diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2020-05-25 16:54:21 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-06-02 00:38:19 +0300 |
commit | dc3ca5cf3e0be9fb73f4691247367d76a22bf30b (patch) | |
tree | d7393cd6ba68b08787e37d9414c32a9ce10fbdf4 /tools/bpf | |
parent | 73a4f0407e67cdfdf55dd94f573ed4ee2d0d62fe (diff) | |
download | linux-dc3ca5cf3e0be9fb73f4691247367d76a22bf30b.tar.xz |
tools, bpftool: Print correct error message when failing to load BTF
btf__parse_raw and btf__parse_elf return negative error numbers wrapped
in an ERR_PTR, so the extracted value needs to be negated before passing
them to strerror which expects a positive error number.
Before:
Error: failed to load BTF from .../vmlinux: Unknown error -2
After:
Error: failed to load BTF from .../vmlinux: No such file or directory
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200525135421.4154-1-tklauser@distanz.ch
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/bpf')
-rw-r--r-- | tools/bpf/bpftool/btf.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c index c134666591a6..faac8189b285 100644 --- a/tools/bpf/bpftool/btf.c +++ b/tools/bpf/bpftool/btf.c @@ -553,7 +553,7 @@ static int do_dump(int argc, char **argv) btf = btf__parse_elf(*argv, NULL); if (IS_ERR(btf)) { - err = PTR_ERR(btf); + err = -PTR_ERR(btf); btf = NULL; p_err("failed to load BTF from %s: %s", *argv, strerror(err)); |