From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: ChenTao <chentao107@huawei.com>
Cc: kstewart@linuxfoundation.org, tglx@linutronix.de,
gregkh@linuxfoundation.org, allison@lohutok.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] input/misc/drv260x: Remove a useless comparison
Date: Thu, 7 May 2020 12:29:33 -0700 [thread overview]
Message-ID: <20200507192933.GK89269@dtor-ws> (raw)
In-Reply-To: <20200507051617.212434-1-chentao107@huawei.com>
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
prev parent reply other threads:[~2020-05-07 19:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-07 5:16 [PATCH] input/misc/drv260x: Remove a useless comparison ChenTao
2020-05-07 19:29 ` Dmitry Torokhov [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=20200507192933.GK89269@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=allison@lohutok.net \
--cc=chentao107@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=kstewart@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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