From: YueHaibing <yuehaibing@huawei.com>
To: <ast@kernel.org>, <daniel@iogearbox.net>, <kafai@fb.com>,
<songliubraving@fb.com>, <yhs@fb.com>, <andriin@fb.com>,
<john.fastabend@gmail.com>, <kpsingh@chromium.org>,
<quentin@isovalent.com>
Cc: <netdev@vger.kernel.org>, <bpf@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
YueHaibing <yuehaibing@huawei.com>
Subject: [PATCH v2] tools/bpftool: Fix error handing in do_skeleton()
Date: Fri, 17 Jul 2020 20:30:59 +0800 [thread overview]
Message-ID: <20200717123059.29624-1-yuehaibing@huawei.com> (raw)
In-Reply-To: <20200715031353.14692-1-yuehaibing@huawei.com>
Fix pass 0 to PTR_ERR, also dump more err info using
libbpf_strerror.
Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
---
v2: use libbpf_strerror
---
tools/bpf/bpftool/gen.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index b59d26e89367..8a4c2b3b0cd6 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -302,8 +302,11 @@ static int do_skeleton(int argc, char **argv)
opts.object_name = obj_name;
obj = bpf_object__open_mem(obj_data, file_sz, &opts);
if (IS_ERR(obj)) {
+ char err_buf[256];
+
+ libbpf_strerror(PTR_ERR(obj), err_buf, sizeof(err_buf));
+ p_err("failed to open BPF object file: %s", err_buf);
obj = NULL;
- p_err("failed to open BPF object file: %ld", PTR_ERR(obj));
goto out;
}
--
2.17.1
next prev parent reply other threads:[~2020-07-17 12:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-15 3:13 [PATCH] tools/bpftool: Fix error return code in do_skeleton() YueHaibing
2020-07-15 16:49 ` Quentin Monnet
2020-07-15 19:23 ` Daniel Borkmann
2020-07-17 12:30 ` YueHaibing [this message]
2020-07-21 19:36 ` [PATCH v2] tools/bpftool: Fix error handing " Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200717123059.29624-1-yuehaibing@huawei.com \
--to=yuehaibing@huawei.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=quentin@isovalent.com \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).