From: Guenter Roeck <linux@roeck-us.net>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: kernel test robot <lkp@intel.com>,
oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-hwmon@vger.kernel.org
Subject: Re: drivers/hwmon/jc42.c:477 jc42_readable_reg() warn: always true condition '(reg >= 0) => (0-u32max >= 0)'
Date: Thu, 22 Dec 2022 15:41:48 -0800 [thread overview]
Message-ID: <20221222234148.GA2776378@roeck-us.net> (raw)
In-Reply-To: <CAFBinCAB0VuoKKm4YHv_zB1d1xN3nP0=-xg9EotiWMJ_vikc2w@mail.gmail.com>
On Thu, Dec 22, 2022 at 10:20:13PM +0100, Martin Blumenstingl wrote:
> Hi Guenter et al.,
>
> On Thu, Dec 22, 2022 at 3:36 PM kernel test robot <lkp@intel.com> wrote:
> [...]
> > 475 static bool jc42_readable_reg(struct device *dev, unsigned int reg)
> > 476 {
> > > 477 return (reg >= JC42_REG_CAP && reg <= JC42_REG_DEVICEID) ||
> > 478 reg == JC42_REG_SMBUS;
> The bot is right: we can omit "reg >= JC42_REG_CAP" as it's already
> covered by the fact that:
> - the reg variable is unsigned, which means the lower limit is zero
> - reg <= JC42_REG_DEVICEID covers the upper limit
>
> Before I send a patch I'd like to hear if removal of "reg >=
> JC42_REG_CAP" makes sense to other people.
>
The bot keeps complaining about it. Yes, it is technically unnecessary,
but I left it in on purpose to indicate that JC42_REG_CAP is the first
register and that it wasn't forgotten. Any modern C compiler notices
that the check is unnecessary and drops it, so there is no runtime penalty.
This is one of those situations where I'd like to have a means to tell
the checker to please stop complaining.
Guenter
next prev parent reply other threads:[~2022-12-22 23:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 14:35 kernel test robot
2022-12-22 21:20 ` Martin Blumenstingl
2022-12-22 23:41 ` Guenter Roeck [this message]
2022-12-25 14:18 ` Martin Blumenstingl
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=20221222234148.GA2776378@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=oe-kbuild-all@lists.linux.dev \
/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®