public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Wangnan (F)" <wangnan0@huawei•com>
To: Eric Leblond <eric@regit•org>, <netdev@vger•kernel.org>
Cc: Alexei Starovoitov <ast@fb•com>
Subject: Re: [PATCH net-next 1/2] tools lib bpf: suppress useless include
Date: Mon, 15 Aug 2016 11:20:39 +0800	[thread overview]
Message-ID: <57B13507.7040601@huawei.com> (raw)
In-Reply-To: <1471090643-22403-2-git-send-email-eric@regit.org>



On 2016/8/13 20:17, Eric Leblond wrote:
> 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.
>
> Signed-off-by: Eric Leblond <eric@regit•org>
> ---
>   tools/lib/bpf/libbpf.c | 1 +
>   tools/lib/bpf/libbpf.h | 1 -
>   2 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index b699aea..7872ff6 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>
>   
> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> index dd7a513..a6c5cde 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>
>   

Functions declared in this header require PTR_ERR
to decode error number. Logically speaking, this
header depends linux/err.h, so this include is
required. If not, there must have another way for
caller to decode error numbers.

I know the problem you try to solve. Please have a look at thread

https://lkml.org/lkml/2015/12/17/20

At that time I think we should create a wrapper in libbpf.h like this:

#ifdef USE_LINUX_ERR
#include <linux/err.h>
#endif
...
int libbpf_ptr_err(void *ptr);
...

It is acceptable but ugly. Can you find a better method?

Thank you.

>   enum libbpf_errno {
>   	__LIBBPF_ERRNO__START = 4000,

  reply	other threads:[~2016-08-15  3:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-13 12:17 [PATCH net-next 0/2] libbpf: minor fix and API update Eric Leblond
2016-08-13 12:17 ` [PATCH net-next 1/2] tools lib bpf: suppress useless include Eric Leblond
2016-08-15  3:20   ` Wangnan (F) [this message]
2016-08-13 12:17 ` [PATCH net-next 2/2] tools lib bpf: export function to set type Eric Leblond
2016-08-15  3:41   ` Wangnan (F)
2016-08-15  1:22 ` [PATCH net-next 0/2] libbpf: minor fix and API update Wangnan (F)

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=57B13507.7040601@huawei.com \
    --to=wangnan0@huawei$(echo .)com \
    --cc=ast@fb$(echo .)com \
    --cc=eric@regit$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox