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

bpftool: Migrate -1 err checks of libbpf fn calls

Per [0], callers of libbpf functions with LIBBPF_STRICT_DIRECT_ERRS set
should handle negative error codes of various values (e.g. -EINVAL).
Migrate two callsites which were explicitly checking for -1 only to
handle the new scheme.

[0]: https://github.com/libbpf/libbpf/wiki/Libbpf-1.0-migration-guide#direct-error-code-returning-libbpf_strict_direct_errs

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20211101224357.2651181-2-davemarchevsky@fb.com

authored by

Dave Marchevsky and committed by
Andrii Nakryiko
60f27075 cc0356d6

+2 -2
+1 -1
tools/bpf/bpftool/btf_dumper.c
··· 52 52 53 53 /* Get the bpf_prog's name. Obtain from func_info. */ 54 54 prog_fd = bpf_prog_get_fd_by_id(prog_id); 55 - if (prog_fd == -1) 55 + if (prog_fd < 0) 56 56 goto print; 57 57 58 58 prog_info = bpf_program__get_prog_info_linear(prog_fd,
+1 -1
tools/bpf/bpftool/struct_ops.c
··· 252 252 } 253 253 254 254 fd = bpf_map_get_fd_by_id(id); 255 - if (fd == -1) { 255 + if (fd < 0) { 256 256 p_err("can't get map by id (%lu): %s", id, strerror(errno)); 257 257 res.nr_errs++; 258 258 return res;