libbpf: fix false uninitialized variable warning
authorAndrii Nakryiko <andriin@fb.com>
Wed, 25 Sep 2019 18:30:38 +0000 (11:30 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 25 Sep 2019 20:15:02 +0000 (22:15 +0200)
Some compilers emit warning for potential uninitialized next_id usage.
The code is correct, but control flow is too complicated for some
compilers to figure this out. Re-initialize next_id to satisfy
compiler.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/lib/bpf/btf_dump.c

index 7159677623129996ec9a9d3bcc2223a6c8119591..84b0661db7f38a06913932423fecb77ed6ce8199 100644 (file)
@@ -1167,6 +1167,7 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,
                                return;
                        }
 
+                       next_id = decls->ids[decls->cnt - 1];
                        next_t = btf__type_by_id(d->btf, next_id);
                        multidim = btf_is_array(next_t);
                        /* we need space if we have named non-pointer */