Skip to contentSkip to conversation

kselftest/kselftest_harness.h: do not redefine ARRAY_SIZE

PATCH In review Peter Oskolkov 2 participants 2 messages Jun 25, 2021 – Jun 30, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kselftest/kselftest_harness.h: do not redefine ARRAY_SIZE

Macro ARRAY_SIZE is defined in tools/include/linux/kernel.h, so if both headers are included there is a warning.

---
 tools/testing/selftests/kselftest_harness.h | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/kselftest_harness.h +2 -0
index ae0f0f33b2a6..75164e23f036 100644
@@ -671,7 +671,9 @@
 #define EXPECT_STRNE(expected, seen) \
 	__EXPECT_STR(expected, seen, !=, 0)
 
+#ifndef ARRAY_SIZE
 #define ARRAY_SIZE(a)	(sizeof(a) / sizeof(a[0]))
+#endif
 
 /* Support an optional handler after and ASSERT_* or EXPECT_*.  The approach is
  * not thread-safe, but it should be fine in most sane test scenarios.
Signature · 1 line
2.32.0.93.g670b81a890-goog
maintainer
#1 lore raw
Quoted 14 lines · Peter Oskolkov

Macro ARRAY_SIZE is defined in tools/include/linux/kernel.h, so if both headers are included there is a warning.

---
  tools/testing/selftests/kselftest_harness.h | 2 ++
  1 file changed, 2 insertions(+)
tools/testing/selftests/kselftest_harness.h +0 -0
index ae0f0f33b2a6..75164e23f036 100644

tools/testing/selftests/kselftest_harness.h line 679

Quoted 9 lines
tools/testing/selftests/kselftest_harness.h +2 -0
@@ -671,7 +671,9 @@
  #define EXPECT_STRNE(expected, seen) \
  	__EXPECT_STR(expected, seen, !=, 0)
 
+#ifndef ARRAY_SIZE
  #define ARRAY_SIZE(a)	(sizeof(a) / sizeof(a[0]))
+#endif
 
  /* Support an optional handler after and ASSERT_* or EXPECT_*.  The approach is
   * not thread-safe, but it should be fine in most sane test scenarios.

Thank you for the patch. This will be queued for rc2 after the merge window closes.

thanks,
-- Shuah