Thread (11 messages) 11 messages, 4 authors, 2020-03-28

Re: [PATCH] bpf: fix build warning - missing prototype

From: Yonghong Song <hidden>
Date: 2020-03-23 14:52:22
Also in: bpf, kernel-janitors, lkml


On 3/23/20 12:42 AM, Jean-Philippe Menil wrote:
On 22/03/20 at 10:32pm, Yonghong Song wrote:
quoted

On 3/22/20 7:08 AM, Jean-Philippe Menil wrote:
quoted
Fix build warning when building net/bpf/test_run.o with W=1 due
to missing prototype for bpf_fentry_test{1..6}.

These functions are only used in test_run.c so just make them static.
Therefore inline keyword should sit between storage class and type.
This won't work. These functions are intentionally global functions
so that their definitions will be in vmlinux BTF and fentry/fexit kernel
selftests can run against them.

See file 
linux/tools/testing/selftests/bpf/progs/{fentry_test.c,fexit_test.c}.
I can see now, thanks for the pointer.
I totally missed that.

So, in order to fix the warnings, better to declare the prototypes?
(compiling with W=1 may be a bit unusual).
Right, you can add prototypes in the same file (test_run.c) to silence 
the warning.
quoted
quoted
Signed-off-by: Jean-Philippe Menil <redacted>
---
 net/bpf/test_run.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index d555c0d8657d..c0dcd29f682c 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -113,32 +113,32 @@ static int bpf_test_finish(const union bpf_attr 
*kattr,
  * architecture dependent calling conventions. 7+ can be supported 
in the
  * future.
  */
-int noinline bpf_fentry_test1(int a)
+static noinline int bpf_fentry_test1(int a)
 {
     return a + 1;
 }
-int noinline bpf_fentry_test2(int a, u64 b)
+static noinline int bpf_fentry_test2(int a, u64 b)
 {
     return a + b;
 }
-int noinline bpf_fentry_test3(char a, int b, u64 c)
+static noinline int bpf_fentry_test3(char a, int b, u64 c)
 {
     return a + b + c;
 }
-int noinline bpf_fentry_test4(void *a, char b, int c, u64 d)
+static noinline int bpf_fentry_test4(void *a, char b, int c, u64 d)
 {
     return (long)a + b + c + d;
 }
-int noinline bpf_fentry_test5(u64 a, void *b, short c, int d, u64 e)
+static noinline int bpf_fentry_test5(u64 a, void *b, short c, int d, 
u64 e)
 {
     return a + (long)b + c + d + e;
 }
-int noinline bpf_fentry_test6(u64 a, void *b, short c, int d, void 
*e, u64 f)
+static noinline int bpf_fentry_test6(u64 a, void *b, short c, int d, 
void *e, u64 f)
 {
     return a + (long)b + c + d + (long)e + f;
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help