Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: Initialize err in probe_map_create

GCC-11 warns about the possibly unitialized err variable in
probe_map_create:

libbpf_probes.c: In function 'probe_map_create':
libbpf_probes.c:361:38: error: 'err' may be used uninitialized in this function [-Werror=maybe-uninitialized]
361 | return fd < 0 && err == exp_err ? 1 : 0;
| ~~~~^~~~~~~~~~

Fixes: 878d8def0603 ("libbpf: Rework feature-probing APIs")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20220801025109.1206633-1-f.fainelli@gmail.com

authored by

Florian Fainelli and committed by
Andrii Nakryiko
3045f42a 47ea7417

+1 -1
+1 -1
tools/lib/bpf/libbpf_probes.c
··· 193 193 LIBBPF_OPTS(bpf_map_create_opts, opts); 194 194 int key_size, value_size, max_entries; 195 195 __u32 btf_key_type_id = 0, btf_value_type_id = 0; 196 - int fd = -1, btf_fd = -1, fd_inner = -1, exp_err = 0, err; 196 + int fd = -1, btf_fd = -1, fd_inner = -1, exp_err = 0, err = 0; 197 197 198 198 key_size = sizeof(__u32); 199 199 value_size = sizeof(__u32);