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] [day] [month] [year] [list]
Date:   Thu, 7 May 2020 12:29:33 -0700
From:   Dmitry Torokhov <dmitry.torokhov@...il.com>
To:     ChenTao <chentao107@...wei.com>
Cc:     kstewart@...uxfoundation.org, tglx@...utronix.de,
        gregkh@...uxfoundation.org, allison@...utok.net,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] input/misc/drv260x: Remove a useless comparison

Hi,

On Thu, May 07, 2020 at 01:16:17PM +0800, ChenTao wrote:
> Fix the following warning:
> 
> 'mode' and 'library' are u32, they are never be negative,
> DRV260X_LRA_MODE and DRV260X_LIB_EMPTY are 0x00, the comparison
> is always false.


The fact that the symbolic names resolve to 0 is just a happenstance. We
should not be writing code based on concrete values in this case. I
wish we could tell the compiler to ignore this kind of cases, where we
want to test a range of values, and do not care about concrete numeric
bounds of said range.

> 
> drivers/input/misc/drv260x.c:478:20: warning:
> comparison of unsigned expression < 0 is always false [-Wtype-limits]
>   if (haptics->mode < DRV260X_LRA_MODE ||
> drivers/input/misc/drv260x.c:490:23: warning:
> comparison of unsigned expression < 0 is always false [-Wtype-limits]
>   if (haptics->library < DRV260X_LIB_EMPTY ||

Are we planning on enabling this warning in kernel by default?

Thanks.

-- 
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ