Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1579090 > unrolled thread

[PATCH net-next v1] bpf: Remove redundant ifdef

Started byMickaël Salaün <mic@digikod.net>
First post2017-02-11 20:40 +0100
Last post2017-02-13 03:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH net-next v1] bpf: Remove redundant ifdef Mickaël Salaün <mic@digikod.net> - 2017-02-11 20:40 +0100
    Re: [PATCH net-next v1] bpf: Remove redundant ifdef "Wangnan (F)" <wangnan0@huawei.com> - 2017-02-13 03:00 +0100

#1579090 — [PATCH net-next v1] bpf: Remove redundant ifdef

FromMickaël Salaün <mic@digikod.net>
Date2017-02-11 20:40 +0100
Subject[PATCH net-next v1] bpf: Remove redundant ifdef
Message-ID<t9LGx-4H8-1@gated-at.bofh.it>
Remove a useless ifdef __NR_bpf as requested by Wang Nan.

Inline one-line static functions as it was in the bpf_sys.h file.

Signed-off-by: Mickaël Salaün <mic@digikod.net>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David S. Miller <davem@davemloft.net>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/r/828ab1ff-4dcf-53ff-c97b-074adb895006@huawei.com
---
 tools/lib/bpf/bpf.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 50e04cc5dddd..2de9c386989a 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -42,21 +42,15 @@
 # endif
 #endif
 
-static __u64 ptr_to_u64(const void *ptr)
+static inline __u64 ptr_to_u64(const void *ptr)
 {
 	return (__u64) (unsigned long) ptr;
 }
 
-static int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
-		   unsigned int size)
+static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
+			  unsigned int size)
 {
-#ifdef __NR_bpf
 	return syscall(__NR_bpf, cmd, attr, size);
-#else
-	fprintf(stderr, "No bpf syscall, kernel headers too old?\n");
-	errno = ENOSYS;
-	return -1;
-#endif
 }
 
 int bpf_create_map(enum bpf_map_type map_type, int key_size,
-- 
2.11.0

[toc] | [next] | [standalone]


#1579352

From"Wangnan (F)" <wangnan0@huawei.com>
Date2017-02-13 03:00 +0100
Message-ID<tae5Q-5nj-1@gated-at.bofh.it>
In reply to#1579090

On 2017/2/12 3:37, Mickaël Salaün wrote:
> Remove a useless ifdef __NR_bpf as requested by Wang Nan.
>
> Inline one-line static functions as it was in the bpf_sys.h file.
>
> Signed-off-by: Mickaël Salaün <mic@digikod.net>
> Cc: Alexei Starovoitov <ast@fb.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Wang Nan <wangnan0@huawei.com>
> Link: https://lkml.kernel.org/r/828ab1ff-4dcf-53ff-c97b-074adb895006@huawei.com
> ---
>   tools/lib/bpf/bpf.c | 12 +++---------
>   1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index 50e04cc5dddd..2de9c386989a 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -42,21 +42,15 @@
>   # endif
>   #endif
>   
> -static __u64 ptr_to_u64(const void *ptr)
> +static inline __u64 ptr_to_u64(const void *ptr)
>   {
>   	return (__u64) (unsigned long) ptr;
>   }
>   
> -static int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
> -		   unsigned int size)
> +static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
> +			  unsigned int size)
>   {
> -#ifdef __NR_bpf
>   	return syscall(__NR_bpf, cmd, attr, size);
> -#else
> -	fprintf(stderr, "No bpf syscall, kernel headers too old?\n");
> -	errno = ENOSYS;
> -	return -1;
> -#endif
>   }
>   
>   int bpf_create_map(enum bpf_map_type map_type, int key_size,

Acked-by: Wang Nan <wangnan0@huawei.com>

However, it is better to merge this patch with commit 
702498a1426bc95b6f49f9c5fba616110cbd3947.

Thank you.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web