[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wh1SFzTM1nWwC30t55jzZradQmJ4942CDD1pM_umhU_Vw@mail.gmail.com>
Date: Wed, 23 Aug 2023 08:32:05 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: David Laight <David.Laight@...lab.com>
Cc: Kees Cook <keescook@...omium.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>,
Christoph Hellwig <hch@...radead.org>,
"Jason A. Donenfeld" <Jason@...c4.com>
Subject: Re: [PATCH next v3 0/5] minmax: Relax type checks in min() and max().
On Wed, 23 Aug 2023 at 01:52, David Laight <David.Laight@...lab.com> wrote:
>
> Linus doesn't like me silently converting unsigned constants
> to signed.
Note that my dislike is more about changing the sign of the
*comparison*, and not warning about it.
It's not the constant conversion itself that ends up being the
problem, but the downstream issues it causes.
Having grepped for those annoying "min_t(size_t..)" uses, lots of them
seem to have perfectly fine signedness, and the 'size_t' is literally
just due to different sizes of unsigned values. In fact, several of
them seem to be due to the unfortunate fact that 'size_t' can be
'unsigned int' on 32-bit architectures, so mixing 'size_t' and
'unsigned long' will sadly warn without it.
So we literally have the issue that 'min(a,b)' will warn even if 'a'
and 'b' have the same signedness *and* the same size, because 'size_t'
and 'unsigned long' are different types.
Your patch 2/5 will fix that. And then I'd certainly be ok with a
"comparing an unsigned value to a signed positive constant" thing
(just not the other way around: "comparing a signed value to an
unsigned positive constant" is wrong)
That might get rid of a number of the more annoying cases.
Linus
Powered by blists - more mailing lists