bpf: syscall_nrs: disable no previous prototype warnning
PATCH v2 1/1 bpf: syscall_nrs: disable no previous prototype warnning
From: Jason Xing <[email protected]>
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.
---
v2
1. use #pragma GCC diagnostic ignored to disable warnning (Andrii Nakryiko)
--- samples/bpf/syscall_nrs.c | 5 +++++ 1 file changed, 5 insertions(+)
samples/bpf/syscall_nrs.c +5 -0
@@ -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 )
Signature · 1 line
2.37.3
Quoted 30 lines · Jason Xing
From: Jason Xing <[email protected]>
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]
voidsyscall_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 <[email protected]>---
v21. use #pragma GCC diagnostic ignored to disable warnning (Andrii Nakryiko)
--- samples/bpf/syscall_nrs.c | 5 +++++ 1 file changed, 5 insertions(+)samples/bpf/syscall_nrs.c +0
-0
samples/bpf/syscall_nrs.c line 5
Quoted 4 lines
samples/bpf/syscall_nrs.c +1
-0@@ -2,6 +2,11 @@#include <uapi/linux/unistd.h> #include <linux/kbuild.h> +#pragma GCC diagnostic push
please add matching pop as well
samples/bpf/syscall_nrs.c line 6
Quoted 1 line
samples/bpf/syscall_nrs.c +1
-0+#ifndef __clang__
I don't think you need this, clang supports this pragma as well (even though it says "GCC")
pw-bot: cr
Quoted 9 lines
samples/bpf/syscall_nrs.c +3
-1+#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#endif +#define SYSNR (_NR) DEFINE(SYS ## _NR, _NR)void syscall_defines (void ) --2.37.3
Hello Andrii,
Quoted 35 lines · Andrii Nakryiko
Quoted 33 lines · Jason Xing
From: Jason Xing <[email protected]>
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]
voidsyscall_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 <[email protected]>---
v21. use #pragma GCC diagnostic ignored to disable warnning (Andrii Nakryiko)
--- samples/bpf/syscall_nrs.c | 5 +++++ 1 file changed, 5 insertions(+)samples/bpf/syscall_nrs.c +0
-0@@ -2,6 +2,11 @@#include <uapi/linux/unistd.h> #include <linux/kbuild.h>
Quoted 8 lines
samples/bpf/syscall_nrs.c line 5
Quoted 1 line
samples/bpf/syscall_nrs.c +1
-0+#pragma GCC diagnostic pushplease add matching pop as well
samples/bpf/syscall_nrs.c line 6
Quoted 1 line
samples/bpf/syscall_nrs.c +1
-0+#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.