diff mbox series

[bpf-next,5/9] libbpf: fix error code returned on corrupted ELF

Message ID 20190529011426.1328736-6-andriin@fb.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series [bpf-next,1/9] libbpf: fix detection of corrupted BPF instructions section | expand

Commit Message

Andrii Nakryiko May 29, 2019, 1:14 a.m. UTC
All of libbpf errors are negative, except this one. Fix it.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Song Liu May 29, 2019, 5:13 p.m. UTC | #1
On Tue, May 28, 2019 at 6:14 PM Andrii Nakryiko <andriin@fb.com> wrote:
>
> All of libbpf errors are negative, except this one. Fix it.
>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  tools/lib/bpf/libbpf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 7abe71ee507a..9c45856e7fd6 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -1221,7 +1221,7 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
>
>         if (!obj->efile.strtabidx || obj->efile.strtabidx >= idx) {
>                 pr_warning("Corrupted ELF file: index of strtab invalid\n");
> -               return LIBBPF_ERRNO__FORMAT;
> +               return -LIBBPF_ERRNO__FORMAT;
>         }
>         if (btf_data) {
>                 obj->btf = btf__new(btf_data->d_buf, btf_data->d_size);
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 7abe71ee507a..9c45856e7fd6 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1221,7 +1221,7 @@  static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
 
 	if (!obj->efile.strtabidx || obj->efile.strtabidx >= idx) {
 		pr_warning("Corrupted ELF file: index of strtab invalid\n");
-		return LIBBPF_ERRNO__FORMAT;
+		return -LIBBPF_ERRNO__FORMAT;
 	}
 	if (btf_data) {
 		obj->btf = btf__new(btf_data->d_buf, btf_data->d_size);