diff mbox series

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

Message ID 20240527213641.299458-1-jhubbard@nvidia.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v2] selftests/net: suppress clang's "variable-sized type not at the end" warning | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 4 maintainers not CCed: justinstitt@google.com ndesaulniers@google.com morbo@google.com nathan@kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-29--00-00 (tests: 1039)

Commit Message

John Hubbard May 27, 2024, 9:36 p.m. UTC
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@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(+)


base-commit: 2bfcfd584ff5ccc8bb7acde19b42570414bf880b

Comments

Nathan Chancellor May 28, 2024, 8:39 p.m. UTC | #1
On Mon, May 27, 2024 at 02:36:41PM -0700, John Hubbard wrote:
> 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@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

For what it's worth, the main kernel has -Wno-gnu because there is
little point in warning about the use of GNU extensions when building
with '-std=gnu...'. It may be worth doing this anywhere that uses a GNU
standard in the selftests but I guess it depends on how noisy things
are.

> +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
> 
>
John Hubbard May 28, 2024, 8:56 p.m. UTC | #2
On 5/28/24 1:39 PM, Nathan Chancellor wrote:
> On Mon, May 27, 2024 at 02:36:41PM -0700, John Hubbard wrote:
...
>> 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
> 
> For what it's worth, the main kernel has -Wno-gnu because there is
> little point in warning about the use of GNU extensions when building
> with '-std=gnu...'. It may be worth doing this anywhere that uses a GNU
> standard in the selftests but I guess it depends on how noisy things
> are.

I think there might be one or two other cases like this that I haven't
gotten around to, so yes you are right, this probably should be moved
into lib.mk instead.

I'll do that in a v3.

> 
>> +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
>>
>>

thanks,
diff mbox series

Patch

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