BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v2] bpf: syscall_nrs: disable no previous prototype warnning
@ 2024-10-01  1:25 Jason Xing
  2024-10-01 17:14 ` Andrii Nakryiko
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Xing @ 2024-10-01  1:25 UTC (permalink / raw)
  To: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa
  Cc: bpf, andrii.nakryiko, Jason Xing

From: Jason Xing <kernelxing@tencent.com>

In some environments (gcc treated as error in W=1, which is default), if we
make -C samples/bpf/, it will be stopped because of
"no previous prototype" error like this:

  ../samples/bpf/syscall_nrs.c:7:6:
  error: no previous prototype for ‘syscall_defines’ [-Werror=missing-prototypes]
   void syscall_defines(void)
        ^~~~~~~~~~~~~~~

Actually, this file meets our expectatations because it will be converted to
a .h file. In this way, it's correct. Considering the warnning stopping us
compiling, we can remove the warnning directly.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
v2
Link: https://lore.kernel.org/all/CAEf4BzaVdr_0kQo=+jPLN++PvcU6pwTjaPVEA880kgDN94TZYw@mail.gmail.com/
1. use #pragma GCC diagnostic ignored to disable warnning (Andrii Nakryiko)
---
 samples/bpf/syscall_nrs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/samples/bpf/syscall_nrs.c b/samples/bpf/syscall_nrs.c
index 88f940052450..8f6ae21d358f 100644
--- a/samples/bpf/syscall_nrs.c
+++ b/samples/bpf/syscall_nrs.c
@@ -2,6 +2,11 @@
 #include <uapi/linux/unistd.h>
 #include <linux/kbuild.h>
 
+#pragma GCC diagnostic push
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#endif
+
 #define SYSNR(_NR) DEFINE(SYS ## _NR, _NR)
 
 void syscall_defines(void)
-- 
2.37.3


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

* Re: [PATCH bpf-next v2] bpf: syscall_nrs: disable no previous prototype warnning
  2024-10-01  1:25 [PATCH bpf-next v2] bpf: syscall_nrs: disable no previous prototype warnning Jason Xing
@ 2024-10-01 17:14 ` Andrii Nakryiko
  2024-10-01 23:25   ` Jason Xing
  0 siblings, 1 reply; 3+ messages in thread
From: Andrii Nakryiko @ 2024-10-01 17:14 UTC (permalink / raw)
  To: Jason Xing
  Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf, Jason Xing

On Mon, Sep 30, 2024 at 6:25 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> From: Jason Xing <kernelxing@tencent.com>
>
> In some environments (gcc treated as error in W=1, which is default), if we
> make -C samples/bpf/, it will be stopped because of
> "no previous prototype" error like this:
>
>   ../samples/bpf/syscall_nrs.c:7:6:
>   error: no previous prototype for ‘syscall_defines’ [-Werror=missing-prototypes]
>    void syscall_defines(void)
>         ^~~~~~~~~~~~~~~
>
> Actually, this file meets our expectatations because it will be converted to
> a .h file. In this way, it's correct. Considering the warnning stopping us
> compiling, we can remove the warnning directly.
>
> Signed-off-by: Jason Xing <kernelxing@tencent.com>
> ---
> v2
> Link: https://lore.kernel.org/all/CAEf4BzaVdr_0kQo=+jPLN++PvcU6pwTjaPVEA880kgDN94TZYw@mail.gmail.com/
> 1. use #pragma GCC diagnostic ignored to disable warnning (Andrii Nakryiko)
> ---
>  samples/bpf/syscall_nrs.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/samples/bpf/syscall_nrs.c b/samples/bpf/syscall_nrs.c
> index 88f940052450..8f6ae21d358f 100644
> --- a/samples/bpf/syscall_nrs.c
> +++ b/samples/bpf/syscall_nrs.c
> @@ -2,6 +2,11 @@
>  #include <uapi/linux/unistd.h>
>  #include <linux/kbuild.h>
>
> +#pragma GCC diagnostic push

please add matching pop as well

> +#ifndef __clang__

I don't think you need this, clang supports this pragma as well (even
though it says "GCC")

pw-bot: cr

> +#pragma GCC diagnostic ignored "-Wmissing-prototypes"
> +#endif
> +
>  #define SYSNR(_NR) DEFINE(SYS ## _NR, _NR)
>
>  void syscall_defines(void)
> --
> 2.37.3
>

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

* Re: [PATCH bpf-next v2] bpf: syscall_nrs: disable no previous prototype warnning
  2024-10-01 17:14 ` Andrii Nakryiko
@ 2024-10-01 23:25   ` Jason Xing
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Xing @ 2024-10-01 23:25 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf, Jason Xing

Hello Andrii,

On Wed, Oct 2, 2024 at 1:15 AM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Mon, Sep 30, 2024 at 6:25 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
> >
> > From: Jason Xing <kernelxing@tencent.com>
> >
> > In some environments (gcc treated as error in W=1, which is default), if we
> > make -C samples/bpf/, it will be stopped because of
> > "no previous prototype" error like this:
> >
> >   ../samples/bpf/syscall_nrs.c:7:6:
> >   error: no previous prototype for ‘syscall_defines’ [-Werror=missing-prototypes]
> >    void syscall_defines(void)
> >         ^~~~~~~~~~~~~~~
> >
> > Actually, this file meets our expectatations because it will be converted to
> > a .h file. In this way, it's correct. Considering the warnning stopping us
> > compiling, we can remove the warnning directly.
> >
> > Signed-off-by: Jason Xing <kernelxing@tencent.com>
> > ---
> > v2
> > Link: https://lore.kernel.org/all/CAEf4BzaVdr_0kQo=+jPLN++PvcU6pwTjaPVEA880kgDN94TZYw@mail.gmail.com/
> > 1. use #pragma GCC diagnostic ignored to disable warnning (Andrii Nakryiko)
> > ---
> >  samples/bpf/syscall_nrs.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/samples/bpf/syscall_nrs.c b/samples/bpf/syscall_nrs.c
> > index 88f940052450..8f6ae21d358f 100644
> > --- a/samples/bpf/syscall_nrs.c
> > +++ b/samples/bpf/syscall_nrs.c
> > @@ -2,6 +2,11 @@
> >  #include <uapi/linux/unistd.h>
> >  #include <linux/kbuild.h>
> >
> > +#pragma GCC diagnostic push
>
> please add matching pop as well
>
> > +#ifndef __clang__
>
> I don't think you need this, clang supports this pragma as well (even
> though it says "GCC")

Thanks for your review. I will fix those two in the next version.

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

end of thread, other threads:[~2024-10-01 23:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-01  1:25 [PATCH bpf-next v2] bpf: syscall_nrs: disable no previous prototype warnning Jason Xing
2024-10-01 17:14 ` Andrii Nakryiko
2024-10-01 23:25   ` Jason Xing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox