Skip to contentSkip to conversation

bpf: syscall_nrs: disable no previous prototype warnning

PATCH Applied Jason Xing 2 participants 3 messages Oct 1, 2024 – Oct 8, 2024 BPF

lore
Share & tools
lore

Jason Xing

author
#0 lore raw

PATCH v3 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.

---
v3

1. remove clang check (Andrii)
2. add matching pop at the bottom of that file (Andrii)

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..a6e600f3d477 100644
@@ -2,6 +2,9 @@
 #include <uapi/linux/unistd.h>
 #include <linux/kbuild.h>
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+
 #define SYSNR(_NR) DEFINE(SYS ## _NR, _NR)
 
 void syscall_defines(void)
@@ -17,3 +20,5 @@ void syscall_defines(void)
 #endif
 
 }
+
+#pragma GCC diagnostic pop
Signature · 1 line
2.37.3
author
#1 lore raw
Quoted 10 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)

Quoted 7 lines
        ^~~~~~~~~~~~~~~

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.

Hello Andrii,

Could you help me review this version?

Thanks,
Jason

#2 lore raw
In reply to Jason Xing
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 6 lines · On Wed, 2 Oct 2024 07:32:42 +0800 you wrote:

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:

Quoted 6 lines

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

        ^~~~~~~~~~~~~~~

[...]

Here is the summary with links:
- [bpf-next,v3] bpf: syscall_nrs: disable no previous prototype warnning

    https://git.kernel.org/bpf/bpf-next/c/c50fc1cbfd71

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html