Skip to content

Commit

Permalink
selftests/bpf: fix a compilation error
Browse files Browse the repository at this point in the history
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: a5cb334 ("selftests/bpf: make flow dissector tests more extensible")
Signed-off-by: Yonghong Song <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
yonghong-song authored and Alexei Starovoitov committed Apr 18, 2019
1 parent 193d000 commit ba02de1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/flow_dissector.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ struct test tests[] = {
void test_flow_dissector(void)
{
struct bpf_object *obj;
int err, prog_fd;
int i, err, prog_fd;

err = bpf_flow_load(&obj, "./bpf_flow.o", "flow_dissector",
"jmp_table", &prog_fd);
Expand All @@ -152,7 +152,7 @@ void test_flow_dissector(void)
return;
}

for (int i = 0; i < ARRAY_SIZE(tests); i++) {
for (i = 0; i < ARRAY_SIZE(tests); i++) {
struct bpf_flow_keys flow_keys;
struct bpf_prog_test_run_attr tattr = {
.prog_fd = prog_fd,
Expand Down

0 comments on commit ba02de1

Please sign in to comment.