Skip to content

Commit c50fd3e

Browse files
guidosarduccigregkh
authored andcommitted
libbpf: Fix build failure from uninitialized variable warning
[ Upstream commit 3168c15 ] While compiling libbpf, some GCC versions (at least 8.4.0) have difficulty determining control flow and a emit warning for potentially uninitialized usage of 'map', which results in a build error if using "-Werror": In file included from libbpf.c:56: libbpf.c: In function '__bpf_object__open': libbpf_internal.h:59:2: warning: 'map' may be used uninitialized in this function [-Wmaybe-uninitialized] libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \ ^~~~~~~~~~~~ libbpf.c:5032:18: note: 'map' was declared here struct bpf_map *map, *targ_map; ^~~ The warning/error is false based on code inspection, so silence it with a NULL initialization. Fixes: 646f02f ("libbpf: Add BTF-defined map-in-map support") Reference: 063e688 ("libbpf: Fix false uninitialized variable warning") Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20200831000304.1696435-1-Tony.Ambardar@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a5307da commit c50fd3e

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
@@ -5030,8 +5030,8 @@ static int bpf_object__collect_map_relos(struct bpf_object *obj,
50305030
int i, j, nrels, new_sz;
50315031
const struct btf_var_secinfo *vi = NULL;
50325032
const struct btf_type *sec, *var, *def;
5033+
struct bpf_map *map = NULL, *targ_map;
50335034
const struct btf_member *member;
5034-
struct bpf_map *map, *targ_map;
50355035
const char *name, *mname;
50365036
Elf_Data *symbols;
50375037
unsigned int moff;

0 commit comments

Comments
 (0)