* [PATCH v2] staging: greybus: audio: expect 0 from kstrtoint(), not 1
@ 2026-05-22 5:53 Alexander A. Klimov
2026-05-23 10:33 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Alexander A. Klimov @ 2026-05-22 5:53 UTC (permalink / raw)
To: Vaibhav Agarwal, Mark Greer, Johan Hovold, Alex Elder,
Greg Kroah-Hartman, Elise Lennion,
moderated list:GREYBUS SUBSYSTEM, open list:STAGING SUBSYSTEM,
open list
Cc: Alexander A. Klimov
kstrtoint() returns "0 on success, -ERANGE on overflow
and -EINVAL on parsing error". In contrast,
manager_sysfs_remove_store() and manager_sysfs_dump_store()
checked for 1 which always failed the operation. I fixed this.
Fixes: f9a21a3f4919 ("staging: greybus: audio_manager_sysfs: Replace sscanf with kstrto* to single variable conversion.")
Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
---
v2: style (X,!X instead of X!=0,X==0)
drivers/staging/greybus/audio_manager_sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/greybus/audio_manager_sysfs.c b/drivers/staging/greybus/audio_manager_sysfs.c
index fcd518f9540c..581791d566e3 100644
--- a/drivers/staging/greybus/audio_manager_sysfs.c
+++ b/drivers/staging/greybus/audio_manager_sysfs.c
@@ -44,7 +44,7 @@ static ssize_t manager_sysfs_remove_store(struct kobject *kobj,
int num = kstrtoint(buf, 10, &id);
- if (num != 1)
+ if (num)
return -EINVAL;
num = gb_audio_manager_remove(id);
@@ -65,7 +65,7 @@ static ssize_t manager_sysfs_dump_store(struct kobject *kobj,
int num = kstrtoint(buf, 10, &id);
- if (num == 1) {
+ if (!num) {
num = gb_audio_manager_dump_module(id);
if (num)
return num;
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] staging: greybus: audio: expect 0 from kstrtoint(), not 1
2026-05-22 5:53 [PATCH v2] staging: greybus: audio: expect 0 from kstrtoint(), not 1 Alexander A. Klimov
@ 2026-05-23 10:33 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-05-23 10:33 UTC (permalink / raw)
To: Alexander A. Klimov
Cc: Vaibhav Agarwal, Mark Greer, Johan Hovold, Alex Elder,
Greg Kroah-Hartman, Elise Lennion,
moderated list:GREYBUS SUBSYSTEM, open list:STAGING SUBSYSTEM,
open list
On Fri, May 22, 2026 at 07:53:43AM +0200, Alexander A. Klimov wrote:
> kstrtoint() returns "0 on success, -ERANGE on overflow
> and -EINVAL on parsing error". In contrast,
> manager_sysfs_remove_store() and manager_sysfs_dump_store()
> checked for 1 which always failed the operation. I fixed this.
>
> Fixes: f9a21a3f4919 ("staging: greybus: audio_manager_sysfs: Replace sscanf with kstrto* to single variable conversion.")
> Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
> ---
> v2: style (X,!X instead of X!=0,X==0)
>
> drivers/staging/greybus/audio_manager_sysfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/greybus/audio_manager_sysfs.c b/drivers/staging/greybus/audio_manager_sysfs.c
> index fcd518f9540c..581791d566e3 100644
> --- a/drivers/staging/greybus/audio_manager_sysfs.c
> +++ b/drivers/staging/greybus/audio_manager_sysfs.c
> @@ -44,7 +44,7 @@ static ssize_t manager_sysfs_remove_store(struct kobject *kobj,
>
> int num = kstrtoint(buf, 10, &id);
>
> - if (num != 1)
> + if (num)
> return -EINVAL;
Really num is the wrong name. It should be ret. Also the declaration
should be at the start of the function... :/
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-23 10:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22 5:53 [PATCH v2] staging: greybus: audio: expect 0 from kstrtoint(), not 1 Alexander A. Klimov
2026-05-23 10:33 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox