* [PATCH][next] drivers: thermal: tsens: remove redundant u32 comparison with less than zero
@ 2019-05-31 10:57 Colin King
2019-06-06 14:24 ` Eduardo Valentin
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-05-31 10:57 UTC (permalink / raw)
To: Andy Gross, David Brown, Amit Kucheria, Zhang Rui,
Eduardo Valentin, Daniel Lezcano, linux-arm-msm, linux-pm
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The u32 variable hw_id is unsigned and cannot be less than zero so
the comparison with less than zero is always false and hence is redundant
and can be removed.
Addresses-Coverity: ("Unsigned compared against 0")
Signed-off-by: Colin Ian King <colin.king@canonical.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..f4419f45025d 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.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next] drivers: thermal: tsens: remove redundant u32 comparison with less than zero
2019-05-31 10:57 [PATCH][next] drivers: thermal: tsens: remove redundant u32 comparison with less than zero Colin King
@ 2019-06-06 14:24 ` Eduardo Valentin
0 siblings, 0 replies; 2+ messages in thread
From: Eduardo Valentin @ 2019-06-06 14:24 UTC (permalink / raw)
To: Colin King
Cc: Andy Gross, David Brown, Amit Kucheria, Zhang Rui,
Daniel Lezcano, linux-arm-msm, linux-pm, kernel-janitors,
linux-kernel
hey Colin,
On Fri, May 31, 2019 at 11:57:08AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The u32 variable hw_id is unsigned and cannot be less than zero so
> the comparison with less than zero is always false and hence is redundant
> and can be removed.
>
> Addresses-Coverity: ("Unsigned compared against 0")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thanks for the patch but the commit that introduced this has been
reverted. I pushed an update on my -next branch to silence this in the
linux-next tree too.
> ---
> 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..f4419f45025d 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-06-06 14:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 10:57 [PATCH][next] drivers: thermal: tsens: remove redundant u32 comparison with less than zero Colin King
2019-06-06 14:24 ` 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).