[PATCH v2] selftests/net: suppress clang's "variable-sized type not at the end" warning

John Hubbard jhubbard at nvidia.com
Mon May 27 14:36:41 PDT 2024


When building with clang, via:

    make LLVM=1 -C tools/testing/selftest

...clang warns that "a variable sized type not at the end of a struct or
class is a GNU extension".

These cases are not easily changed, because they involve structs that
are part of the API. Fortunately, however, the tests seem to be doing
just fine (specifically, neither affected test runs any differently with
gcc vs. clang builds, on my test system) regardless of the warning. So,
all the warning is doing is preventing a clean build of selftests/net.

Fix this by suppressing this particular clang warning for the
selftests/net suite.

Signed-off-by: John Hubbard <jhubbard at nvidia.com>
---

Changes since the first version:

1) Rebased onto Linux 6.10-rc1

thanks,
John Hubbard


 tools/testing/selftests/net/Makefile | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index bd01e4a0be2c..9a3b766c8781 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -6,6 +6,10 @@ CFLAGS += -I../../../../usr/include/ $(KHDR_INCLUDES)
 # Additional include paths needed by kselftest.h
 CFLAGS += -I../
 
+ifneq ($(LLVM),)
+    CFLAGS += -Wno-gnu-variable-sized-type-not-at-end
+endif
+
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh \
 	      rtnetlink.sh xfrm_policy.sh test_blackhole_dev.sh
 TEST_PROGS += fib_tests.sh fib-onlink-tests.sh pmtu.sh udpgso.sh ip_defrag.sh

base-commit: 2bfcfd584ff5ccc8bb7acde19b42570414bf880b
-- 
2.45.1




More information about the linux-arm-kernel mailing list