ALSA: usb-audio: Fix missing return assignment
Subsystems (2)
PATCH 1/1 ALSA: usb-audio: Fix missing return assignment
Return value of usb_driver_claim_interface should not be ignored. Instead it should be stored in err variable and returned from this function.
--- sound/usb/quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/quirks.c +2 -2
@@ -427,10 +427,10 @@ static int create_autodetect_quirks(struct snd_usb_audio *chip, err =create_autodetect_quirk (chip, iface, driver);if (err >=0 ) -usb_driver_claim_interface (driver, iface, (void *)-1L ); + err =usb_driver_claim_interface (driver, iface, (void *)-1L ); } -return 0 ; +return err; }/*
Signature · 1 line
2.25.1
Quoted 14 lines · Muhammad Usama Anjum
Return value of
usb_driver_claim_interfaceshould not be ignored. Instead it should be stored in err variable and returned from this function.Signed-off-by Muhammad Usama Anjum <[email protected]>--- sound/usb/quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)sound/usb/quirks.c +0
-0
sound/usb/quirks.c static int create_autodetect_quirks(struct snd_usb_audio *chip, · line 429
Quoted 3 lines
sound/usb/quirks.c +0
-0@@ -427,10 +427,10 @@ static int create_autodetect_quirks(struct snd_usb_audio *chip, err =create_autodetect_quirk (chip, iface, driver);if (err >=0 )
create_autodetect_quirk() never returns positive values. Flip this condition. (Always do error handling, don't do success handling).
if (err) continue;
sound/usb/quirks.c static int create_autodetect_quirks(struct snd_usb_audio *chip, · line 430
Quoted 2 lines
sound/usb/quirks.c +1
-1-usb_driver_claim_interface (driver, iface, (void *)-1L ); + err =usb_driver_claim_interface (driver, iface, (void *)-1L );
This is in a loop so only the last return value is used. Which seems sort of weird and pointless that the last value would matter more than the others.
sound/usb/quirks.c static int create_autodetect_quirks(struct snd_usb_audio *chip, · line 433
Quoted 4 lines
sound/usb/quirks.c +1
-1} -return 0 ; +return err;
regards,
dan carpenter
Quoted 16 lines · Dan Carpenter
Quoted 15 lines · Muhammad Usama Anjum
Return value of
usb_driver_claim_interfaceshould not be ignored. Instead it should be stored in err variable and returned from this function.Signed-off-by Muhammad Usama Anjum <[email protected]>--- sound/usb/quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)sound/usb/quirks.c +0
-0@@ -427,10 +427,10 @@ static int create_autodetect_quirks(struct snd_usb_audio *chip,
Quoted 8 lines
sound/usb/quirks.c static int create_autodetect_quirks(struct snd_usb_audio *chip, · line 429
Quoted 2 lines
sound/usb/quirks.c +0
-0err =create_autodetect_quirk (chip, iface, driver);if (err >=0 )
create_autodetect_quirk()never returns positive values. Flip this condition. (Always do error handling, don't do success handling).if (err) continue;
Got it. I'll send a patch.
Quoted 9 lines
sound/usb/quirks.c static int create_autodetect_quirks(struct snd_usb_audio *chip, · line 430
Quoted 4 lines
sound/usb/quirks.c +1
-1-usb_driver_claim_interface (driver, iface, (void *)-1L ); + err =usb_driver_claim_interface (driver, iface, (void *)-1L );This is in a loop so only the last return value is used. Which seems sort of weird and pointless that the last value would matter more than the others.
Correct. Lets not store the return value. To stop the static analyzers to report the missing return assignment, can we add (void) in start of this function call? I've not seen use of (void) this way in the kernel. Is there any other way used in the kernel?
Quoted 8 lines
sound/usb/quirks.c static int create_autodetect_quirks(struct snd_usb_audio *chip, · line 433
Quoted 4 lines
sound/usb/quirks.c +1
-1} -return 0 ; +return err;regards,
dan carpenter
Quoted 8 lines · Muhammad Usama Anjum
Quoted 7 lines · Dan Carpenter
sound/usb/quirks.c static int create_autodetect_quirks(struct snd_usb_audio *chip, · line 430
Quoted 2 lines
sound/usb/quirks.c +1
-1-usb_driver_claim_interface (driver, iface, (void *)-1L ); + err =usb_driver_claim_interface (driver, iface, (void *)-1L );This is in a loop so only the last return value is used. Which seems sort of weird and pointless that the last value would matter more than the others.
Quoted 4 lines
Correct. Lets not store the return value. To stop the static analyzers to report the missing return assignment, can we add (void) in start of this function call? I've not seen use of (void) this way in the kernel. Is there any other way used in the kernel?
Don't add (void). Don't add any code just to help static checkers, only do it if it helps humans. The (void) stuff is ugly. We have a __must_check annotation for functions where it's a bug not to check the return and the usb_driver_claim_interface() is not a __must_check function. Just ignore the static checker when it's wrong.
When I'm reviewing static checker warnings, I only look at the new ones. Then after I've looked at them, I mark them as old. I currently have 65k old ignored warnings.
regards,
dan carpenter