linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: YueHaibing <yuehaibing@huawei.com>,
	ast@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
	andriin@fb.com, john.fastabend@gmail.com, kpsingh@chromium.org
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tools/bpftool: Fix error return code in do_skeleton()
Date: Wed, 15 Jul 2020 21:23:33 +0200	[thread overview]
Message-ID: <6cb1dfd7-6456-ef1c-d708-042ab53b3d2c@iogearbox.net> (raw)
In-Reply-To: <20200715031353.14692-1-yuehaibing@huawei.com>

On 7/15/20 5:13 AM, YueHaibing wrote:
> The error return code should be PTR_ERR(obj) other than
> PTR_ERR(NULL).
> 
> Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>   tools/bpf/bpftool/gen.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index 10de76b296ba..35f62273cdbd 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c
> @@ -305,8 +305,9 @@ 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)) {
> +		err = PTR_ERR(obj);
> +		p_err("failed to open BPF object file: %ld", err);
>   		obj = NULL;
> -		p_err("failed to open BPF object file: %ld", PTR_ERR(obj));
>   		goto out;

Instead of just the error number, could we dump something useful to the user here
via libbpf_strerror() given you touch this line? Also, I think the convention in
do_skeleton() is to just return {0,-1} given this is propagated as return code
for bpftool.

>   	}
>   
> 


  parent reply	other threads:[~2020-07-15 19:23 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 [this message]
2020-07-17 12:30 ` [PATCH v2] tools/bpftool: Fix error handing " YueHaibing
2020-07-21 19:36   ` 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=6cb1dfd7-6456-ef1c-d708-042ab53b3d2c@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --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=songliubraving@fb.com \
    --cc=yhs@fb.com \
    --cc=yuehaibing@huawei.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).