Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf test: Simplify for_each_test() to avoid tripping on -Werror=array-bounds

When cross building on debian to the mips 32-bit arch we get these
warnings:

In function '__cmd_test',
inlined from 'cmd_test' at tests/builtin-test.c:561:9:
tests/builtin-test.c:260:66: error: array subscript 1 is outside array bounds of 'struct test_suite *[1]' [-Werror=array-bounds]
260 | for (k = 0, t = tests[j][k]; tests[j][k]; k++, t = tests[j][k])
| ^
tests/builtin-test.c:369:9: note: in expansion of macro 'for_each_test'
369 | for_each_test(j, k, t) {
| ^~~~~~~~~~~~~
tests/builtin-test.c: In function 'cmd_test':
tests/builtin-test.c:36:27: note: at offset 4 into object 'arch_tests' of size 4
36 | struct test_suite *__weak arch_tests[] = {
| ^~~~~~~~~~
cc1: all warnings being treated as errors

Switch to using a while(!sentinel) for the second level of the 'tests'
array to avoid that compiler complaint.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+2 -2
+2 -2
tools/perf/tests/builtin-test.c
··· 256 256 } 257 257 258 258 #define for_each_test(j, k, t) \ 259 - for (j = 0; j < ARRAY_SIZE(tests); j++) \ 260 - for (k = 0, t = tests[j][k]; tests[j][k]; k++, t = tests[j][k]) 259 + for (j = 0, k = 0; j < ARRAY_SIZE(tests); j++, k = 0) \ 260 + while ((t = tests[j][k++]) != NULL) 261 261 262 262 static int test_and_print(struct test_suite *t, int subtest) 263 263 {