* [PATCH] thermal: tsens: Remove unnecessary comparison of unsigned integer with < 0
@ 2019-05-27 16:08 Gustavo A. R. Silva
2019-05-29 2:36 ` Eduardo Valentin
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2019-05-27 16:08 UTC (permalink / raw)
To: Amit Kucheria, Andy Gross, David Brown, Zhang Rui,
Eduardo Valentin, Daniel Lezcano
Cc: linux-pm, linux-arm-msm, linux-kernel, 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.
Addresses-Coverity-ID: 1445440 ("Unsigned compared against 0")
Fixes: 3e6a8fb33084 ("drivers: thermal: tsens: Add new operation to check if a sensor is enabled")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/thermal/qcom/tsens-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
index 928e8e81ba69..94878ad35464 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -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)
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] thermal: tsens: Remove unnecessary comparison of unsigned integer with < 0
2019-05-27 16:08 [PATCH] thermal: tsens: Remove unnecessary comparison of unsigned integer with < 0 Gustavo A. R. Silva
@ 2019-05-29 2:36 ` Eduardo Valentin
0 siblings, 0 replies; 2+ messages in thread
From: Eduardo Valentin @ 2019-05-29 2:36 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Amit Kucheria, Andy Gross, David Brown, Zhang Rui,
Daniel Lezcano, linux-pm, linux-arm-msm, linux-kernel
Gustavo,
On Mon, May 27, 2019 at 11:08:25AM -0500, Gustavo A. R. Silva wrote:
> 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.
>
> Addresses-Coverity-ID: 1445440 ("Unsigned compared against 0")
> Fixes: 3e6a8fb33084 ("drivers: thermal: tsens: Add new operation to check if a sensor is enabled")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/thermal/qcom/tsens-common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
> index 928e8e81ba69..94878ad35464 100644
> --- a/drivers/thermal/qcom/tsens-common.c
> +++ b/drivers/thermal/qcom/tsens-common.c
> @@ -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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-29 2:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27 16:08 [PATCH] thermal: tsens: Remove unnecessary comparison of unsigned integer with < 0 Gustavo A. R. Silva
2019-05-29 2:36 ` Eduardo Valentin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).