Skip to contentSkip to conversation

hwmon: HS3001: remove redundant store on division

PATCH Applied Colin Ian King 2 participants 2 messages Oct 23, 2023 – Oct 25, 2023

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

PATCH 1/1 hwmon: HS3001: remove redundant store on division

Currently the local variable hum is being divided by a constant and the results is being re-assigned back to hum before the value is being returned to the caller. The assignment to hum is redundant and can be removed.

Cleans up clang scan build warning:
drivers/hwmon/hs3001.c:65:9: warning: Although the value stored to 'hum' is used in the enclosing expression, the value is never actually read from 'hum' [deadcode.DeadStores]

---
 drivers/hwmon/hs3001.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/hs3001.c +1 -1
index ac574e46d069..01ea9a3062bc 100644
@@ -62,7 +62,7 @@ static u32 hs3001_extract_humidity(u16 raw)
 {
 	u32 hum = (raw & HS3001_MASK_HUMIDITY_0X3FFF) * HS3001_FIXPOINT_ARITH * 100;
 
-	return hum /= (1 << 14) - 1;
+	return hum / (1 << 14) - 1;
 }
 
 static int hs3001_data_fetch_command(struct i2c_client *client,
Signature · 1 line
2.39.2
maintainer Applied
#1 lore raw
Quoted 11 lines · Colin Ian King

Currently the local variable hum is being divided by a constant and the results is being re-assigned back to hum before the value is being returned to the caller. The assignment to hum is redundant and can be removed.

Cleans up clang scan build warning:
drivers/hwmon/hs3001.c:65:9: warning: Although the value stored to 'hum' is used in the enclosing expression, the value is never actually read from 'hum' [deadcode.DeadStores]

Applied.

Guenter