From: Colin King <colin.king@canonical.com>
To: Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Alexandru Tachici <alexandru.tachici@analog.com>,
linux-hwmon@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] hwmon: ltc2992: fix less than zero comparisons with an unsigned integer
Date: Mon, 7 Dec 2020 14:24:10 +0000 [thread overview]
Message-ID: <20201207142410.168987-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
There are several occurrances of a less than zero error check on
a u32 unsigned integer. These will never be true. Fix this by making
reg_value a plain int.
Addresses-Coverity: ("Unsigned comparison against zero")
Fixes: e126370240e0 ("hwmon: (ltc2992) Add support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/hwmon/ltc2992.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/hwmon/ltc2992.c b/drivers/hwmon/ltc2992.c
index 69dbb5aa5dc2..4382105bf142 100644
--- a/drivers/hwmon/ltc2992.c
+++ b/drivers/hwmon/ltc2992.c
@@ -480,7 +480,7 @@ static int ltc2992_read_gpios_in(struct device *dev, u32 attr, int nr_gpio, long
static int ltc2992_read_in_alarm(struct ltc2992_state *st, int channel, long *val, u32 attr)
{
- u32 reg_val;
+ int reg_val;
u32 mask;
if (attr == hwmon_in_max_alarm)
@@ -534,7 +534,7 @@ static int ltc2992_read_in(struct device *dev, u32 attr, int channel, long *val)
static int ltc2992_get_current(struct ltc2992_state *st, u32 reg, u32 channel, long *val)
{
- u32 reg_val;
+ int reg_val;
reg_val = ltc2992_read_reg(st, reg, 2);
if (reg_val < 0)
@@ -558,7 +558,7 @@ static int ltc2992_set_current(struct ltc2992_state *st, u32 reg, u32 channel, l
static int ltc2992_read_curr_alarm(struct ltc2992_state *st, int channel, long *val, u32 attr)
{
- u32 reg_val;
+ int reg_val;
u32 mask;
if (attr == hwmon_curr_max_alarm)
@@ -609,7 +609,7 @@ static int ltc2992_read_curr(struct device *dev, u32 attr, int channel, long *va
static int ltc2992_get_power(struct ltc2992_state *st, u32 reg, u32 channel, long *val)
{
- u32 reg_val;
+ int reg_val;
reg_val = ltc2992_read_reg(st, reg, 3);
if (reg_val < 0)
@@ -633,7 +633,7 @@ static int ltc2992_set_power(struct ltc2992_state *st, u32 reg, u32 channel, lon
static int ltc2992_read_power_alarm(struct ltc2992_state *st, int channel, long *val, u32 attr)
{
- u32 reg_val;
+ int reg_val;
u32 mask;
if (attr == hwmon_power_max_alarm)
--
2.29.2
next reply other threads:[~2020-12-07 14:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 14:24 Colin King [this message]
2020-12-07 15:51 ` [PATCH][next] hwmon: ltc2992: fix less than zero comparisons with an unsigned integer Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201207142410.168987-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=alexandru.tachici@analog.com \
--cc=jdelvare@suse.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).