Skip to contentSkip to conversation

thermal: tsens: Remove unnecessary comparison of unsigned integer with < 0

PATCH In review Gustavo A. R. Silva 2 participants 2 messages May 27, 2019 – May 29, 2019

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

PATCH 1/1 thermal: tsens: Remove unnecessary comparison of unsigned integer with < 0

There is no need to compare hw_id with < 0 because such comparison of an unsigned value is always false.

Fix this by removing such comparison.

Addresses-Coverity-ID: 1445440 ("Unsigned compared against 0")

Fixes 3e6a8fb33084 ("drivers: thermal: tsens: Add new operation to check if a sensor is enabled")
---
 drivers/thermal/qcom/tsens-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/qcom/tsens-common.c +1 -1
index 928e8e81ba69..94878ad35464 100644
@@ -69,7 +69,7 @@ bool is_sensor_enabled(struct tsens_priv *priv, u32 hw_id)
 	u32 val;
 	int ret;
 
-	if ((hw_id > (priv->num_sensors - 1)) || (hw_id < 0))
+	if (hw_id > priv->num_sensors - 1)
 		return -EINVAL;
 	ret = regmap_field_read(priv->rf[SENSOR_EN], &val);
 	if (ret)
Signature · 1 line
2.21.0
#1 lore raw

Gustavo,

Quoted 4 lines · Gustavo A. R. Silva

There is no need to compare hw_id with < 0 because such comparison of an unsigned value is always false.

Fix this by removing such comparison.

Thanks for fixing this. But we had to revert the commit that introduces this issue. So this patch is no longer applicable.

Quoted 21 lines

Addresses-Coverity-ID: 1445440 ("Unsigned compared against 0")

Fixes 3e6a8fb33084 ("drivers: thermal: tsens: Add new operation to check if a sensor is enabled")
---
 drivers/thermal/qcom/tsens-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/qcom/tsens-common.c +1 -1
index 928e8e81ba69..94878ad35464 100644
@@ -69,7 +69,7 @@ bool is_sensor_enabled(struct tsens_priv *priv, u32 hw_id)
 	u32 val;
 	int ret;
 
-	if ((hw_id > (priv->num_sensors - 1)) || (hw_id < 0))
+	if (hw_id > priv->num_sensors - 1)
 		return -EINVAL;
 	ret = regmap_field_read(priv->rf[SENSOR_EN], &val);
 	if (ret)