diff options
| author | Joe Stringer <[email protected]> | 2017-01-23 01:11:25 +0000 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <[email protected]> | 2017-01-26 14:42:58 +0000 |
| commit | e28ff1a8382ee02b10cf11cf3b48541dc3d14a58 (patch) | |
| tree | 7b2e4fbf719f7c62f506e2d19f5aca86597d0337 /tools/lib/bpf/libbpf.c | |
| parent | tools lib bpf: Add set/is helpers for all prog types (diff) | |
| download | kernel-e28ff1a8382ee02b10cf11cf3b48541dc3d14a58.tar.gz kernel-e28ff1a8382ee02b10cf11cf3b48541dc3d14a58.zip | |
tools lib bpf: Add libbpf_get_error()
This function will turn a libbpf pointer into a standard error code (or
0 if the pointer is valid).
This also allows removal of the dependency on linux/err.h in the public
header file, which causes problems in userspace programs built against
libbpf.
Signed-off-by: Joe Stringer <[email protected]>
Acked-by: Wang Nan <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 406838fa9c4f..e6cd62b1264b 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -28,6 +28,7 @@ #include <fcntl.h> #include <errno.h> #include <asm/unistd.h> +#include <linux/err.h> #include <linux/kernel.h> #include <linux/bpf.h> #include <linux/list.h> @@ -1542,3 +1543,10 @@ bpf_object__find_map_by_offset(struct bpf_object *obj, size_t offset) } return ERR_PTR(-ENOENT); } + +long libbpf_get_error(const void *ptr) +{ + if (IS_ERR(ptr)) + return PTR_ERR(ptr); + return 0; +} |
