libbpf: fix non-C89 loop variable declaration in gen_loader.c
Andrii Nakryiko
maintainerPATCH 1/1 libbpf: fix non-C89 loop variable declaration in gen_loader.c
Fix the int i declaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build.
[0] https://github.com/libbpf/libbpf/issues/403
--- tools/lib/bpf/gen_loader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/lib/bpf/gen_loader.c +2 -1
@@ -584,8 +584,9 @@ void bpf_gen__record_extern(struct bpf_gen *gen, const char *name, bool is_weak,static struct ksym_desc *get_ksym_desc (struct bpf_gen *gen,struct ksym_relo_desc *relo) {struct ksym_desc *kdesc; +int i; -for (int i =0 ; i < gen->nr_ksyms; i++) { +for (i =0 ; i < gen->nr_ksyms; i++) {if (!strcmp (gen->ksyms[i].name, relo->name)) { gen->ksyms[i].ref++;return &gen->ksyms[i];
Signature · 1 line
2.30.2
Quoted 7 lines · Andrii Nakryiko
Fix the
int ideclaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build.[0] https://github.com/libbpf/libbpf/issues/403
Fixes 18f4fccbf314 ("libbpf: Update gen_loader to emit BTF_KIND_FUNC relocations")Signed-off-by Andrii Nakryiko <[email protected]>
Thanks for the fix, and sorry about that.
Quoted 1 line
[...]
--
Kartikeya
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 3 lines · Andrii Nakryiko
Fix the
int ideclaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build.
Quoted 9 lines
Quoted 4 lines
[0] https://github.com/libbpf/libbpf/issues/403
Fixes 18f4fccbf314 ("libbpf: Update gen_loader to emit BTF_KIND_FUNC relocations")Signed-off-by Andrii Nakryiko <[email protected]>Thanks for the fix, and sorry about that.
No worries, we just need to figure out which compiler flags we need to catch this. I'm surprised BCC build caught this and neither libbpf's Makefile nor selftest did. Selftests are definitely too permissive w.r.t. stuff like this.
If you could take a look and see what we'll need to lock it down a bit, that would be great. I've also requested help from the original reporter of this issue (see issue on Github).
Quoted 4 lines
Quoted 1 line
[...]
--
Kartikeya
Kumar Kartikeya Dwivedi
maintainerQuoted 16 lines · Andrii Nakryiko
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 3 lines · Andrii Nakryiko
Fix the
int ideclaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build.Quoted 9 lines
Quoted 4 lines
[0] https://github.com/libbpf/libbpf/issues/403
Fixes 18f4fccbf314 ("libbpf: Update gen_loader to emit BTF_KIND_FUNC relocations")Signed-off-by Andrii Nakryiko <[email protected]>Thanks for the fix, and sorry about that.
Quoted 9 lines
No worries, we just need to figure out which compiler flags we need to catch this. I'm surprised BCC build caught this and neither libbpf's
Makefilenor selftest did. Selftests are definitely too permissive w.r.t. stuff like this.If you could take a look and see what we'll need to lock it down a bit, that would be great. I've also requested help from the original reporter of this issue (see issue on Github).
I think you want -std=gnu89 (i.e. C89 with GNU extensions). I get the same error as the reporter when building with that.
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
[...]
--
Kartikeya
--
Kartikeya
Quoted 23 lines · Kumar Kartikeya Dwivedi
Quoted 21 lines · Andrii Nakryiko
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 3 lines · Andrii Nakryiko
Fix the
int ideclaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build.Quoted 9 lines
Quoted 4 lines
[0] https://github.com/libbpf/libbpf/issues/403
Fixes 18f4fccbf314 ("libbpf: Update gen_loader to emit BTF_KIND_FUNC relocations")Signed-off-by Andrii Nakryiko <[email protected]>Thanks for the fix, and sorry about that.
No worries, we just need to figure out which compiler flags we need to catch this. I'm surprised BCC build caught this and neither libbpf's
Makefilenor selftest did. Selftests are definitely too permissive w.r.t. stuff like this.
Quoted 7 lines
Quoted 4 lines
If you could take a look and see what we'll need to lock it down a bit, that would be great. I've also requested help from the original reporter of this issue (see issue on Github).
I think you want -std=gnu89 (i.e. C89 with GNU extensions). I get the same error as the reporter when building with that.
Oh, I think I tried -std=c89 and it didn't compile due to use of those extensions. Didn't realize gnu89 exists. Do you mind adding it to bpftool, libbpf, and selftests Makefiles and sending a patch?
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
[...]
--
Kartikeya--
Kartikeya
Kumar Kartikeya Dwivedi
maintainerQuoted 29 lines · Andrii Nakryiko
Quoted 28 lines · Kumar Kartikeya Dwivedi
Quoted 25 lines · Andrii Nakryiko
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 3 lines · Andrii Nakryiko
Fix the
int ideclaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build.Quoted 9 lines
Quoted 4 lines
[0] https://github.com/libbpf/libbpf/issues/403
Fixes 18f4fccbf314 ("libbpf: Update gen_loader to emit BTF_KIND_FUNC relocations")Signed-off-by Andrii Nakryiko <[email protected]>Thanks for the fix, and sorry about that.
No worries, we just need to figure out which compiler flags we need to catch this. I'm surprised BCC build caught this and neither libbpf's
Makefilenor selftest did. Selftests are definitely too permissive w.r.t. stuff like this.If you could take a look and see what we'll need to lock it down a bit, that would be great. I've also requested help from the original reporter of this issue (see issue on Github).
Quoted 7 lines
Quoted 2 lines
I think you want -std=gnu89 (i.e. C89 with GNU extensions). I get the same error as the reporter when building with that.
Oh, I think I tried -std=c89 and it didn't compile due to use of those extensions. Didn't realize gnu89 exists. Do you mind adding it to bpftool, libbpf, and selftests Makefiles and sending a patch?
Sure, will do!
--
Kartikeya
Quoted 5 lines · Andrii Nakryiko
Fix the
int ideclaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build.
I'd prefer to fix bcc and/or its derivatives instead. It's year 2021.
Quoted 10 lines · Alexei Starovoitov
Quoted 5 lines · Andrii Nakryiko
Fix the
int ideclaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build.I'd prefer to fix bcc and/or its derivatives instead. It's year 2021.
Fixing BCC and derivatives is a separate topic. This is the only instance of non-C89 compliant for() loop in libbpf and I'd prefer to fix it at the very least for style consistency.
Quoted 9 lines · Andrii Nakryiko
Quoted 6 lines · Alexei Starovoitov
Quoted 4 lines · Andrii Nakryiko
Fix the
int ideclaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
I'd prefer to fix bcc and/or its derivatives instead. It's year 2021.
Fixing BCC and derivatives is a separate topic. This is the only instance of non-C89 compliant
for()loop in libbpf and I'd prefer to fix it at the very least for style consistency.
Fair enough. Applied.