tools/include/linux/kernel.h and kselftest_harness.h are missing ifndef guard around ARRAY_SIZE define. Fix them to avoid duplicate define errors during compile when another file defines it. This problem was found when compiling selftests that include a header with ARRAY_SIZE define. ARRAY_SIZE is defined in several selftests. There are about 25+ duplicate defines in various selftests source and header files. Add ARRAY_SIZE to kselftest.h in preparation for removing duplicate ARRAY_SIZE defines from individual test files.
Unified · Split
| @@ -92,7 +92,9 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); · 91 unmodified lines | |||
| 92 | int scnprintf(char * buf, size_t size, const char * fmt, ...); | 92 | int scnprintf(char * buf, size_t size, const char * fmt, ...); |
| 93 | int scnprintf_pad(char * buf, size_t size, const char * fmt, ...); | 93 | int scnprintf_pad(char * buf, size_t size, const char * fmt, ...); |
| 94 | 94 | ||
| 95 | #ifndef ARRAY_SIZE | ||
| 95 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) | 96 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) |
| 97 | #endif | ||
| 96 | 98 | ||
| 97 | #define current_gfp_context(k) 0 | 99 | #define current_gfp_context(k) 0 |
| 98 | #define synchronize_rcu() | 100 | #define synchronize_rcu() |
| @@ -48,6 +48,10 @@ · 47 unmodified lines | |||
| 48 | #include <stdarg.h> | 48 | #include <stdarg.h> |
| 49 | #include <stdio.h> | 49 | #include <stdio.h> |
| 50 | 50 | ||
| 51 | #ifndef ARRAY_SIZE | ||
| 52 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) | ||
| 53 | #endif | ||
| 54 | |||
| 51 | /* define kselftest exit codes */ | 55 | /* define kselftest exit codes */ |
| 52 | #define KSFT_PASS 0 | 56 | #define KSFT_PASS 0 |
| 53 | #define KSFT_FAIL 1 | 57 | #define KSFT_FAIL 1 |
| @@ -671,7 +671,9 @@ · 670 unmodified lines | |||
| 671 | #define EXPECT_STRNE(expected, seen) \ | 671 | #define EXPECT_STRNE(expected, seen) \ |
| 672 | __EXPECT_STR(expected, seen, !=, 0) | 672 | __EXPECT_STR(expected, seen, !=, 0) |
| 673 | 673 | ||
| 674 | #ifndef ARRAY_SIZE | ||
| 674 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) | 675 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 676 | #endif | ||
| 675 | 677 | ||
| 676 | /* Support an optional handler after and ASSERT_* or EXPECT_*. The approach is | 678 | /* Support an optional handler after and ASSERT_* or EXPECT_*. The approach is |
| 677 | * not thread-safe, but it should be fine in most sane test scenarios. | 679 | * not thread-safe, but it should be fine in most sane test scenarios. |