[PATCH -next] soc: qcom: dcc: Fix unsigned comparison with less than zero

Yang Li posted 1 patch 2 years, 8 months ago
drivers/soc/qcom/dcc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH -next] soc: qcom: dcc: Fix unsigned comparison with less than zero
Posted by Yang Li 2 years, 8 months ago
The return value from the call to kstrtouint_from_user() is int.
However, the return value is being assigned to
an unsigned int variable 'ret', so making 'ret' an int.

Eliminate the following warning:
./drivers/soc/qcom/dcc.c:815:5-8: WARNING: Unsigned expression compared with zero: ret < 0

Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3638
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
 drivers/soc/qcom/dcc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/dcc.c b/drivers/soc/qcom/dcc.c
index d4101f79cb5d..5b50d638771d 100644
--- a/drivers/soc/qcom/dcc.c
+++ b/drivers/soc/qcom/dcc.c
@@ -808,7 +808,8 @@ static ssize_t config_reset_write(struct file *filp,
 				  const char __user *user_buf, size_t count,
 				  loff_t *ppos)
 {
-	unsigned int val, ret;
+	unsigned int val;
+	int ret;
 	struct dcc_drvdata *drvdata = filp->private_data;
 
 	ret = kstrtouint_from_user(user_buf, count, 0, &val);
-- 
2.20.1.7.g153144c
Re: [PATCH -next] soc: qcom: dcc: Fix unsigned comparison with less than zero
Posted by Bjorn Andersson 2 years, 8 months ago
On Fri, 6 Jan 2023 09:17:10 +0800, Yang Li wrote:
> The return value from the call to kstrtouint_from_user() is int.
> However, the return value is being assigned to
> an unsigned int variable 'ret', so making 'ret' an int.
> 
> Eliminate the following warning:
> ./drivers/soc/qcom/dcc.c:815:5-8: WARNING: Unsigned expression compared with zero: ret < 0
> 
> [...]

Applied, thanks!

[1/1] soc: qcom: dcc: Fix unsigned comparison with less than zero
      commit: d4b2c7484a8edd79c90b9f8acc8a03e5e3235b89

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>