linux-yocto/6.12: libbpf: silence maybe-uninitialized warning from clang
Integrating the following commit(s) to linux-yocto/6.12:
1/1 [
Author: Ross Burton
Email: ross.burton@arm.com
Subject: libbpf: silence maybe-uninitialized warning from clang
Date: Wed, 4 Jun 2025 21:22:23 +0100
perf is build with -Werror, but clang 20.1.6 (incorrectly) finds that
mod_len may be used uninitialized:
libbpf.c: In function 'find_kernel_btf_id.constprop':
libbpf.c:10009:33: error: 'mod_len' may be used uninitialized [-Werror=maybe-uninitialized]
10009 | if (mod_name && strncmp(mod->name, mod_name, mod_len) != 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libbpf.c:9979:21: note: 'mod_len' was declared here
9979 | int ret, i, mod_len;
| ^~~~~~~
Inspecting the code it can be seen that mod_len is set if mod_name is
set, and the strncmp() is only called if mod_name is set, so this is a
false positive (interestingly, clang doesn't spot the same issue above).
Silence the false positive by explicitly initializing mod_len to 0.
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
]
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit
43f6b7795170f0e571265f22bcef51554684206f)
Signed-off-by: Steve Sakoman <steve@sakoman.com>