Skip to contentSkip to conversation

iio: adc: ti-ads7950: remove redundant assignment to variable ret

PATCH In review Colin Ian King 4 participants 4 messages Jan 6, 2024 – Jan 8, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: ti-ads7950: remove redundant assignment to variable ret

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]

---
 drivers/iio/adc/ti-ads7950.c | 2 --
 1 file changed, 2 deletions(-)
drivers/iio/adc/ti-ads7950.c +0 -2
index 263fc3a1b87e..f975de059ba0 100644
@@ -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);
Signature · 1 line
2.39.2
#1 lore raw
Quoted 16 lines · Colin Ian King

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]

---
  drivers/iio/adc/ti-ads7950.c | 2 --
  1 file changed, 2 deletions(-)
drivers/iio/adc/ti-ads7950.c +0 -0
index 263fc3a1b87e..f975de059ba0 100644

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset) · line 446

Quoted 8 lines
drivers/iio/adc/ti-ads7950.c +0 -2
@@ -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.

maintainer
#2 lore raw
Quoted 20 lines · On Sat, 6 Jan 2024 12:14:22 -0600 David Lechner <[email protected]> wrote:
Quoted 19 lines · Colin Ian King

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]

---
  drivers/iio/adc/ti-ads7950.c | 2 --
  1 file changed, 2 deletions(-)
drivers/iio/adc/ti-ads7950.c +0 -0
index 263fc3a1b87e..f975de059ba0 100644
@@ -441,8 +441,6 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
  	if (ret)
  		goto out;
 
Quoted 7 lines

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset) · line 446

Quoted 5 lines
drivers/iio/adc/ti-ads7950.c +0 -2
-	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

#3 lore raw

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

Quoted 36 lines · Jonathan Cameron
Quoted 20 lines · On Sat, 6 Jan 2024 12:14:22 -0600 David Lechner <[email protected]> wrote:
Quoted 19 lines · Colin Ian King

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]

---
  drivers/iio/adc/ti-ads7950.c | 2 --
  1 file changed, 2 deletions(-)
drivers/iio/adc/ti-ads7950.c +0 -0
index 263fc3a1b87e..f975de059ba0 100644
@@ -441,8 +441,6 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
  	if (ret)
  		goto out;
 
Quoted 7 lines

drivers/iio/adc/ti-ads7950.c static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset) · line 446

Quoted 5 lines
drivers/iio/adc/ti-ads7950.c +0 -2
-	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