BPF Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] bpf: fix build warning - missing prototype
@ 2020-03-22 14:08 Jean-Philippe Menil
  2020-03-23  5:32 ` Yonghong Song
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Philippe Menil @ 2020-03-22 14:08 UTC (permalink / raw)
  To: netdev
  Cc: kernel-janitors, jpmenil, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, bpf, linux-kernel

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.

Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
---
 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;
 }
-- 
2.25.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] bpf: fix build warning - missing prototype
  2020-03-22 14:08 [PATCH] bpf: fix build warning - missing prototype Jean-Philippe Menil
@ 2020-03-23  5:32 ` Yonghong Song
  2020-03-23  7:42   ` Jean-Philippe Menil
  0 siblings, 1 reply; 11+ messages in thread
From: Yonghong Song @ 2020-03-23  5:32 UTC (permalink / raw)
  To: Jean-Philippe Menil, netdev
  Cc: kernel-janitors, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Andrii Nakryiko, bpf, linux-kernel



On 3/22/20 7:08 AM, Jean-Philippe Menil wrote:
> 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}.

> 
> Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
> ---
>   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;
>   }
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] bpf: fix build warning - missing prototype
  2020-03-23  5:32 ` Yonghong Song
@ 2020-03-23  7:42   ` Jean-Philippe Menil
  2020-03-23 14:52     ` Yonghong Song
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Philippe Menil @ 2020-03-23  7:42 UTC (permalink / raw)
  To: Yonghong Song
  Cc: netdev, kernel-janitors, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Andrii Nakryiko, bpf, linux-kernel

On 22/03/20 at 10:32pm, Yonghong Song wrote:
>
>
>On 3/22/20 7:08 AM, Jean-Philippe Menil wrote:
>>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).

>>
>>Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
>>---
>>  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;
>>  }
>>

-- 
Jean-Philippe Menil

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] bpf: fix build warning - missing prototype
  2020-03-23  7:42   ` Jean-Philippe Menil
@ 2020-03-23 14:52     ` Yonghong Song
  2020-03-24  7:22       ` [PATCH v2] " Jean-Philippe Menil
  0 siblings, 1 reply; 11+ messages in thread
From: Yonghong Song @ 2020-03-23 14:52 UTC (permalink / raw)
  To: Jean-Philippe Menil
  Cc: netdev, kernel-janitors, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Andrii Nakryiko, bpf, linux-kernel



On 3/23/20 12:42 AM, Jean-Philippe Menil wrote:
> On 22/03/20 at 10:32pm, Yonghong Song wrote:
>>
>>
>> On 3/22/20 7:08 AM, Jean-Philippe Menil wrote:
>>> 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.

> 
>>>
>>> Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
>>> ---
>>>  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;
>>>  }
>>>
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] bpf: fix build warning - missing prototype
  2020-03-23 14:52     ` Yonghong Song
@ 2020-03-24  7:22       ` " Jean-Philippe Menil
  2020-03-24 16:19         ` Yonghong Song
  2020-03-26 23:54         ` Alexei Starovoitov
  0 siblings, 2 replies; 11+ messages in thread
From: Jean-Philippe Menil @ 2020-03-24  7:22 UTC (permalink / raw)
  To: yhs
  Cc: kernel-janitors, jpmenil, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Andrii Nakryiko, netdev, bpf, linux-kernel

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.

Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
---
 net/bpf/test_run.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index d555c0d8657d..cdf87fb0b6eb 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -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;
-- 
2.25.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] bpf: fix build warning - missing prototype
  2020-03-24  7:22       ` [PATCH v2] " Jean-Philippe Menil
@ 2020-03-24 16:19         ` Yonghong Song
  2020-03-26 23:54         ` Alexei Starovoitov
  1 sibling, 0 replies; 11+ messages in thread
From: Yonghong Song @ 2020-03-24 16:19 UTC (permalink / raw)
  To: Jean-Philippe Menil
  Cc: kernel-janitors, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Andrii Nakryiko, netdev, bpf, linux-kernel



On 3/24/20 12:22 AM, Jean-Philippe Menil wrote:
> 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.
> 
> Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>

Acked-by: Yonghong Song <yhs@fb.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] bpf: fix build warning - missing prototype
  2020-03-24  7:22       ` [PATCH v2] " Jean-Philippe Menil
  2020-03-24 16:19         ` Yonghong Song
@ 2020-03-26 23:54         ` Alexei Starovoitov
  2020-03-27  7:55           ` [PATCH v3] " Jean-Philippe Menil
  1 sibling, 1 reply; 11+ messages in thread
From: Alexei Starovoitov @ 2020-03-26 23:54 UTC (permalink / raw)
  To: Jean-Philippe Menil
  Cc: yhs, kernel-janitors, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Andrii Nakryiko, netdev, bpf, linux-kernel

On Tue, Mar 24, 2020 at 08:22:31AM +0100, Jean-Philippe Menil wrote:
> 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.
> 
> Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
> ---
>  net/bpf/test_run.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index d555c0d8657d..cdf87fb0b6eb 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -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)

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3] bpf: fix build warning - missing prototype
  2020-03-26 23:54         ` Alexei Starovoitov
@ 2020-03-27  7:55           ` " Jean-Philippe Menil
  2020-03-27 20:34             ` Daniel Borkmann
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Philippe Menil @ 2020-03-27  7:55 UTC (permalink / raw)
  To: alexei.starovoitov
  Cc: kernel-janitors, jpmenil, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, netdev, bpf, linux-kernel

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.

Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
---
 net/bpf/test_run.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index d555c0d8657d..cc1592413fc3 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -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)
 {
-- 
2.26.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] bpf: fix build warning - missing prototype
  2020-03-27  7:55           ` [PATCH v3] " Jean-Philippe Menil
@ 2020-03-27 20:34             ` Daniel Borkmann
  2020-03-27 20:47               ` [PATCH v4] " Jean-Philippe Menil
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Borkmann @ 2020-03-27 20:34 UTC (permalink / raw)
  To: Jean-Philippe Menil, alexei.starovoitov
  Cc: kernel-janitors, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Martin KaFai Lau, Song Liu, Yonghong Song,
	Andrii Nakryiko, netdev, bpf, linux-kernel

On 3/27/20 8:55 AM, Jean-Philippe Menil wrote:
> 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.
> 
> Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>

Looks better, but this doesn't apply cleanly. Please respin to latest bpf-next tree, thanks.

> ---
>   net/bpf/test_run.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index d555c0d8657d..cc1592413fc3 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -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)
>   {
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v4] bpf: fix build warning - missing prototype
  2020-03-27 20:34             ` Daniel Borkmann
@ 2020-03-27 20:47               ` " Jean-Philippe Menil
  2020-03-28 17:15                 ` Daniel Borkmann
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Philippe Menil @ 2020-03-27 20:47 UTC (permalink / raw)
  To: daniel
  Cc: kernel-janitors, jpmenil, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Martin KaFai Lau, Song Liu, Yonghong Song,
	Andrii Nakryiko, netdev, bpf, linux-kernel

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.

Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>
---
 net/bpf/test_run.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index 4c921f5154e0..73e703895343 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -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,
-- 
2.26.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4] bpf: fix build warning - missing prototype
  2020-03-27 20:47               ` [PATCH v4] " Jean-Philippe Menil
@ 2020-03-28 17:15                 ` Daniel Borkmann
  0 siblings, 0 replies; 11+ messages in thread
From: Daniel Borkmann @ 2020-03-28 17:15 UTC (permalink / raw)
  To: Jean-Philippe Menil
  Cc: kernel-janitors, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, Martin KaFai Lau, Song Liu, Yonghong Song,
	Andrii Nakryiko, netdev, bpf, linux-kernel

On 3/27/20 9:47 PM, Jean-Philippe Menil wrote:
> 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.
> 
> Signed-off-by: Jean-Philippe Menil <jpmenil@gmail.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, back to index

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-22 14:08 [PATCH] bpf: fix build warning - missing prototype Jean-Philippe Menil
2020-03-23  5:32 ` Yonghong Song
2020-03-23  7:42   ` Jean-Philippe Menil
2020-03-23 14:52     ` Yonghong Song
2020-03-24  7:22       ` [PATCH v2] " Jean-Philippe Menil
2020-03-24 16:19         ` Yonghong Song
2020-03-26 23:54         ` Alexei Starovoitov
2020-03-27  7:55           ` [PATCH v3] " Jean-Philippe Menil
2020-03-27 20:34             ` Daniel Borkmann
2020-03-27 20:47               ` [PATCH v4] " Jean-Philippe Menil
2020-03-28 17:15                 ` Daniel Borkmann

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
		bpf@vger.kernel.org
	public-inbox-index bpf

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.bpf


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git