public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Parth Y Shah <sparth1292@gmail.com>
Cc: arnd@arndb.de, gregkh@linuxfoundation.org, bhumirks@gmail.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] misc: eeprom: assignment outside the if statement
Date: Fri, 3 Aug 2018 14:36:12 +0200	[thread overview]
Message-ID: <20180803143612.121fba20@endymion> (raw)
In-Reply-To: <1533288043-19624-1-git-send-email-sparth1292@gmail.com>

On Fri,  3 Aug 2018 14:50:43 +0530, Parth Y Shah wrote:
> Assignment of any variable should be kept outside the if statement

Actually there are exceptions to that rule, but this isn't one of them.

> Signed-off-by: Parth Y Shah <sparth1292@gmail.com>
> ---
>  drivers/misc/eeprom/max6875.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/eeprom/max6875.c b/drivers/misc/eeprom/max6875.c
> index 0e32709..fc0cf9a 100644
> --- a/drivers/misc/eeprom/max6875.c
> +++ b/drivers/misc/eeprom/max6875.c
> @@ -148,7 +148,8 @@ static int max6875_probe(struct i2c_client *client,
>  	if (client->addr & 1)
>  		return -ENODEV;
>  
> -	if (!(data = kzalloc(sizeof(struct max6875_data), GFP_KERNEL)))
> +	data = kzalloc(sizeof(struct max6875_data), GFP_KERNEL);
> +	if (!data)
>  		return -ENOMEM;
>  
>  	/* A fake client is created on the odd address */

Reviewed-by: Jean Delvare <jdelvare@suse.de>

Thanks,
-- 
Jean Delvare
SUSE L3 Support

      reply	other threads:[~2018-08-03 12:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03  9:20 [PATCH] misc: eeprom: assignment outside the if statement Parth Y Shah
2018-08-03 12:36 ` Jean Delvare [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180803143612.121fba20@endymion \
    --to=jdelvare@suse.de \
    --cc=arnd@arndb.de \
    --cc=bhumirks@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparth1292@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox