Re: [PATCH 4/5][next] uapi: net: arp: Avoid -Wflex-array-member-not-at-end warnings
From: Andrew Lunn
Date: Wed Oct 16 2024 - 08:30:26 EST
On Tue, Oct 15, 2024 at 06:32:43PM -0600, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
>
> Address the following warnings by changing the type of the middle struct
> members in a couple of composite structs, which are currently causing
> trouble, from `struct sockaddr` to `struct sockaddr_legacy`. Note that
> the latter struct doesn't contain a flexible-array member.
>
> include/uapi/linux/if_arp.h:118:25: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> include/uapi/linux/if_arp.h:119:25: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> include/uapi/linux/if_arp.h:121:25: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> include/uapi/linux/if_arp.h:126:25: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> include/uapi/linux/if_arp.h:127:25: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>
> Also, update some related code, accordingly.
>
> No binary differences are present after these changes.
These are clearly UAPI files. It would be good to state in the commit
message why this is a safe change, at the source level.
Could user space code expect the type struct sockaddr and we are going
to get warnings when struct sockaddr_legacy is found? Have you tried
compiling an old arp binary, one that uses the IOCTL? The netfilter
code also references it:
http://charette.no-ip.com:81/programming/doxygen/netfilter/structarpreq.html
You also need to submit a patch to the man page:
https://man7.org/linux/man-pages/man7/arp.7.html
You might also want to build some Rust code:
https://docs.diesel.rs/master/libc/struct.arpreq.html
I've no idea what Rust does when a C structure has a type change.
Andrew