]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bpftool: fix error message when function can't register struct_ops
authorSahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Sun, 20 Nov 2022 11:26:18 +0000 (11:26 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 21 Nov 2022 00:17:46 +0000 (16:17 -0800)
It is expected that errno be passed to strerror(). This also cleans
this part of code from using libbpf_get_error().

Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Acked-by: Yonghong Song <yhs@fb.com>
Suggested-by: Quentin Monnet <quentin@isovalent.com>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/r/20221120112515.38165-4-sahid.ferdjaoui@industrialdiscipline.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/bpf/bpftool/struct_ops.c

index d3cfdfef9b58a2271867d85578f533d788e4dd5b..ae9ad85f5cdac5386feefb4ac5d9f6ff73c70ff4 100644 (file)
@@ -511,10 +511,9 @@ static int do_register(int argc, char **argv)
                        continue;
 
                link = bpf_map__attach_struct_ops(map);
-               if (libbpf_get_error(link)) {
+               if (!link) {
                        p_err("can't register struct_ops %s: %s",
-                             bpf_map__name(map),
-                             strerror(-PTR_ERR(link)));
+                             bpf_map__name(map), strerror(errno));
                        nr_errs++;
                        continue;
                }