Re: [PATCH 0/2] kbuild: remove gcc's -Wtype-limits
From: Dan Carpenter
Date: Fri Dec 19 2025 - 02:08:21 EST
On Thu, Dec 18, 2025 at 10:06:51PM +0000, David Laight wrote:
> On Fri, 19 Dec 2025 08:34:05 +1200
> Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > On Fri, 19 Dec 2025 at 08:26, David Laight <david.laight.linux@xxxxxxxxx> wrote:
> > >
> > > One possibility is to conditionally add _Pragma()
> >
> > No. That compiler warning is pure and utter garbage. I have pointed it
> > out fopr *years*, and compiler people don't get it.
> >
> > So that warning just needs to die. It's shit. It's wrong.
>
> True - especially for code like:
> if (x < 0 || x > limit)
> return ...
> where the code is correct even with 'accidental' conversion of a
> negative signed value to a large unsigned one.
>
> clang seems to have a dozen similar warnings, all of which are a PITA
> for kernel code - like rejecting !(4 << 16).
In this example is 4 a literal or do we at least know that 4 is
non-zero?
I really thought I had a check for that in Smatch but I guess I
don't...
regards,
dan carpenter