Skip to content

Commit 13cb757

Browse files
fossddAlexei Starovoitov
authored andcommitted
libbpf: Avoid possible use of uninitialized mod_len
Though mod_len is only read when mod_name != NULL and both are initialized together, gcc15 produces a warning with -Werror=maybe-uninitialized: libbpf.c: In function 'find_kernel_btf_id.constprop': libbpf.c:10100:33: error: 'mod_len' may be used uninitialized [-Werror=maybe-uninitialized] 10100 | if (mod_name && strncmp(mod->name, mod_name, mod_len) != 0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libbpf.c:10070:21: note: 'mod_len' was declared here 10070 | int ret, i, mod_len; | ^~~~~~~ Silence the false positive. Signed-off-by: Achill Gilgenast <fossdd@pwned.life> Acked-by: Yonghong Song <yonghong.song@linux.dev> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20250729094611.2065713-1-fossdd@pwned.life Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent abad3d0 commit 13cb757

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/lib/bpf/libbpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10096,7 +10096,7 @@ static int find_kernel_btf_id(struct bpf_object *obj, const char *attach_name,
1009610096
enum bpf_attach_type attach_type,
1009710097
int *btf_obj_fd, int *btf_type_id)
1009810098
{
10099-
int ret, i, mod_len;
10099+
int ret, i, mod_len = 0;
1010010100
const char *fn_name, *mod_name = NULL;
1010110101

1010210102
fn_name = strchr(attach_name, ':');

0 commit comments

Comments
 (0)