libbpf: Fix compile error in libbpf_attach_type_by_name
authorAndrey Ignatov <rdna@fb.com>
Wed, 31 Oct 2018 19:57:18 +0000 (12:57 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 31 Oct 2018 22:06:17 +0000 (23:06 +0100)
commit3615353218744bb60f55170c620ce4dce1a008c7
treefd8df6356914077abfcfe6434ae664de3ba32b1a
parentdeee2cae27d1914850195e3fb219cc611e953560
libbpf: Fix compile error in libbpf_attach_type_by_name

Arnaldo Carvalho de Melo reported build error in libbpf when clang
version 3.8.1-24 (tags/RELEASE_381/final) is used:

libbpf.c:2201:36: error: comparison of constant -22 with expression of
type 'const enum bpf_attach_type' is always false
[-Werror,-Wtautological-constant-out-of-range-compare]
                if (section_names[i].attach_type == -EINVAL)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~
1 error generated.

Fix the error by keeping "is_attachable" property of a program in a
separate struct field instead of trying to use attach_type itself.

Fixes: 956b620fcf0b ("libbpf: Introduce libbpf_attach_type_by_name")
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/lib/bpf/libbpf.c