* [PATCH][next] iio: adc: ti-ads7950: remove redundant assignment to variable ret
@ 2024-01-06 15:22 Colin Ian King
2024-01-06 18:14 ` David Lechner
0 siblings, 1 reply; 4+ messages in thread
From: Colin Ian King @ 2024-01-06 15:22 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen, David Lechner, linux-iio
Cc: kernel-janitors, linux-kernel
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);
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] iio: adc: ti-ads7950: remove redundant assignment to variable ret
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
0 siblings, 1 reply; 4+ messages in thread
From: David Lechner @ 2024-01-06 18:14 UTC (permalink / raw)
To: Colin Ian King, Jonathan Cameron, Lars-Peter Clausen, linux-iio
Cc: kernel-janitors, linux-kernel
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] iio: adc: ti-ads7950: remove redundant assignment to variable ret
2024-01-06 18:14 ` David Lechner
@ 2024-01-07 16:02 ` Jonathan Cameron
2024-01-08 7:45 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2024-01-07 16:02 UTC (permalink / raw)
To: David Lechner
Cc: Colin Ian King, Lars-Peter Clausen, linux-iio, kernel-janitors,
linux-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] iio: adc: ti-ads7950: remove redundant assignment to variable ret
2024-01-07 16:02 ` Jonathan Cameron
@ 2024-01-08 7:45 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-01-08 7:45 UTC (permalink / raw)
To: Jonathan Cameron, Justin Chen
Cc: David Lechner, Colin Ian King, Lars-Peter Clausen, linux-iio,
kernel-janitors, linux-kernel
Justin Chen should have been on the CC list... It's a little late now
because we've kind of figured things out already, but lets add him
anyway.
regards,
dan carpenter
On Sun, Jan 07, 2024 at 04:02:32PM +0000, Jonathan Cameron wrote:
> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-08 7:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-01-08 7:45 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox