[PATCH 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores

From: John Hubbard
Date: Tue May 28 2024 - 22:09:15 EST


gcc defaults to silence (off) for the following warnings, but clang
defaults to the opposite. These warnings are not useful for kselftests,
so silence them for the clang builds as well:

-Wno-address-of-packed-member
-Wno-gnu-variable-sized-type-not-at-end

This eliminates warnings for the net/ and user_events/ kselftest
subsystems, in these files:

./net/af_unix/scm_rights.c
./net/timestamping.c
./net/ipsec.c
./user_events/perf_test.c

Cc: Nathan Chancellor <nathan@xxxxxxxxxx>
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
---
tools/testing/selftests/lib.mk | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 2902787b89b2..41e879f3f8a2 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -50,6 +50,12 @@ else
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
endif # CROSS_COMPILE

+# gcc defaults to silence (off) for the following warnings, but clang defaults
+# to the opposite. These warnings are not useful for kselftests, so silence them
+# for the clang builds as well.
+CFLAGS += -Wno-address-of-packed-member
+CFLAGS += -Wno-gnu-variable-sized-type-not-at-end
+
CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
else
CC := $(CROSS_COMPILE)gcc
--
2.45.1