Skip to contentSkip to conversation

staging: iio: addac: adt7316: return 0 in _adt7316_store_enabled

PATCH In review Maria Sheikh 4 participants 4 messages Nov 4 – Nov 7

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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
index 20f6052cc7fb..4cb03e7808ab 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Maria Sheikh

_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.

Quoted 5 lines

Compile-tested with W=1. The disassembly of adt7316.o is identical before and after this change.

---

regards,
dan carpenter

Reviewed-by on v1 1/1
#2 lore raw
In reply to Maria Sheikh
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 -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.

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
maintainer
#3 lore raw
Quoted 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 -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.

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