diff mbox series

[bpf-next] selftests/bpf: fix a compilation error

Message ID 20190418052330.4180377-1-yhs@fb.com
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf-next] selftests/bpf: fix a compilation error | expand

Commit Message

Yonghong Song April 18, 2019, 5:23 a.m. UTC
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>
---
 tools/testing/selftests/bpf/prog_tests/flow_dissector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alexei Starovoitov April 18, 2019, 5:31 a.m. UTC | #1
On Wed, Apr 17, 2019 at 10:23 PM Yonghong Song <yhs@fb.com> wrote:
>
> 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>

Applied. Thanks
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
index 1a73937826b0..126319f9a97c 100644
--- a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
+++ b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
@@ -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);
@@ -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,