All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Leblond <eric@regit.org>
To: netdev@vger.kernel.org, wangnan0@huawei.com
Cc: linux-kernel@vger.kernel.org, ast@fb.com, Eric Leblond <eric@regit.org>
Subject: [PATCH 1/8] tools lib bpf: add error functions
Date: Sun, 16 Oct 2016 23:18:27 +0200	[thread overview]
Message-ID: <20161016211834.11732-2-eric@regit.org> (raw)
In-Reply-To: <20161016211834.11732-1-eric@regit.org>

The include of err.h is not explicitely needed in exported
functions and it was causing include conflict with some existing
code due to redefining some macros.

To fix this, let's have error handling functions provided by the
library. Furthermore this will allow user to have an homogeneous
API.

Signed-off-by: Eric Leblond <eric@regit.org>
---
 tools/lib/bpf/libbpf.c | 11 +++++++++++
 tools/lib/bpf/libbpf.h |  4 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b699aea..90932f1 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -31,6 +31,7 @@
 #include <linux/kernel.h>
 #include <linux/bpf.h>
 #include <linux/list.h>
+#include <linux/err.h>
 #include <libelf.h>
 #include <gelf.h>
 
@@ -1447,3 +1448,13 @@ bpf_object__find_map_by_name(struct bpf_object *obj, const char *name)
 	}
 	return NULL;
 }
+
+bool bpf__is_error(const void *ptr)
+{
+	return IS_ERR(ptr);
+}
+
+long bpf__get_error(const void *ptr)
+{
+	return PTR_ERR(ptr);
+}
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index dd7a513..e40c8d3 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -23,7 +23,6 @@
 
 #include <stdio.h>
 #include <stdbool.h>
-#include <linux/err.h>
 
 enum libbpf_errno {
 	__LIBBPF_ERRNO__START = 4000,
@@ -211,4 +210,7 @@ int bpf_map__set_priv(struct bpf_map *map, void *priv,
 		      bpf_map_clear_priv_t clear_priv);
 void *bpf_map__priv(struct bpf_map *map);
 
+bool bpf__is_error(const void *ptr);
+long bpf__get_error(const void *ptr);
+
 #endif
-- 
2.9.3

  reply	other threads:[~2016-10-16 22:01 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-16 21:18 [PATCH 0/8] tools lib bpf: fixes and functional upgrade Eric Leblond
2016-10-16 21:18 ` Eric Leblond
2016-10-16 21:18 ` Eric Leblond [this message]
2016-10-17  1:47   ` [PATCH 1/8] tools lib bpf: add error functions Wangnan (F)
2016-10-18 22:52   ` Joe Stringer
2016-10-19  1:53     ` Wangnan (F)
2016-10-16 21:18 ` [PATCH 2/8] uapi linux bpf: add max value to enum Eric Leblond
2016-10-16 21:18 ` [PATCH 3/8] tools: Sync tools/include/uapi/linux/bpf.h with the kernel Eric Leblond
2016-10-17  1:48   ` Wangnan (F)
2016-10-16 21:18 ` [PATCH 4/8] tools lib bpf: export function to set type Eric Leblond
2016-10-17  1:56   ` Wangnan (F)
2016-10-16 21:18 ` [PATCH 5/8] tools lib bpf: add missing functions Eric Leblond
2016-10-17  2:16   ` Wangnan (F)
2016-10-16 21:18 ` [PATCH 6/8] tools lib bpf: improve warning Eric Leblond
2016-10-17  2:17   ` Wangnan (F)
2016-10-16 21:18 ` [PATCH 7/8] tools lib bpf: fix maps resolution Eric Leblond
2016-10-17  2:23   ` Wangnan (F)
2016-11-07 18:23   ` Wangnan (F)
2016-11-07 18:40     ` Eric Leblond
2016-11-08 22:08   ` Wangnan (F)
2016-10-16 21:18 ` [PATCH 8/8] tools lib bpf: install header file Eric Leblond

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161016211834.11732-2-eric@regit.org \
    --to=eric@regit.org \
    --cc=ast@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.