[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wiU=euKEQOzgdQqTAekJgHMMTtqMwdAw=mGkcGoR9ChEw@mail.gmail.com>
Date: Thu, 10 Aug 2023 12:46:58 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: David Laight <David.Laight@...lab.com>
Cc: "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 v3 5/5] minmax: Relax check to allow comparison between
int and small unsigned constants.
On Thu, 10 Aug 2023 at 01:29, David Laight <David.Laight@...lab.com> wrote:
>
> > Does that expression mean "give me a number 0..20" or "MININT..20"?
>
> Why does the lower bound of any type matter?
Because it might actually be the upper bound.
That MININT becomes be 20 if it's unsigned, and you do min() on it.
Bugs when mixing unsigned and signed comparisons is WHY WE HAVE THE
TYPE CHECK IN THE FIRST PLACE.
And no, constants don't necessarily make that any different.
I think we all agree that using a (signed) constant 20 makes perfect
sense when the other side is an unsigned entity. It may be "signed",
but when the value is positive, we don't care.
But using an *unsigned* constant 20 when the other side is signed
means that now somebody is confused. We should warn.
Your argum,ent that "a constant is a constant" is bogus garbage.
I'm not going to keep telling you this. I'm telling you now, and if
you don't get it, it's no longer my problem. I'm just telling you that
your patch won't be accepted, and no amount of whining will make it
so.
Linus
Powered by blists - more mailing lists