Thread (4 messages) 4 messages, 2 authors, 2025-11-11

Re: [PATCH] selftest: net: fix variable sized type not at the end of struct warnings

From: Simon Horman <horms@kernel.org>
Date: 2025-10-28 17:23:18
Also in: linux-kernel-mentees, linux-kselftest, lkml

On Mon, Oct 27, 2025 at 10:38:56AM +0530, Ankit Khushwaha wrote:
Some network selftests defined variable-sized types defined at the end of
struct causing -Wgnu-variable-sized-type-not-at-end warning.

warning:
timestamping.c:285:18: warning: field 'cm' with variable sized type 
'struct cmsghdr' not at the end of a struct or class is a GNU 
extension [-Wgnu-variable-sized-type-not-at-end]
  285 |                 struct cmsghdr cm;
      |                                ^

ipsec.c:835:5: warning: field 'u' with variable sized type 'union 
(unnamed union at ipsec.c:831:3)' not at the end of a struct or class 
is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
  835 |                 } u;
      |                   ^

This patch move these field at the end of struct to fix these warnings.

Signed-off-by: Ankit Khushwaha <redacted>
Hi Ankit,

I don't believe this change is correct.

I think that the intention of the code is the char arrays (buf and control)
provide the buffer space for the variable-length trailing field
of the preceding structure. Where we basically have a header followed
by data. But your patch would place the before the header.

-- 
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help