2020-08-02 11:16:56

by Tianjia Zhang

[permalink] [raw]
Subject: [PATCH] tools/bpf/bpftool: Fix wrong return value in do_dump()

In case of btf_id does not exist, a negative error code -ENOENT
should be returned.

Fixes: c93cc69004df3 ("bpftool: add ability to dump BTF types")
Cc: Andrii Nakryiko <[email protected]>
Signed-off-by: Tianjia Zhang <[email protected]>
---
tools/bpf/bpftool/btf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
index faac8189b285..c2f1fd414820 100644
--- a/tools/bpf/bpftool/btf.c
+++ b/tools/bpf/bpftool/btf.c
@@ -596,7 +596,7 @@ static int do_dump(int argc, char **argv)
goto done;
}
if (!btf) {
- err = ENOENT;
+ err = -ENOENT;
p_err("can't find btf with ID (%u)", btf_id);
goto done;
}
--
2.26.2


2020-08-03 01:25:51

by Andrii Nakryiko

[permalink] [raw]
Subject: Re: [PATCH] tools/bpf/bpftool: Fix wrong return value in do_dump()

On Sun, Aug 2, 2020 at 4:16 AM Tianjia Zhang
<[email protected]> wrote:
>
> In case of btf_id does not exist, a negative error code -ENOENT
> should be returned.
>
> Fixes: c93cc69004df3 ("bpftool: add ability to dump BTF types")
> Cc: Andrii Nakryiko <[email protected]>
> Signed-off-by: Tianjia Zhang <[email protected]>
> ---


Acked-by: Andrii Nakryiko <[email protected]>

> tools/bpf/bpftool/btf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
> index faac8189b285..c2f1fd414820 100644
> --- a/tools/bpf/bpftool/btf.c
> +++ b/tools/bpf/bpftool/btf.c
> @@ -596,7 +596,7 @@ static int do_dump(int argc, char **argv)
> goto done;
> }
> if (!btf) {
> - err = ENOENT;
> + err = -ENOENT;
> p_err("can't find btf with ID (%u)", btf_id);
> goto done;
> }
> --
> 2.26.2
>

2020-08-03 05:07:39

by John Fastabend

[permalink] [raw]
Subject: Re: [PATCH] tools/bpf/bpftool: Fix wrong return value in do_dump()

Andrii Nakryiko wrote:
> On Sun, Aug 2, 2020 at 4:16 AM Tianjia Zhang
> <[email protected]> wrote:
> >
> > In case of btf_id does not exist, a negative error code -ENOENT
> > should be returned.
> >
> > Fixes: c93cc69004df3 ("bpftool: add ability to dump BTF types")
> > Cc: Andrii Nakryiko <[email protected]>
> > Signed-off-by: Tianjia Zhang <[email protected]>
> > ---
>
>
> Acked-by: Andrii Nakryiko <[email protected]>
>

Acked-by: John Fastabend <[email protected]>

2020-08-03 08:42:11

by Tobias Klauser

[permalink] [raw]
Subject: Re: [PATCH] tools/bpf/bpftool: Fix wrong return value in do_dump()

On 2020-08-02 at 13:15:40 +0200, Tianjia Zhang <[email protected]> wrote:
> In case of btf_id does not exist, a negative error code -ENOENT
> should be returned.
>
> Fixes: c93cc69004df3 ("bpftool: add ability to dump BTF types")
> Cc: Andrii Nakryiko <[email protected]>
> Signed-off-by: Tianjia Zhang <[email protected]>

Reviewed-by: Tobias Klauser <[email protected]>

> ---
> tools/bpf/bpftool/btf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
> index faac8189b285..c2f1fd414820 100644
> --- a/tools/bpf/bpftool/btf.c
> +++ b/tools/bpf/bpftool/btf.c
> @@ -596,7 +596,7 @@ static int do_dump(int argc, char **argv)
> goto done;
> }
> if (!btf) {
> - err = ENOENT;
> + err = -ENOENT;
> p_err("can't find btf with ID (%u)", btf_id);
> goto done;
> }
> --
> 2.26.2
>

2020-08-03 14:34:30

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH] tools/bpf/bpftool: Fix wrong return value in do_dump()

On 8/2/20 1:15 PM, Tianjia Zhang wrote:
> In case of btf_id does not exist, a negative error code -ENOENT
> should be returned.
>
> Fixes: c93cc69004df3 ("bpftool: add ability to dump BTF types")
> Cc: Andrii Nakryiko <[email protected]>
> Signed-off-by: Tianjia Zhang <[email protected]>

Applied, thanks!