Skip to contentSkip to conversation

libbpf: avoid false unuinitialized variable warning in bpf_core_apply_relo

PATCH Applied Andrii Nakryiko 2 participants 2 messages Aug 21, 2020 – Aug 24, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf: avoid false unuinitialized variable warning in bpf_core_apply_relo

Some versions of GCC report uninitialized targ_spec usage. GCC is wrong, but let's avoid unnecessary warnings.

Fixes ddc7c3042614 ("libbpf: implement BPF CO-RE offset relocation algorithm")
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
index ea80a1582af6..58b9e7ea42b7 100644
@@ -5285,7 +5285,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
 			       struct hashmap *cand_cache)
 {
 	const char *prog_name = bpf_program__title(prog, false);
-	struct bpf_core_spec local_spec, cand_spec, targ_spec;
+	struct bpf_core_spec local_spec, cand_spec, targ_spec = {};
 	const void *type_key = u32_as_hash_key(relo->type_id);
 	struct bpf_core_relo_res cand_res, targ_res;
 	const struct btf_type *local_type;
Signature · 1 line
2.24.1
#1 lore raw
Quoted 6 lines · Andrii Nakryiko

Some versions of GCC report uninitialized targ_spec usage. GCC is wrong, but let's avoid unnecessary warnings.

Fixes ddc7c3042614 ("libbpf: implement BPF CO-RE offset relocation algorithm")

Applied. Thanks