mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: wangkailong@jari.cn, jdelvare@suse.com,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwmon: (amc6821) Fix unsigned expression compared with zero
Date: Thu, 3 Nov 2022 08:25:33 -0700	[thread overview]
Message-ID: <20221103152533.GB146501@roeck-us.net> (raw)
In-Reply-To: <a530b209-36bd-c2c3-8196-a9c5001f6333@infradead.org>

On Thu, Nov 03, 2022 at 08:03:35AM -0700, Randy Dunlap wrote:
> 
> 
> On 11/3/22 07:17, Guenter Roeck wrote:
> > On Wed, Nov 02, 2022 at 07:59:06PM -0700, Randy Dunlap wrote:
> >>
> >>
> >> On 11/2/22 19:27, wangkailong@jari.cn wrote:
> >>> Fix the following coccicheck warning:
> >>>
> >>> drivers/hwmon/amc6821.c:215: WARNING: Unsigned expression compared
> >>> with zero: reg > 0
> >>> drivers/hwmon/amc6821.c:228: WARNING: Unsigned expression compared
> >>> with zero: reg > 0
> >>>
> >>> Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
> >>
> >> Hm. IDGI. What's wrong with comparing an unsigned value to > 0?
> >> I mean, it could be == 0 or > 0.
> >> Please explain.
> > 
> > I don't get it either. The real problem with this driver is that error
> > returns from i2c functions are not checked. However, that problem is not
> > fixed by this patch. That means the patch would change behavior without
> > fixing the actual problem.
> > 
> > I wonder what kind of (broken) compiler or analyzer produces above errors.
> > We'll have to watch out for similar broken "fixes".
> 
> It says above that it's a coccicheck warning.
> 

I see, unsigned_lesser_than_zero.cocci. It actually complains that an
unsigned variable is used to hold the return code of a function which
returns an int. In other words, it really tries to warn that the error
return code from that function is not or not properly checked.
The message is misleading for that situation.

Guenter

      reply	other threads:[~2022-11-03 15:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03  2:27 wangkailong
2022-11-03  2:59 ` Randy Dunlap
2022-11-03 14:17   ` Guenter Roeck
2022-11-03 15:03     ` Randy Dunlap
2022-11-03 15:25       ` Guenter Roeck [this message]

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=20221103152533.GB146501@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=wangkailong@jari.cn \
    /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

all inboxes | Powered by JetHome®