libbpf: Fix uninitialized warning in btf_dump_dump_type_data
authorDavid Michael <fedora.dm0@gmail.com>
Sun, 13 Nov 2022 20:52:17 +0000 (15:52 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Dec 2022 16:48:02 +0000 (17:48 +0100)
commit76c6303530ebcb1459302d8943527cba04baf42e
treed4d429bf61cdc3f21371181ee6c6d3a26c72b2c7
parent96c5043a4d6443d56b92b5740e8e7d25907d1c66
libbpf: Fix uninitialized warning in btf_dump_dump_type_data

commit dfd0afbf151d85411b371e841f62b81ee5d1ca54 upstream.

GCC 11.3.0 fails to compile btf_dump.c due to the following error,
which seems to originate in btf_dump_struct_data where the returned
value would be uninitialized if btf_vlen returns zero.

btf_dump.c: In function ‘btf_dump_dump_type_data’:
btf_dump.c:2363:12: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2363 |         if (err < 0)
      |            ^

Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data")
Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/bpf/87zgcu60hq.fsf@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/lib/bpf/btf_dump.c