]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
libbpf: Avoid possible use of uninitialized mod_len
authorAchill Gilgenast <fossdd@pwned.life>
Tue, 29 Jul 2025 09:45:53 +0000 (11:45 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 31 Jul 2025 18:39:46 +0000 (11:39 -0700)
commit13cb75730b7a8b2dc8fe32874e159b2c7b75efde
treefb8452c13c4a15e6f9bc981e4b7d7ec4e1eb306f
parentabad3d0bad72a52137e0c350c59542d75ae4f513
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>
tools/lib/bpf/libbpf.c