lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230727082536.1974154-1-xiangyu.chen@eng.windriver.com>
Date:   Thu, 27 Jul 2023 16:25:36 +0800
From:   Xiangyu Chen <xiangyu.chen@....windriver.com>
To:     bpf@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH] libbpf: fix warnings "'pad_type' 'pad_bits' 'new_off' may be used uninitialized"

From: Xiangyu Chen <xiangyu.chen@...driver.com>

When turn on the yocto DEBUG_BUILD flag, the build options for gcc would enable maybe-uninitialized,
and following warnings would be reported as below:

| btf_dump.c: In function 'btf_dump_emit_bit_padding':
| btf_dump.c:916:4: error: 'pad_type' may be used uninitialized in this function [-Werror=maybe-uninitialized]
|   916 |    btf_dump_printf(d, "\n%s%s: %d;", pfx(lvl), pad_type,
|       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|   917 |      in_bitfield ? new_off - cur_off : 0);
|       |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| btf_dump.c:929:6: error: 'pad_bits' may be used uninitialized in this function [-Werror=maybe-uninitialized]
|   929 |   if (bits == pad_bits) {
|       |      ^
| btf_dump.c:913:28: error: 'new_off' may be used uninitialized in this function [-Werror=maybe-uninitialized]
|   913 |       (new_off == next_off && roundup(cur_off, next_align * 8) != new_off) ||
|       |       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|   HOSTLD  scripts/mod/modpost

Signed-off-by: Xiangyu Chen <xiangyu.chen@...driver.com>
---
 tools/lib/bpf/btf_dump.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index 4d9f30bf7f01..79923c3b8777 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -867,8 +867,8 @@ static void btf_dump_emit_bit_padding(const struct btf_dump *d,
 	} pads[] = {
 		{"long", d->ptr_sz * 8}, {"int", 32}, {"short", 16}, {"char", 8}
 	};
-	int new_off, pad_bits, bits, i;
-	const char *pad_type;
+	int new_off = 0, pad_bits = 0, bits, i;
+	const char *pad_type = NULL;
 
 	if (cur_off >= next_off)
 		return; /* no gap */
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ