lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221222234148.GA2776378@roeck-us.net>
Date:   Thu, 22 Dec 2022 15:41:48 -0800
From:   Guenter Roeck <linux@...ck-us.net>
To:     Martin Blumenstingl <martin.blumenstingl@...glemail.com>
Cc:     kernel test robot <lkp@...el.com>, oe-kbuild-all@...ts.linux.dev,
        linux-kernel@...r.kernel.org, linux-hwmon@...r.kernel.org
Subject: Re: drivers/hwmon/jc42.c:477 jc42_readable_reg() warn: always true
 condition '(reg >= 0) => (0-u32max >= 0)'

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@...el.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ