staging: iio: addac: adt7316: return 0 in _adt7316_store_enabled
Subsystems (4)
PATCH 1/1 staging: iio: addac: adt7316: return 0 in _adt7316_store_enabled
_adt7316_store_enabled() writes the config register and returns -EIO if the write fails. When execution reaches the final "return ret;", the write has succeeded, so ret is always 0. Return 0 directly to make the success path obvious.
Found with cppcheck (identicalConditionAfterEarlyExit). All callers either check for a negative return value or pass it through, so behavior does not change.
Compile-tested with W=1. The disassembly of adt7316.o is identical before and after this change.
--- drivers/staging/iio/addac/adt7316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/addac/adt7316.c +1 -1
@@ -236,7 +236,7 @@ static ssize_t _adt7316_store_enabled(struct adt7316_chip_info *chip, chip->config1 = config1; -return ret; +return 0 ; } static ssize_t adt7316_store_enabled(struct device *dev,
Signature · 1 line
2.53.0
Quoted 9 lines · Maria Sheikh
_adt7316_store_enabled()writes the config register and returns-EIOif the write fails. When execution reaches the final "return ret;", the write has succeeded, so ret is always 0. Return 0 directly to make the success path obvious.Found with cppcheck (identicalConditionAfterEarlyExit). All callers either check for a negative return value or pass it through, so behavior does not change.
Quoted 5 lines
Compile-tested with W=1. The disassembly of adt7316.o is identical before and after this change.
Signed-off-by Maria Sheikh <[email protected]>---
regards,
dan carpenter
Quoted 11 lines · On Wed, 4 Nov 2026 09:10:45 +0500 Maria Sheikh <[email protected]>…
_adt7316_store_enabled()writes the config register and returns-EIOif the write fails. When execution reaches the final "return ret;", the write has succeeded, so ret is always 0. Return 0 directly to make the success path obvious.Found with cppcheck (identicalConditionAfterEarlyExit). All callers either check for a negative return value or pass it through, so behavior does not change.
Compile-tested with W=1. The disassembly of adt7316.o is identical before and after this change.
I'd move the testing info below the ---, as it's only compile tested. No need to resend however, this can be fixed up when applying.
Signature · 2 lines
Kind regards, Joshua Crofts
Jonathan Cameron
maintainerQuoted 12 lines · On Wed, 4 Nov 2026 09:00:08 +0100 Joshua Crofts <[email protected]>…
Quoted 9 lines · On Wed, 4 Nov 2026 09:10:45 +0500 Maria Sheikh <[email protected]>…
_adt7316_store_enabled()writes the config register and returns-EIOif the write fails. When execution reaches the final "return ret;", the write has succeeded, so ret is always 0. Return 0 directly to make the success path obvious.Found with cppcheck (identicalConditionAfterEarlyExit). All callers either check for a negative return value or pass it through, so behavior does not change.
Quoted 6 lines
Quoted 2 lines
Compile-tested with W=1. The disassembly of adt7316.o is identical before and after this change.
I'd move the testing info below the ---, as it's only compile tested. No need to resend however, this can be fixed up when applying.
Done whilst applying.
Applied to the testing branch of iio.git
thanks,
Jonathan
Quoted 2 lines
Reviewed-by Joshua Crofts <[email protected]>