diff mbox series

kselftest/kselftest_harness.h: do not redefine ARRAY_SIZE

Message ID 20210625224902.1222942-1-posk@google.com (mailing list archive)
State New
Headers show
Series kselftest/kselftest_harness.h: do not redefine ARRAY_SIZE | expand

Commit Message

Peter Oskolkov June 25, 2021, 10:49 p.m. UTC
Macro ARRAY_SIZE is defined in tools/include/linux/kernel.h, so
if both headers are included there is a warning.

Signed-off-by: Peter Oskolkov <posk@google.com>
---
 tools/testing/selftests/kselftest_harness.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Shuah Khan June 30, 2021, 10:38 p.m. UTC | #1
On 6/25/21 4:49 PM, Peter Oskolkov wrote:
> Macro ARRAY_SIZE is defined in tools/include/linux/kernel.h, so
> if both headers are included there is a warning.
> 
> Signed-off-by: Peter Oskolkov <posk@google.com>
> ---
>   tools/testing/selftests/kselftest_harness.h | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index ae0f0f33b2a6..75164e23f036 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -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
diff mbox series

Patch

diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index ae0f0f33b2a6..75164e23f036 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -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.