Skip to contentSkip to conversation

bpf: syscall_nrs: disable no previous prototype warnning

PATCH Superseded Jason Xing 2 participants 3 messages Oct 1, 2024 BPF

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jason Xing

author
#0 lore raw

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
index 88f940052450..8f6ae21d358f 100644
@@ -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
#1 lore raw
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]
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 +0 -0
index 88f940052450..8f6ae21d358f 100644

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

author
#2 lore raw

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]
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 +0 -0
index 88f940052450..8f6ae21d358f 100644
@@ -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 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")

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