]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Silence uninitialized warning/error in btf_dump_dump_type_data
authorAlan Maguire <alan.maguire@oracle.com>
Mon, 29 Nov 2021 10:00:40 +0000 (10:00 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 29 Nov 2021 17:36:44 +0000 (09:36 -0800)
commitd402c4a3132fcfe20eda80cae8eeac7ff8a16b4b
tree318a452e823b527a7adb1a7018304a078aa0661b
parent8e4cd86c7b497d5b5c1ef0d1c9fdef28ec7b93e7
libbpf: Silence uninitialized warning/error in btf_dump_dump_type_data

When compiling libbpf with gcc 4.8.5, we see:

  CC       staticobjs/btf_dump.o
btf_dump.c: In function ‘btf_dump_dump_type_data.isra.24’:
btf_dump.c:2296:5: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  if (err < 0)
     ^
cc1: all warnings being treated as errors
make: *** [staticobjs/btf_dump.o] Error 1

While gcc 4.8.5 is too old to build the upstream kernel, it's possible it
could be used to build standalone libbpf which suffers from the same problem.
Silence the error by initializing 'err' to 0.  The warning/error seems to be
a false positive since err is set early in the function.  Regardless we
shouldn't prevent libbpf from building for this.

Fixes: db6a92f38729 ("libbpf: BTF dumper support for typed data")
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/1638180040-8037-1-git-send-email-alan.maguire@oracle.com
tools/lib/bpf/btf_dump.c