summaryrefslogtreecommitdiff
path: root/tools/bpf/bpftool/iter.c
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2022-11-20 16:17:46 -0800
committerAlexei Starovoitov <ast@kernel.org>2022-11-20 16:18:25 -0800
commit35ffb1d9bff01cf3e2a55fcc8ab001cbb087c9cb (patch)
tree485001b6e4ef11db75fb1a4bd2e896bbb8742fe9 /tools/bpf/bpftool/iter.c
parent99429b224f6107f691c365ef9bdc1bbe4ee43ede (diff)
parent52df1a8aabadeba1e4c2fe157784637ddec76301 (diff)
Merge branch 'clean-up bpftool from legacy support'
Sahid Orentino Ferdjaoui says: ==================== As part of commit 93b8952d223a ("libbpf: deprecate legacy BPF map definitions") and commit bd054102a8c7 ("libbpf: enforce strict libbpf 1.0 behaviors") The --legacy option is not relevant anymore. #1 is removing it. #4 is cleaning the code from using libbpf_get_error(). About patches #2 and #3 They are changes discovered while working on this series (credits to Quentin Monnet). #2 is cleaning-up usage of an unnecessary PTR_ERR(NULL), finally #3 is fixing an invalid value passed to strerror(). v1 -> v2: - Addressed review comments from Yonghong Song on patch #4 - Added a patch #5 that removes unwanted function noticed by Yonghong Song v2 -> v3 - Addressed review comments from Andrii Nakryiko on patch #2, #3, #4 * clean-up usage of libbpf_get_error() (#2, #3) * fix possible return of an uninitialized local variable err * fix returned errors using errno v3 -> v4 - Addressed review comments from Quentin Monnet * fix line moved from patch #2 to patch #3 * fix missing returned errors using errno * fix some returned values to errno instead of -1 ==================== Reviewed-by: Quentin Monnet <quentin@isovalent.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/bpf/bpftool/iter.c')
-rw-r--r--tools/bpf/bpftool/iter.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/bpf/bpftool/iter.c b/tools/bpf/bpftool/iter.c
index a3e6b167153d..9a1d2365a297 100644
--- a/tools/bpf/bpftool/iter.c
+++ b/tools/bpf/bpftool/iter.c
@@ -4,6 +4,7 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
+#include <errno.h>
#include <unistd.h>
#include <linux/err.h>
#include <bpf/libbpf.h>
@@ -48,8 +49,8 @@ static int do_pin(int argc, char **argv)
}
obj = bpf_object__open(objfile);
- err = libbpf_get_error(obj);
- if (err) {
+ if (!obj) {
+ err = -errno;
p_err("can't open objfile %s", objfile);
goto close_map_fd;
}
@@ -62,13 +63,14 @@ static int do_pin(int argc, char **argv)
prog = bpf_object__next_program(obj, NULL);
if (!prog) {
+ err = -errno;
p_err("can't find bpf program in objfile %s", objfile);
goto close_obj;
}
link = bpf_program__attach_iter(prog, &iter_opts);
- err = libbpf_get_error(link);
- if (err) {
+ if (!link) {
+ err = -errno;
p_err("attach_iter failed for program %s",
bpf_program__name(prog));
goto close_obj;