From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754250AbcDDNDi (ORCPT ); Mon, 4 Apr 2016 09:03:38 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:35997 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751065AbcDDNDg (ORCPT ); Mon, 4 Apr 2016 09:03:36 -0400 Reply-To: minyard@acm.org Subject: Re: [patch] ipmi_ssif: silence an uninitialized variable warning References: <20160404111657.GA26910@mwanda> To: Dan Carpenter Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org From: Corey Minyard Message-ID: <57026624.7000007@acm.org> Date: Mon, 4 Apr 2016 08:03:32 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160404111657.GA26910@mwanda> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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 ||