All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Michael <fedora.dm0@gmail.com>
To: andrii@kernel.org
Cc: bpf@vger.kernel.org
Subject: [PATCH] libbpf: Fix uninitialized warning in btf_dump_dump_type_data
Date: Sun, 13 Nov 2022 15:52:17 -0500	[thread overview]
Message-ID: <87zgcu60hq.fsf@gmail.com> (raw)

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")
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

             reply	other threads:[~2022-11-13 20:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-13 20:52 David Michael [this message]
2022-11-14 17:21 ` [PATCH] libbpf: Fix uninitialized warning in btf_dump_dump_type_data sdf
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=87zgcu60hq.fsf@gmail.com \
    --to=fedora.dm0@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.