linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] ipmi_ssif: silence an uninitialized variable warning
@ 2016-04-04 11:16 Dan Carpenter
  2016-04-04 13:03 ` Corey Minyard
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-04-04 11:16 UTC (permalink / raw)
  To: Corey Minyard; +Cc: openipmi-developer, linux-kernel, kernel-janitors

My static checker complains that "ret" could be zero here.  (Presumably
that means the hardware is badly busted).  But the result would be that
the caller assumes *resp_len is initialized when it's not and it leads
to a warning.  Let's just silence the warning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 8b3be8b..512c5b6 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1232,6 +1232,8 @@ static int do_cmd(struct i2c_client *client, int len, unsigned char *msg,
 			break;
 	}
 
+	if (ret == 0)
+		ret = -EINVAL;
 	if (ret > 0) {
 		/* Validate that the response is correct. */
 		if (ret < 3 ||

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

* Re: [patch] ipmi_ssif: silence an uninitialized variable warning
  2016-04-04 11:16 [patch] ipmi_ssif: silence an uninitialized variable warning Dan Carpenter
@ 2016-04-04 13:03 ` Corey Minyard
  0 siblings, 0 replies; 2+ messages in thread
From: Corey Minyard @ 2016-04-04 13:03 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: openipmi-developer, linux-kernel, kernel-janitors

On 04/04/2016 06:16 AM, Dan Carpenter wrote:
> My static checker complains that "ret" could be zero here.  (Presumably
> that means the hardware is badly busted).  But the result would be that
> the caller assumes *resp_len is initialized when it's not and it leads
> to a warning.  Let's just silence the warning.

I don't think i2c_smbus_read_block_data() can return a zero, it's either 
an error or a message.

I'm ok with this, but can you add a comment saying why this is here?  I 
don't like strange looking code without explanations.

Thanks,
-corey

> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
> index 8b3be8b..512c5b6 100644
> --- a/drivers/char/ipmi/ipmi_ssif.c
> +++ b/drivers/char/ipmi/ipmi_ssif.c
> @@ -1232,6 +1232,8 @@ static int do_cmd(struct i2c_client *client, int len, unsigned char *msg,
>   			break;
>   	}
>   
> +	if (ret == 0)
> +		ret = -EINVAL;
>   	if (ret > 0) {
>   		/* Validate that the response is correct. */
>   		if (ret < 3 ||

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

end of thread, other threads:[~2016-04-04 13:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-04 11:16 [patch] ipmi_ssif: silence an uninitialized variable warning Dan Carpenter
2016-04-04 13:03 ` Corey Minyard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).