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

selftests/bpf: fix a compilation error

I hit the following compilation error with gcc 4.8.5.

prog_tests/flow_dissector.c: In function ‘test_flow_dissector’:
prog_tests/flow_dissector.c:155:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < ARRAY_SIZE(tests); i++) {
^
prog_tests/flow_dissector.c:155:2: note: use option -std=c99 or -std=gnu99 to compile your code

Let us fix the issue by avoiding this particular c99 feature.

Fixes: a5cb33464e53 ("selftests/bpf: make flow dissector tests more extensible")
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Yonghong Song and committed by
Alexei Starovoitov
ba02de1a 193d0002

+2 -2
+2 -2
tools/testing/selftests/bpf/prog_tests/flow_dissector.c
··· 143 143 void test_flow_dissector(void) 144 144 { 145 145 struct bpf_object *obj; 146 - int err, prog_fd; 146 + int i, err, prog_fd; 147 147 148 148 err = bpf_flow_load(&obj, "./bpf_flow.o", "flow_dissector", 149 149 "jmp_table", &prog_fd); ··· 152 152 return; 153 153 } 154 154 155 - for (int i = 0; i < ARRAY_SIZE(tests); i++) { 155 + for (i = 0; i < ARRAY_SIZE(tests); i++) { 156 156 struct bpf_flow_keys flow_keys; 157 157 struct bpf_prog_test_run_attr tattr = { 158 158 .prog_fd = prog_fd,