Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <david@lechnology.com>
Cc: Colin Ian King <colin.i.king@gmail.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] iio: adc: ti-ads7950: remove redundant assignment to variable ret
Date: Sun, 7 Jan 2024 16:02:32 +0000	[thread overview]
Message-ID: <20240107160232.4cdbae62@jic23-huawei> (raw)
In-Reply-To: <e0f58f77-1dd0-4def-84ec-eded4b7d2092@lechnology.com>

On Sat, 6 Jan 2024 12:14:22 -0600
David Lechner <david@lechnology.com> wrote:

> On 1/6/24 9:22 AM, Colin Ian King wrote:
> > Variable ret is being assigned a value that is never read, the variable
> > is being re-assigned again a few statements later. Remove it.
> > 
> > Cleans up clang scan build warning:
> > warning: Value stored to 'ret' is never read [deadcode.DeadStores]
> > 
> > Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> > ---
> >   drivers/iio/adc/ti-ads7950.c | 2 --
> >   1 file changed, 2 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
> > index 263fc3a1b87e..f975de059ba0 100644
> > --- a/drivers/iio/adc/ti-ads7950.c
> > +++ b/drivers/iio/adc/ti-ads7950.c
> > @@ -441,8 +441,6 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
> >   	if (ret)
> >   		goto out;
> >   
> > -	ret = ((st->single_rx >> 12) & BIT(offset)) ? 1 : 0;
> > -
> >   	/* Revert back to original settings */
> >   	st->cmd_settings_bitmask &= ~TI_ADS7950_CR_GPIO_DATA;
> >   	st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);  
> 
> This does not look like the correct fix. This is the intended return value of the function in the case of no errors. So we probably need to introduce a new variable instead so that it doesn't get written over.

Agreed.  Needs to stash that in another local variable and return that value
if ret == 0.

J


  reply	other threads:[~2024-01-07 16:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-06 15:22 [PATCH][next] iio: adc: ti-ads7950: remove redundant assignment to variable ret Colin Ian King
2024-01-06 18:14 ` David Lechner
2024-01-07 16:02   ` Jonathan Cameron [this message]
2024-01-08  7:45     ` Dan Carpenter

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=20240107160232.4cdbae62@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=colin.i.king@gmail.com \
    --cc=david@lechnology.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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