diff mbox series

tools/bpf: Return the appropriate error value

Message ID HKAPR02MB429180E153A7547C20F17915E0F40@HKAPR02MB4291.apcprd02.prod.outlook.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series tools/bpf: Return the appropriate error value | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

彭浩(Richard) Dec. 1, 2020, 3:02 a.m. UTC
Compile times error:
"Error: failed to load BTF from /mnt/linux/vmlinux: No such file or directory".
This file "/mnt/linux/vmlinux" actually exists, but only because CONFIG_DEBUG_INFO_BTF
is not configured with this error.

Signed-off-by: Peng Hao <richard.peng@oppo.com>
---
 tools/lib/bpf/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.18.4

Comments

Andrii Nakryiko Dec. 2, 2020, 1:38 a.m. UTC | #1
On Mon, Nov 30, 2020 at 7:06 PM 彭浩(Richard) <richard.peng@oppo.com> wrote:
>
> Compile times error:
> "Error: failed to load BTF from /mnt/linux/vmlinux: No such file or directory".
> This file "/mnt/linux/vmlinux" actually exists, but only because CONFIG_DEBUG_INFO_BTF
> is not configured with this error.
>
> Signed-off-by: Peng Hao <richard.peng@oppo.com>
> ---
>  tools/lib/bpf/btf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index 231b07203e3d..228f508fbd04 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -865,7 +865,7 @@ struct btf *btf__parse_elf(const char *path, struct btf_ext **btf_ext)
>         err = 0;
>
>         if (!btf_data) {
> -               err = -ENOENT;
> +               err = -EPROTO;

ENOENT as related to "no .BTF section found"... EPROTO would make
sense as well, but I don't think we need to really change anything.
"Protocol error" isn't very meaningful either...


>                 goto done;
>         }
>         btf = btf__new(btf_data->d_buf, btf_data->d_size);
> --
> 2.18.4
diff mbox series

Patch

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 231b07203e3d..228f508fbd04 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -865,7 +865,7 @@  struct btf *btf__parse_elf(const char *path, struct btf_ext **btf_ext)
        err = 0;

        if (!btf_data) {
-               err = -ENOENT;
+               err = -EPROTO;
                goto done;
        }
        btf = btf__new(btf_data->d_buf, btf_data->d_size);