Skip to contentSkip to conversation

bpf: Remove redundant ifdef

PATCH Applied Mickaël Salaün 3 participants 5 messages Feb 11, 2017 – Feb 15, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Remove redundant ifdef

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.

---
 tools/lib/bpf/bpf.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
tools/lib/bpf/bpf.c +3 -9
index 50e04cc5dddd..2de9c386989a 100644
@@ -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,
Signature · 1 line
2.11.0
Acked-by on v1 1/1
#1 lore raw
Quoted 33 lines · Mickaël Salaün

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.

---
  tools/lib/bpf/bpf.c | 12 +++---------
  1 file changed, 3 insertions(+), 9 deletions(-)
tools/lib/bpf/bpf.c +3 -3
index 50e04cc5dddd..2de9c386989a 100644
@@ -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)
  {

tools/lib/bpf/bpf.c line 56

Quoted 10 lines
tools/lib/bpf/bpf.c +0 -6
-#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,

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

Thank you.

maintainer
#2 lore raw

From: "Wangnan (F)" <[email protected]>
Date: Mon, 13 Feb 2017 09:53:49 +0800

Quoted 47 lines · Mickaël Salaün
Quoted 31 lines

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.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc David S. Miller <[email protected]>
Cc Wang Nan <[email protected]>

Link:
https://lkml.kernel.org/r/[email protected]

---
  tools/lib/bpf/bpf.c | 12 +++---------
  1 file changed, 3 insertions(+), 9 deletions(-)
tools/lib/bpf/bpf.c +3 -1
index 50e04cc5dddd..2de9c386989a 100644
@@ -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)

tools/lib/bpf/bpf.c line 55

Quoted 10 lines
tools/lib/bpf/bpf.c +0 -6
  {
-#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,
Quoted 2 lines

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

I don't know where this commit ID is. Since this patch is targetting net-next I would expect a commit ID with not context to be in that tree. Please always specify where the commit ID you mention is.

Futhermore, commits in net-next are permanent so it is not possible afterwards to "merge this patch with commit X".

#3 lore raw
Quoted 48 lines · David Miller

From: "Wangnan (F)" <[email protected]>
Date: Mon, 13 Feb 2017 09:53:49 +0800

Quoted 45 lines · Mickaël Salaün
Quoted 31 lines

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.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc David S. Miller <[email protected]>
Cc Wang Nan <[email protected]>

Link:
https://lkml.kernel.org/r/[email protected]

---
   tools/lib/bpf/bpf.c | 12 +++---------
   1 file changed, 3 insertions(+), 9 deletions(-)
tools/lib/bpf/bpf.c +3 -1
index 50e04cc5dddd..2de9c386989a 100644
@@ -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)

tools/lib/bpf/bpf.c line 55

Quoted 10 lines
tools/lib/bpf/bpf.c +0 -6
   {
-#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,
Quoted 5 lines
Quoted 2 lines

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

I don't know where this commit ID is. Since this patch is targetting net-next I would expect a commit ID with not context to be in that tree. Please always specify where the commit ID you mention is.

It is "bpf: Remove bpf_sys.h from selftests" in net-next.

Quoted 2 lines

Futhermore, commits in net-next are permanent so it is not possible afterwards to "merge this patch with commit X".

I understand. Maintainers sometime reset his/her head to an early version and amend the commit to make the history clean, but clearly net-next never do this.

Thank you.

maintainer Applied
#4 lore raw
In reply to Mickaël Salaün

From: Mickaël Salaün <[email protected]>
Date: Sat, 11 Feb 2017 20:37:08 +0100

Quoted 10 lines

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.

Applied.