i2c: core: squelch error: uninitialized symbol 'ret'
Subsystems (2)
PATCH 1/1 i2c: core: squelch error: uninitialized symbol 'ret'
The following smatch error was introduced by commit 7ca5f6be7900 ("i2c:
recovery: add get_bus_free callback"):
drivers/i2c/i2c-core-base.c:228 i2c_generic_scl_recovery() error: uninitialized symbol 'ret'.
Analysis of the code appears to show that the smatch error is a false positive since 'ret' will in fact be initialized after exiting the 'while()' loop.
Squelch the smatch error since it is a false positive.
--- drivers/i2c/i2c-core-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core-base.c +1 -1
@@ -185,7 +185,7 @@ static int i2c_generic_bus_free(struct i2c_adapter *adap)int i2c_generic_scl_recovery (struct i2c_adapter *adap) {struct i2c_bus_recovery_info *bri = adap->bus_recovery_info; -int i =0 , scl =1 , ret; +int i =0 , scl =1 ,uninitialized_var (ret );if (bri->prepare_recovery) bri->prepare_recovery (adap);
Signature · 1 line
2.14.4
Quoted 10 lines · George G. Davis
The following smatch error was introduced by commit
7ca5f6be7900("i2c:
recovery: addget_bus_freecallback"):
drivers/i2c/i2c-core-base.c:228i2c_generic_scl_recovery()error: uninitialized symbol 'ret'.Analysis of the code appears to show that the smatch error is a false positive since 'ret' will in fact be initialized after exiting the '
while()' loop.Squelch the smatch error since it is a false positive.
What about fixing smatch?
Quoted 23 lines
Fixes 7ca5f6be7900 ("i2c: recovery: add get_bus_free callback")Signed-off-by George G. Davis <[email protected]>--- drivers/i2c/i2c-core-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/i2c-core-base.c +1
-1@@ -185,7 +185,7 @@ static int i2c_generic_bus_free(struct i2c_adapter *adap)int i2c_generic_scl_recovery (struct i2c_adapter *adap) {struct i2c_bus_recovery_info *bri = adap->bus_recovery_info; -int i =0 , scl =1 , ret; +int i =0 , scl =1 ,uninitialized_var (ret );if (bri->prepare_recovery) bri->prepare_recovery (adap);Signature · 1 line
2.14.4
Quoted 6 lines · Wolfram Sang
Quoted 5 lines · George G. Davis
The following smatch error was introduced by commit
7ca5f6be7900("i2c:
recovery: addget_bus_freecallback"):
drivers/i2c/i2c-core-base.c:228i2c_generic_scl_recovery()error: uninitialized symbol 'ret'.
Quoted 7 lines
Quoted 5 lines
Analysis of the code appears to show that the smatch error is a false positive since 'ret' will in fact be initialized after exiting the '
while()' loop.Squelch the smatch error since it is a false positive.
What about fixing smatch?
That would perhaps be the better long term solution. Something tells me that this topic comes up periodically. : ) For the record, I've confirmed that this problem exists while using the latest version of smatch [1] but I doubt my abilities to fix smatch. So I chose to squelch it instead.
Feel free to ignore if this is a topic already discussed in other threads. To be honest, I did not search the mailing list to determine if this particular issue was already discussed.
--
Regards,
George
[1] https://repo.or.cz/smatch.git/commit/79fe36620a7a3a45d1a51d62238da250fb8db920
Quoted 24 lines
Quoted 24 lines
Fixes 7ca5f6be7900 ("i2c: recovery: add get_bus_free callback")Signed-off-by George G. Davis <[email protected]>--- drivers/i2c/i2c-core-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/i2c-core-base.c +1
-1@@ -185,7 +185,7 @@ static int i2c_generic_bus_free(struct i2c_adapter *adap)int i2c_generic_scl_recovery (struct i2c_adapter *adap) {struct i2c_bus_recovery_info *bri = adap->bus_recovery_info; -int i =0 , scl =1 , ret; +int i =0 , scl =1 ,uninitialized_var (ret );if (bri->prepare_recovery) bri->prepare_recovery (adap);Signature · 1 line
2.14.4
Quoted 4 lines
Feel free to ignore if this is a topic already discussed in other threads. To be honest, I did not search the mailing list to determine if this particular issue was already discussed.
Not this particular issue, but in general we usually don't change working code to silence false positives in code checkers.
But thanks for letting me know this is a false positive!
BTW next time CC Dan Carpenter, he might be interested to fix the issue in smatch.
Quoted 7 lines · Wolfram Sang
Quoted 4 lines
Feel free to ignore if this is a topic already discussed in other threads. To be honest, I did not search the mailing list to determine if this particular issue was already discussed.
Not this particular issue, but in general we usually don't change working code to silence false positives in code checkers.
Ok.
Quoted 1 line
But thanks for letting me know this is a false positive!
No worries. Thanks for having a look.
Quoted 2 lines
BTW next time CC Dan Carpenter, he might be interested to fix the issue in smatch.
I'll try to remember this in the future.
Thanks again!
--
Regards,
George