bpf: fix build warning - missing prototype
Subsystems (4)
PATCH 1/1 bpf: fix build warning - missing prototype
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.
--- net/bpf/test_run.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/bpf/test_run.c +6 -6
@@ -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; }
Signature · 1 line
2.25.2
Quoted 5 lines · Jean-Philippe Menil
Fix build warning when building
net/bpf/test_run.owith W=1 due to missing prototype for bpf_fentry_test{1..6}.These functions are only used in
test_run.cso 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}.
Quoted 50 lines
Signed-off-by Jean-Philippe Menil <[email protected]>--- net/bpf/test_run.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)net/bpf/test_run.c +6
-6@@ -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; }
Quoted 9 lines · Yonghong Song
Quoted 5 lines · Jean-Philippe Menil
Fix build warning when building
net/bpf/test_run.owith W=1 due to missing prototype for bpf_fentry_test{1..6}.These functions are only used in
test_run.cso just make them static. Therefore inline keyword should sit between storage class and type.
Quoted 7 lines
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).
Quoted 45 lines
Quoted 45 lines
Signed-off-by Jean-Philippe Menil <[email protected]>--- net/bpf/test_run.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)net/bpf/test_run.c +6
-6@@ -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; }
Signature · 1 line
Jean-Philippe Menil
Quoted 18 lines · Jean-Philippe Menil
Quoted 9 lines · Yonghong Song
Quoted 5 lines · Jean-Philippe Menil
Fix build warning when building
net/bpf/test_run.owith W=1 due to missing prototype for bpf_fentry_test{1..6}.These functions are only used in
test_run.cso just make them static. Therefore inline keyword should sit between storage class and type.Quoted 7 lines
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}.
Quoted 5 lines
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 52 lines
Quoted 51 lines
Quoted 51 lines
Signed-off-by Jean-Philippe Menil <[email protected]>---
net/bpf/test_run.c | 12 ++++++------1 file changed, 6 insertions(+), 6 deletions(-)net/bpf/test_run.c +0
-0@@ -113,32 +113,32 @@ static int bpf_test_finish(const union bpf_attr *kattr, * architecture dependent calling conventions. 7+ can be supportedin the
* future.
*/net/bpf/test_run.c +1
-1-int noinline bpf_fentry_test1(int a) +static noinline int bpf_fentry_test1(int a){
return a + 1;
}net/bpf/test_run.c +1
-1-int noinline bpf_fentry_test2(int a, u64 b) +static noinline int bpf_fentry_test2(int a, u64 b){
return a + b;
}net/bpf/test_run.c +1
-1-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;
}net/bpf/test_run.c +1
-1-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;
}net/bpf/test_run.c +1
-1-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 noinlinebpf_fentry_test6(u64 a, void *b, short c, int d, void *e, u64 f)
+static noinline intbpf_fentry_test6(u64 a, void *b, short c, int d, void *e, u64 f)
{
return a + (long)b + c + d + (long)e + f;
}
PATCH v2 1/1 bpf: fix build warning - missing prototype
Fix build warnings when building net/bpf/test_run.o with W=1 due to missing prototype for bpf_fentry_test{1..6}.
Declare prototypes in order to silence warnings.
--- net/bpf/test_run.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bpf/test_run.c +6 -0
@@ -113,31 +113,37 @@ 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); int noinline bpf_fentry_test1(int a) {return a +1 ; } +int noinline bpf_fentry_test2(int a, u64 b); int noinline bpf_fentry_test2(int a, u64 b) {return a + b; } +int noinline bpf_fentry_test3(char a, int b, u64 c); int noinline 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); int noinline 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); int noinline 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); int noinline bpf_fentry_test6(u64 a, void *b, short c, int d, void *e, u64 f) {return a + (long )b + c + d + (long )e + f;
Signature · 1 line
2.25.2
Quoted 6 lines · Jean-Philippe Menil
Fix build warnings when building
net/bpf/test_run.owith W=1 due to missing prototype for bpf_fentry_test{1..6}.Declare prototypes in order to silence warnings.
Signed-off-by Jean-Philippe Menil <[email protected]>
Quoted 40 lines · Jean-Philippe Menil
Fix build warnings when building
net/bpf/test_run.owith W=1 due to missing prototype for bpf_fentry_test{1..6}.Declare prototypes in order to silence warnings.
Signed-off-by Jean-Philippe Menil <[email protected]>--- net/bpf/test_run.c | 6 ++++++ 1 file changed, 6 insertions(+)net/bpf/test_run.c +4
-0@@ -113,31 +113,37 @@ 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); int noinline bpf_fentry_test1(int a) {return a +1 ; } +int noinline bpf_fentry_test2(int a, u64 b); int noinline bpf_fentry_test2(int a, u64 b) {return a + b; } +int noinline bpf_fentry_test3(char a, int b, u64 c); int noinline 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); int noinline bpf_fentry_test4(void *a, char b, int c, u64 d) {return (long )a + b + c + d;
net/bpf/test_run.c static int bpf_test_finish(const union bpf_attr *kattr, · line 147
Quoted 10 lines
net/bpf/test_run.c +2
-0} +int noinline bpf_fentry_test5(u64 a, void *b, short c, int d, u64 e); int noinline 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); int noinline bpf_fentry_test6(u64 a, void *b, short c, int d, void *e, u64 f)
That's a bit too much of "watery water".
Have you considered__diag_push();__diag_ignore(GCC, "-Wwhatever specific flag will shut up this warn") __diag_pop();
approach ?
It will be self documenting as well.
PATCH v3 1/1 bpf: fix build warning - missing prototype
Fix build warnings when building net/bpf/test_run.o with W=1 due to missing prototype for bpf_fentry_test{1..6}.
Instead of declaring prototypes, turn off warnings with __diag_{push,ignore,pop} as pointed by Alexei.
--- net/bpf/test_run.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bpf/test_run.c +5 -0
@@ -113,6 +113,9 @@ static int bpf_test_finish(const union bpf_attr *kattr,* architecture dependent calling conventions. 7+ can be supported in the * future. */ +__diag_push (); +__diag_ignore(GCC, 8, "-Wmissing-prototypes", + "Global functions as their definitions will be in vmlinux BTF); int noinline bpf_fentry_test1(int a) { return a + 1;
@@ -143,6 +146,8 @@ int noinline bpf_fentry_test6(u64 a, void *b, short c, int d, void *e, u64 f)return a + (long )b + c + d + (long )e + f; } +__diag_pop (); +static void *bpf_test_init (const union bpf_attr *kattr,u32 size,u32 headroom,u32 tailroom) {
Signature · 1 line
2.26.0
Daniel Borkmann
maintainerQuoted 7 lines · Jean-Philippe Menil
Fix build warnings when building
net/bpf/test_run.owith W=1 due to missing prototype for bpf_fentry_test{1..6}.Instead of declaring prototypes, turn off warnings with __diag_{push,ignore,pop} as pointed by Alexei.
Signed-off-by Jean-Philippe Menil <[email protected]>
Looks better, but this doesn't apply cleanly. Please respin to latest bpf-next tree, thanks.
Quoted 28 lines
--- net/bpf/test_run.c | 5 +++++ 1 file changed, 5 insertions(+)net/bpf/test_run.c +5
-0@@ -113,6 +113,9 @@ static int bpf_test_finish(const union bpf_attr *kattr,* architecture dependent calling conventions. 7+ can be supported in the * future. */ +__diag_push (); +__diag_ignore(GCC, 8, "-Wmissing-prototypes", + "Global functions as their definitions will be in vmlinux BTF); int noinline bpf_fentry_test1(int a) { return a + 1;@@ -143,6 +146,8 @@ int noinline bpf_fentry_test6(u64 a, void *b, short c, int d, void *e, u64 f)return a + (long )b + c + d + (long )e + f; } +__diag_pop (); +static void *bpf_test_init (const union bpf_attr *kattr,u32 size,u32 headroom,u32 tailroom) {
PATCH v4 1/1 bpf: fix build warning - missing prototype
Fix build warnings when building net/bpf/test_run.o with W=1 due to missing prototype for bpf_fentry_test{1..6}.
Instead of declaring prototypes, turn off warnings with __diag_{push,ignore,pop} as pointed by Alexei.
--- net/bpf/test_run.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bpf/test_run.c +5 -0
@@ -114,6 +114,9 @@ static int bpf_test_finish(const union bpf_attr *kattr,* architecture dependent calling conventions. 7+ can be supported in the * future. */ +__diag_push (); +__diag_ignore (GCC ,8 ,"-Wmissing-prototypes" , +"Global functions as their definitions will be in vmlinux BTF" ); int noinline bpf_fentry_test1(int a) {return a +1 ;
@@ -150,6 +153,8 @@ int noinline bpf_modify_return_test(int a, int *b)return a + *b; } +__diag_pop (); +ALLOW_ERROR_INJECTION (bpf_modify_return_test,ERRNO ); static void *bpf_test_init(const union bpf_attr *kattr, u32 size,
Signature · 1 line
2.26.0
Quoted 7 lines · Jean-Philippe Menil
Fix build warnings when building
net/bpf/test_run.owith W=1 due to missing prototype for bpf_fentry_test{1..6}.Instead of declaring prototypes, turn off warnings with __diag_{push,ignore,pop} as pointed by Alexei.
Signed-off-by Jean-Philippe Menil <[email protected]>
Applied, thanks!