[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251020125642.35c59292@pumpkin>
Date: Mon, 20 Oct 2025 12:56:42 +0100
From: David Laight <david.laight.linux@...il.com>
To: Théo Lebrun <theo.lebrun@...tlin.com>
Cc: "Andrew Lunn" <andrew+netdev@...n.ch>, "David S. Miller"
<davem@...emloft.net>, "Eric Dumazet" <edumazet@...gle.com>, "Jakub
Kicinski" <kuba@...nel.org>, "Paolo Abeni" <pabeni@...hat.com>, "Rob
Herring" <robh@...nel.org>, "Krzysztof Kozlowski" <krzk+dt@...nel.org>,
"Conor Dooley" <conor+dt@...nel.org>, "Nicolas Ferre"
<nicolas.ferre@...rochip.com>, "Claudiu Beznea" <claudiu.beznea@...on.dev>,
"Richard Cochran" <richardcochran@...il.com>, "Russell King"
<linux@...linux.org.uk>, <netdev@...r.kernel.org>,
<devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>, "Vladimir
Kondratiev" <vladimir.kondratiev@...ileye.com>, "Tawfik Bayouk"
<tawfik.bayouk@...ileye.com>, "Thomas Petazzoni"
<thomas.petazzoni@...tlin.com>, Grégory Clement
<gregory.clement@...tlin.com>, Benoît Monin
<benoit.monin@...tlin.com>, "Maxime Chevallier"
<maxime.chevallier@...tlin.com>
Subject: Re: [PATCH net-next 11/15] net: macb: replace min() with umin()
calls
On Mon, 20 Oct 2025 13:44:43 +0200
Théo Lebrun <theo.lebrun@...tlin.com> wrote:
> On Sun Oct 19, 2025 at 4:10 PM CEST, David Laight wrote:
> > On Tue, 14 Oct 2025 17:25:12 +0200
> > Théo Lebrun <theo.lebrun@...tlin.com> wrote:
> >
> >> Whenever min(a, b) is used with a and b unsigned variables or literals,
> >> `make W=2` complains. Change four min() calls into umin().
> >
> > It will, and you'll get the same 'error' all over the place.
> > Basically -Wtype-limits is broken.
> >
> > Don't remove valid checks because it bleats.
>
> In theory I agree. In practice, this patch leads to a more readable
> `make W=2 drivers/net/ethernet/cadence/` stderr output, by removing a
> few false positives, and that's my only desire (not quite).
>
> I am not sure what you mean by "Don't remove valid checks"; could you
> clarify? My understanding is that the warning checks are about the
> signedness of unsigned integers. Are you implying that we lose
> something (safety?) when switching from min(a, b) to umin(a, b) with
> a/b both unsigned ints?
The issue is that -Wtype-limits warns for every case where min() is
used with two unsigned values.
It is pretty much impossible to code around it as well.
It also warns for other #defines that are trying to check for invalid
constant values.
The checks are there to pick up invalid calls, using umin() (and worse
min_t()) to avoid the warnings is making the checks pointless.
So you may know the code is ok, but the compile-time checks are there
to ensure it is ok.
David
> [0]: https://lore.kernel.org/lkml/176066582948.1978978.752807229943547484.git-patchwork-notify@kernel.org/
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=f26c6438a285
>
> --
> Théo Lebrun, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
Powered by blists - more mailing lists