From: sdf@google.com
To: David Michael <fedora.dm0@gmail.com>
Cc: andrii@kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH] libbpf: Fix uninitialized warning in btf_dump_dump_type_data
Date: Mon, 14 Nov 2022 09:21:48 -0800 [thread overview]
Message-ID: <Y3J5LMzdb9+FBCN8@google.com> (raw)
In-Reply-To: <87zgcu60hq.fsf@gmail.com>
On 11/13, David Michael wrote:
> 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)
> | ^
> 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")
Acked-by: Stanislav Fomichev <sdf@google.com>
> Signed-off-by: David Michael <fedora.dm0@gmail.com>
> ---
> 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(-)
> diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
> index 12f7039e0..e9f849d82 100644
> --- a/tools/lib/bpf/btf_dump.c
> +++ b/tools/lib/bpf/btf_dump.c
> @@ -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
next prev parent reply other threads:[~2022-11-14 17:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-13 20:52 [PATCH] libbpf: Fix uninitialized warning in btf_dump_dump_type_data David Michael
2022-11-14 17:21 ` sdf [this message]
2022-11-14 17:54 ` Alan Maguire
2022-11-14 18:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y3J5LMzdb9+FBCN8@google.com \
--to=sdf@google.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=fedora.dm0@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox