Re: [PATCH v2 1/8] minmax: Put all the clamp() definitions together
From: Linus Torvalds
Date: Sun Jul 28 2024 - 15:55:35 EST
On Sun, 28 Jul 2024 at 11:12, David Laight <David.Laight@xxxxxxxxxx> 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];
| ^~~~~~~~
(and same issue repeated twice for IPv6).
Similar case here:
drivers/gpu/drm/drm_color_mgmt.c: In function
‘drm_plane_create_color_properties’:
drivers/gpu/drm/drm_color_mgmt.c:535:16: error: ISO C90 forbids
variable length array ‘enum_list’ [-Werror=vla]
535 | struct drm_prop_enum_list enum_list[max_t(int,
DRM_COLOR_ENCODING_MAX,
| ^~~~~~~~~~~~~~~~~~
and
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: In function
‘stmmac_dma_interrupt’:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2915:9: error: ISO
C90 forbids variable length array ‘status’ [-Werror=vla]
2915 | int status[max_t(u32, MTL_MAX_TX_QUEUES, MTL_MAX_RX_QUEUES)];
| ^~~
and several cases in drivers/md/dm-integrity.c.
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