]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ipv4/inet_sock.h: Avoid thousands of -Wflex-array-member-not-at-end warnings
authorGustavo A. R. Silva <gustavoars@kernel.org>
Mon, 5 Jan 2026 06:45:25 +0000 (15:45 +0900)
committerJakub Kicinski <kuba@kernel.org>
Wed, 7 Jan 2026 01:02:52 +0000 (17:02 -0800)
commitc86af46b9c7af2041495231fd59834da6da1543c
tree848af30b821a30bf79a0bc82b410a7be63a8eba9
parent915a5f60ad947e8dd515d2cc77a96a14dffb3f15
ipv4/inet_sock.h: Avoid thousands of -Wflex-array-member-not-at-end warnings

Use DEFINE_RAW_FLEX() to avoid thousands of -Wflex-array-member-not-at-end
warnings.

Remove struct ip_options_data, and adjust the rest of the code so that
flexible-array member struct ip_options_rcu::opt.__data[] ends last
in struct icmp_bxm.

Compensate for this by using the DEFINE_RAW_FLEX() helper to define each
on-stack struct instance that contained struct ip_options_data as a member,
and to define struct ip_options_rcu with a fixed on-stack size for its
nested flexible-array member opt.__data[].

Also, add a couple of code comments to prevent people from adding members
to a struct after another member that contains a flexible array.

With these changes, fix 2600 warnings of the following type:

include/net/inet_sock.h:65:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://patch.msgid.link/aVteBadWA6AbTp7X@kspp
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/inet_sock.h
net/ipv4/icmp.c
net/ipv4/ip_output.c
net/ipv4/ping.c
net/ipv4/raw.c
net/ipv4/udp.c