selftests/harness: Update named initializer syntax
Subsystems (2)
PATCH 1/1 selftests/harness: Update named initializer syntax
The harness was still using old-style GNU named initializer syntax. Fix this so Clang will stop warning:
seccomp_bpf.c:2924:1: warning: use of GNU old-style field designator extension
[-Wgnu-designator]./../kselftest_harness.h:147:25: note: expanded from macro 'TEST'
^
./../kselftest_harness.h:172:5: note: expanded from macro '__TEST_IMPL'
fn: &test_name, termsig: _signal }; \
^--- tools/testing/selftests/kselftest_harness.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/kselftest_harness.h +5 -5
@@ -168,8 +168,8 @@#define __TEST_IMPL (test_name, _signal) \ static void test_name(struct __test_metadata *_metadata); \ static struct __test_metadata _##test_name##_object = \ - { name: "global." #test_name, \ - fn: &test_name, termsig: _signal }; \ + { .name = "global." #test_name, \ + .fn = &test_name, .termsig = _signal }; \ static void __attribute__((constructor)) _register_##test_name(void) \ { \ __register_test(&_##test_name##_object); \
@@ -304,9 +304,9 @@ } \ static struct __test_metadata \ _##fixture_name##_##test_name##_object = { \ - name: #fixture_name "." #test_name, \ - fn: &wrapper_##fixture_name##_##test_name, \ - termsig: signal, \ + .name = #fixture_name "." #test_name, \ + .fn = &wrapper_##fixture_name##_##test_name, \ + .termsig = signal, \ }; \ static void __attribute__((constructor)) \ _register_##fixture_name##_##test_name(void) \
Signature · 5 lines
2.17.1 -- Kees Cook
Quoted 33 lines · Kees Cook
The harness was still using old-style GNU named initializer syntax. Fix this so Clang will stop warning:
seccomp_bpf.c:2924:1: warning: use of GNU old-style field designator extension
[-Wgnu-designator]./../kselftest_harness.h:147:25: note: expanded from macro 'TEST'^ ./../kselftest_harness.h:172:5: note: expanded from macro '__TEST_IMPL' fn: &test_name, termsig: _signal }; \ ^Signed-off-by Kees Cook <keescook at chromium.org>--- tools/testing/selftests/kselftest_harness.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)tools/testing/selftests/kselftest_harness.h +2
-2@@ -168,8 +168,8 @@#define __TEST_IMPL (test_name, _signal) \ static void test_name(struct __test_metadata *_metadata); \ static struct __test_metadata _##test_name##_object = \ - { name: "global." #test_name, \ - fn: &test_name, termsig: _signal }; \ + { .name = "global." #test_name, \ + .fn = &test_name, .termsig = _signal }; \ static void __attribute__((constructor)) _register_##test_name(void) \ { \ __register_test(&_##test_name##_object); \
tools/testing/selftests/kselftest_harness.h line 309
Quoted 9 lines
tools/testing/selftests/kselftest_harness.h +3
-3@@ -304,9 +304,9 @@ } \ static struct __test_metadata \ _##fixture_name##_##test_name##_object = { \ - name: #fixture_name "." #test_name, \ - fn: &wrapper_##fixture_name##_##test_name, \ - termsig: signal, \ + .name = #fixture_name "." #test_name, \ + .fn = &wrapper_##fixture_name##_##test_name, \ + .termsig = signal, \
My favorite feature of C, stolen now in C++20. Thanks for cleaning this up.
Reviewed-by: Nick Desaulniers <ndesaulniers at google.com>
Quoted 9 lines
tools/testing/selftests/kselftest_harness.h +0
-1}; \ static void __attribute__((constructor)) \ _register_##fixture_name##_##test_name(void) \ --2.17.1
--
Kees Cook
Signature · 2 lines
Thanks, ~Nick Desaulniers