tools/testing/selftests/net/Makefile adds -Wall to CFLAGS.

With clang supporting -Wunused-but-set-global, building kselftest
gets too noisy:

  bind_timewait.c:76:1: warning: variable '_bind_timewait_1_object' set but not 
used [-Wunused-but-set-global]
     76 | TEST_F(bind_timewait, 1)
        | ^
  ../kselftest_harness.h:398:2: note: expanded from macro 'TEST_F'
    398 |         __TEST_F_IMPL(fixture_name, test_name, -1, 
TEST_TIMEOUT_DEFAULT)
        |         ^
  ../kselftest_harness.h:470:33: note: expanded from macro '__TEST_F_IMPL'
    470 |         static struct __test_metadata 
*_##fixture_name##_##test_name##_object; \
        |                                        ^
  <scratch space>:155:1: note: expanded from here
    155 | _bind_timewait_1_object
        | ^

The global variable _##fixture_name##_##test_name##_object is not
used if a test does not use XFAIL_ADD().

Let's add __maybe_unused to it.

Link: 
https://github.com/llvm/llvm-project/commit/3e011457055bd3868bd05cf80bc1a4482777809b
Signed-off-by: Kuniyuki Iwashima <[email protected]>
---
 tools/testing/selftests/kselftest_harness.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kselftest_harness.h 
b/tools/testing/selftests/kselftest_harness.h
index cfdce9cd252e..a2e104f7fb52 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -467,7 +467,7 @@ static inline void __kselftest_memset_safe(void *s, int c, 
size_t n)
                                !__atomic_test_and_set(_metadata->no_teardown, 
__ATOMIC_RELAXED)) \
                        fixture_name##_teardown(_metadata, self, variant); \
        } \
-       static struct __test_metadata *_##fixture_name##_##test_name##_object; \
+       static struct __test_metadata *_##fixture_name##_##test_name##_object 
__maybe_unused; \
        static void __attribute__((constructor(KSELFTEST_PRIO_TEST))) \
                        _register_##fixture_name##_##test_name(void) \
        { \
-- 
2.54.0.823.g6e5bcc1fc9-goog


Reply via email to