RE: [PATCH v2 1/8] minmax: Put all the clamp() definitions together

David Laight
2024-07-28T20:10:15Z

From: Linus Torvalds <torvalds@linuxfoundation.org>
> Sent: 28 July 2024 20:55
>
> On Sun, 28 Jul 2024 at 11:12, David Laight <David.Laight@aculab.com> wrote:
> >
> > Although min_t(type,x,y) should just be
> > type __x = x;
> > type __y = y;
> > __x < __y ? __x : __y;
> > Absolutely no point doing anything else.
>
> I tried it. Doesn't quite work:
>
> net/ipv4/proc.c: In function ‘snmp_seq_show_tcp_udp’:
> net/ipv4/proc.c:414:9: error: ISO C90 forbids variable length array
> ‘buff’ [-Werror=vla]
> 414 | unsigned long buff[TCPUDP_MIB_MAX];
> | ^~~~~~~~
...

Ah, the constants.
I think they just need to be MIN_CONST() (without the casts).
One might need a cast of one of its constants.
But maybe the signedness test can be ignored if there is a
test for it being a constant.

But (as you said earlier in the year) that should just be MIN().
Except there are a few places that is used that need changing first.

David

>
> I guess all of these could just be made to use MIN_T()/MAX_T instead.
> We're not talking hundreds of cases, it seems to be just a small
> handful.
>
> Let me go check.
>
> Linus

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)