libbpf: Fix uninitialized warning in btf_dump_dump_type_data
PATCH 1/1 libbpf: Fix uninitialized warning in btf_dump_dump_type_data
GCC 11.3.0 fails to compile btf_dump.c due to the following error, which seems to originate in btf_dump_struct_data where the returned value would be uninitialized if btf_vlen returns zero.
btf_dump.c: In function ‘btf_dump_dump_type_data’:
btf_dump.c:2363:12: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2363 | if (err < 0)
| ^
---
Hi,
I encountered this build failure when using Gentoo's hardened profile to build sys-kernel/gentoo-kernel (at least some 5.19 and 6.0 versions). The following patch fixes it. Can this be applied?
Thanks.
David
tools/lib/bpf/btf_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/btf_dump.c +1 -1
@@ -1989,7 +1989,7 @@ static int btf_dump_struct_data(struct btf_dump *d, {const struct btf_member *m =btf_members (t);__u16 n =btf_vlen (t); -int i, err; +int i, err =0 ;/* note that we increment depth before calling btf_dump_print() below; * this is intentional. btf_dump_data_newline() will not print a
Signature · 1 line
2.38.1
Quoted 10 lines · David Michael
GCC 11.3.0 fails to compile
btf_dump.cdue to the following error, which seems to originate inbtf_dump_struct_datawhere the returned value would be uninitialized ifbtf_vlenreturns zero.
btf_dump.c: In function ‘btf_dump_dump_type_data’:
btf_dump.c:2363:12: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2363 | if (err < 0)
| ^Fixes 43174f0d4597 ("libbpf: Silence uninitialized warning/error in btf_dump_dump_type_data")
Probably better to reference the original patch?
Quoted 31 lines
Signed-off-by David Michael <[email protected]>---
Hi,
I encountered this build failure when using Gentoo's hardened profile to build sys-kernel/gentoo-kernel (at least some 5.19 and 6.0 versions). The following patch fixes it. Can this be applied?
Thanks.
David
tools/lib/bpf/btf_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/btf_dump.c +1
-2@@ -1989,7 +1989,7 @@ static int btf_dump_struct_data(struct btf_dump *d, {const struct btf_member *m =btf_members (t);__u16 n =btf_vlen (t); -int i, err; +int i, err =0 ;/* note that we increment depth before calling btf_dump_print() below; * this is intentional. btf_dump_data_newline() will not print a -- 2.38.1
Alan Maguire
Acked-byQuoted 10 lines · On 14/11/2022 17:21, [email protected] wrote:
Quoted 8 lines · David Michael
GCC 11.3.0 fails to compile
btf_dump.cdue to the following error, which seems to originate inbtf_dump_struct_datawhere the returned value would be uninitialized ifbtf_vlenreturns zero.
btf_dump.c: In function ‘btf_dump_dump_type_data’:
btf_dump.c:2363:12: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 2363 | if (err < 0)
| ^
Quoted 7 lines
Quoted 1 line
Fixes 43174f0d4597 ("libbpf: Silence uninitialized warning/error in btf_dump_dump_type_data")Probably better to reference the original patch?
Fixes 920d16af9b42 ("libbpf: BTF dumper support for typed data")
Thanks for fixing!
Quoted 31 lines
Quoted 31 lines
Signed-off-by David Michael <[email protected]>---
Hi,
I encountered this build failure when using Gentoo's hardened profile to build sys-kernel/gentoo-kernel (at least some 5.19 and 6.0 versions). The following patch fixes it. Can this be applied?
Thanks.
David
tools/lib/bpf/btf_dump.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/btf_dump.c +1
-1@@ -1989,7 +1989,7 @@ static int btf_dump_struct_data(struct btf_dump *d, { const struct btf_member *m = btf_members(t); __u16 n = btf_vlen(t); - int i, err; + int i, err = 0; /* note that we increment depth before calling btf_dump_print() below;* this is intentional. btf_dump_data_newline() will not print a Signature · 1 line
2.38.1
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 10 lines · On Sun, 13 Nov 2022 15:52:17 -0500 you wrote:
GCC 11.3.0 fails to compile
btf_dump.cdue to the following error, which seems to originate inbtf_dump_struct_datawhere the returned value would be uninitialized ifbtf_vlenreturns zero.
btf_dump.c: In function ‘btf_dump_dump_type_data’:
btf_dump.c:2363:12: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2363 | if (err < 0)
| ^[...]
Here is the summary with links:
- libbpf: Fix uninitialized warning in btf_dump_dump_type_data
https://git.kernel.org/bpf/bpf-next/c/dfd0afbf151d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html