summaryrefslogtreecommitdiff
path: root/tools/perf/tests/builtin-test.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-04-14 11:26:42 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-14 21:43:39 -0300
commit17354d1528f902b3a4f66023cd24012e7999c4dc (patch)
tree0d0fcc29cb2b2f4ca3ae18cba58123fa7653a772 /tools/perf/tests/builtin-test.c
parentc160118a90d4acf335993d8d59b02ae2147a524e (diff)
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>
Diffstat (limited to 'tools/perf/tests/builtin-test.c')
-rw-r--r--tools/perf/tests/builtin-test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 35cc3807cc9e..b89d69afcef0 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -256,8 +256,8 @@ static int run_test(struct test_suite *test, int subtest)
}
#define for_each_test(j, k, t) \
- for (j = 0; j < ARRAY_SIZE(tests); j++) \
- for (k = 0, t = tests[j][k]; tests[j][k]; k++, t = tests[j][k])
+ for (j = 0, k = 0; j < ARRAY_SIZE(tests); j++, k = 0) \
+ while ((t = tests[j][k++]) != NULL)
static int test_and_print(struct test_suite *t, int subtest)
{