Subject: Re: [PATCH net-next 11/15] net: macb: replace min() with umin() calls

From: David Laight <[email-masked]>
Date: Mon, 20 Oct 2025 12:56:42 +0100

On Mon, 20 Oct 2025 13:44:43 +0200
Théo Lebrun <[email-masked]> 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 <[email-masked]> 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/[email-masked]/
> [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
>