All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: core: squelch error: uninitialized symbol 'ret'
@ 2018-10-05 16:18 ` George G. Davis
  0 siblings, 0 replies; 6+ messages in thread
From: George G. Davis @ 2018-10-05 16:18 UTC (permalink / raw)
  To: Wolfram Sang, open list:I2C SUBSYSTEM, open list; +Cc: George G. Davis

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.

Fixes: 7ca5f6be7900 ("i2c: recovery: add get_bus_free callback")
Signed-off-by: George G. Davis <george_davis@mentor.com>
---
 drivers/i2c/i2c-core-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 9ee9a15e7134..7b25ecb6b616 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -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);
-- 
2.14.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] i2c: core: squelch error: uninitialized symbol 'ret'
@ 2018-10-05 16:18 ` George G. Davis
  0 siblings, 0 replies; 6+ messages in thread
From: George G. Davis @ 2018-10-05 16:18 UTC (permalink / raw)
  To: Wolfram Sang, open list:I2C SUBSYSTEM, open list; +Cc: George G. Davis

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.

Fixes: 7ca5f6be7900 ("i2c: recovery: add get_bus_free callback")
Signed-off-by: George G. Davis <george_davis@mentor.com>
---
 drivers/i2c/i2c-core-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 9ee9a15e7134..7b25ecb6b616 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -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);
-- 
2.14.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: core: squelch error: uninitialized symbol 'ret'
  2018-10-05 16:18 ` George G. Davis
  (?)
@ 2018-10-05 16:28 ` Wolfram Sang
  2018-10-05 16:45   ` George G. Davis
  -1 siblings, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2018-10-05 16:28 UTC (permalink / raw)
  To: George G. Davis; +Cc: open list:I2C SUBSYSTEM, open list, George G. Davis

[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]

On Fri, Oct 05, 2018 at 12:18:25PM -0400, George G. Davis wrote:
> 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.

What about fixing smatch?

> 
> Fixes: 7ca5f6be7900 ("i2c: recovery: add get_bus_free callback")
> Signed-off-by: George G. Davis <george_davis@mentor.com>
> ---
>  drivers/i2c/i2c-core-base.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 9ee9a15e7134..7b25ecb6b616 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -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);
> -- 
> 2.14.4
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: core: squelch error: uninitialized symbol 'ret'
  2018-10-05 16:28 ` Wolfram Sang
@ 2018-10-05 16:45   ` George G. Davis
  2018-10-05 17:43     ` Wolfram Sang
  0 siblings, 1 reply; 6+ messages in thread
From: George G. Davis @ 2018-10-05 16:45 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: open list:I2C SUBSYSTEM, open list, George G. Davis

On Fri, Oct 05, 2018 at 06:28:41PM +0200, Wolfram Sang wrote:
> On Fri, Oct 05, 2018 at 12:18:25PM -0400, George G. Davis wrote:
> > 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.
> 
> 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
> 
> > 
> > Fixes: 7ca5f6be7900 ("i2c: recovery: add get_bus_free callback")
> > Signed-off-by: George G. Davis <george_davis@mentor.com>
> > ---
> >  drivers/i2c/i2c-core-base.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> > index 9ee9a15e7134..7b25ecb6b616 100644
> > --- a/drivers/i2c/i2c-core-base.c
> > +++ b/drivers/i2c/i2c-core-base.c
> > @@ -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);
> > -- 
> > 2.14.4
> > 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: core: squelch error: uninitialized symbol 'ret'
  2018-10-05 16:45   ` George G. Davis
@ 2018-10-05 17:43     ` Wolfram Sang
  2018-10-05 20:55       ` George G. Davis
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2018-10-05 17:43 UTC (permalink / raw)
  To: George G. Davis; +Cc: open list:I2C SUBSYSTEM, open list, George G. Davis

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]


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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: core: squelch error: uninitialized symbol 'ret'
  2018-10-05 17:43     ` Wolfram Sang
@ 2018-10-05 20:55       ` George G. Davis
  0 siblings, 0 replies; 6+ messages in thread
From: George G. Davis @ 2018-10-05 20:55 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: open list:I2C SUBSYSTEM, open list, George G. Davis

On Fri, Oct 05, 2018 at 07:43:01PM +0200, Wolfram Sang wrote:
> 
> > 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.

> But thanks for letting me know this is a false positive!

No worries. Thanks for having a look.

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-10-05 20:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-05 16:18 [PATCH] i2c: core: squelch error: uninitialized symbol 'ret' George G. Davis
2018-10-05 16:18 ` George G. Davis
2018-10-05 16:28 ` Wolfram Sang
2018-10-05 16:45   ` George G. Davis
2018-10-05 17:43     ` Wolfram Sang
2018-10-05 20:55       ` George G. Davis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.