Re: [PATCH] linux/bits.h: fix -Wtype-limits warnings in GENMASK_INPUT_CHECK()

From: Andy Shevchenko
Date: Mon Mar 07 2022 - 06:12:27 EST


On Sun, Mar 6, 2022 at 7:35 AM Vincent MAILHOL
<mailhol.vincent@xxxxxxxxxx> wrote:
> On Sun. 6 Mar 2022 at 06:33, Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:
> > On Sat, Mar 5, 2022 at 2:43 PM Vincent MAILHOL
> > <mailhol.vincent@xxxxxxxxxx> wrote:
> > > On Tue. 5 Mar 2022 at 03:46, Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:
> > > > On Fri, Mar 4, 2022 at 7:36 PM Vincent Mailhol
> > > > <mailhol.vincent@xxxxxxxxxx> wrote:
> >
> > ...
> >
> > > > NAK.
> > >
> > > Are you willing to change your decision following my comments?
> >
> > Have you read this discussion (read the thread in full)
> > https://lore.kernel.org/lkml/cover.1590017578.git.syednwaris@xxxxxxxxx/
>
> Thank you, this was an instructive read.
>
> For what I understand, there was an effort to fix this when
> -Wtype-limits was still a W=1 warning but the effort was stopped
> after -Wtype-limits was moved to W=2 despite a v4 patch being very
> close to the goal.

My understanding of that discussion is that Wtype-limits is broken,
and Linus pointed out many times that compiler warning on

if ((unsigned int)foo < 0)

is bogus. I.o.w. there is no issue with the code and hence nothing to fix.

> Back to my patch, it successfully passes the lib/test_bits.c
> build test (including the TEST_GENMASK_FAILURES) and it also
> fixes the last open warning from the thread you pointed me to (on
> drivers/crypto/inside-secure/safexcel.o):
> https://lore.kernel.org/lkml/20200709123011.GA18734@xxxxxxxxxxxxxxxxxxx/
>
> So, I am still not sure to understand what issue you see with my
> patch. Is it that we should just not care about fixing W=2? Or
> do you still see some issues which are not being addressed (if
> so, sorry for not understanding)?

See above. You may Cc Linus himself to reignite the discussion.

> I do agree that fixing a W=2 has small value for all the files
> which are still emitting some W=1. However, I think it is
> beneficial to remove this W=2 spam for all the developers who
> produced W=1 clean files and would like to tackle the W=2
> warnings.

--
With Best Regards,
Andy Shevchenko