Skip to contentSkip to conversation

bpf: syscall_nrs: fix no previous prototype for "syscall_defines"

PATCH In review Jason Xing 3 participants 8 messages Sep 19, 2024 – Oct 1, 2024 BPF

lore
Share & tools
lore

Jason Xing

author
#0 lore raw

PATCH 1/1 bpf: syscall_nrs: fix no previous prototype for "syscall_defines"

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)

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

---
I'm not sure which tree I should target, sorry about that.

---
 samples/bpf/syscall_nrs.c | 2 ++
 1 file changed, 2 insertions(+)
samples/bpf/syscall_nrs.c +2 -0
index 88f940052450..5f40a29034b6 100644
@@ -4,6 +4,8 @@
 
 #define SYSNR(_NR) DEFINE(SYS ## _NR, _NR)
 
+void syscall_defines(void);
+
 void syscall_defines(void)
 {
 	COMMENT("Linux system call numbers.");
Signature · 1 line
2.37.3
#1 lore raw
Quoted 11 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)

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

samples/bpf/ doesn't accept patches any more.
If this samples/test is useful, refactor it to the test_progs framework. Otherwise delete it.

pw-bot: cr

author
#2 lore raw
Quoted 9 lines · Alexei Starovoitov
Quoted 7 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:

Quoted 6 lines
Quoted 4 lines

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

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

samples/bpf/ doesn't accept patches any more.

Thanks for your reminder. I didn't know that.

Quoted 2 lines

If this samples/test is useful, refactor it to the test_progs framework. Otherwise delete it.

I'm trying to use the samples/test to do some tests to verify if some functions like bpf_sock_ops_cb_flags_set() can work. Then I encountered the issue as this patch said.

author
#3 lore raw
In reply to Alexei Starovoitov
Quoted 14 lines · Alexei Starovoitov
Quoted 11 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 5 lines

samples/bpf/ doesn't accept patches any more.
If this samples/test is useful, refactor it to the test_progs framework. Otherwise delete it.

pw-bot: cr

After reconsidering what Alexei said, I still feel we could take this patch? It is because:
1) the patch itself is more of a fix instead of optimization, 2)as long as samples/bpf exists in the kernel, we cannot easily let it(issues) go and ignore it.

Applying such a patch won't cause any further confusion, right? As we can see, it's like a fix which does not introduce anything new here.

What do you bpf maintainers think?

Thanks,
Jason

#4 lore raw
Quoted 29 lines · Jason Xing
Quoted 14 lines · Alexei Starovoitov
Quoted 11 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 5 lines

samples/bpf/ doesn't accept patches any more.
If this samples/test is useful, refactor it to the test_progs framework. Otherwise delete it.

pw-bot: cr

After reconsidering what Alexei said, I still feel we could take this patch? It is because:
1) the patch itself is more of a fix instead of optimization, 2)as long as samples/bpf exists in the kernel, we cannot easily let it(issues) go and ignore it.

Quoted 4 lines

Applying such a patch won't cause any further confusion, right? As we can see, it's like a fix which does not introduce anything new here.

What do you bpf maintainers think?

I think it's fine to minimally fix the issue in samples/bpf, but I don't think this weirdly-looking extra declaration is the best fix.

Can you mark that function static? Will that work? Or, as a plan B, use pragma to disable this warning, it's clearly "expected" in this case.

Quoted 3 lines

Thanks,
Jason

author
#5 lore raw

Hello Andrii,

Quoted 31 lines · Andrii Nakryiko
Quoted 29 lines · Jason Xing
Quoted 14 lines · Alexei Starovoitov
Quoted 11 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 5 lines

samples/bpf/ doesn't accept patches any more.
If this samples/test is useful, refactor it to the test_progs framework. Otherwise delete it.

pw-bot: cr

After reconsidering what Alexei said, I still feel we could take this patch? It is because:
1) the patch itself is more of a fix instead of optimization, 2)as long as samples/bpf exists in the kernel, we cannot easily let it(issues) go and ignore it.

Quoted 7 lines
Quoted 4 lines

Applying such a patch won't cause any further confusion, right? As we can see, it's like a fix which does not introduce anything new here.

What do you bpf maintainers think?

I think it's fine to minimally fix the issue in samples/bpf, but I don't think this weirdly-looking extra declaration is the best fix.

Thanks for your reply.

Quoted 2 lines

Can you mark that function static? Will that work?

Not really, it will print:
samples/bpf/syscall_nrs.c:7:13: error: ‘syscall_defines’ defined but not used [-Werror=unused-function]
static void syscall_defines(void)

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

cc1: all warnings being treated as errors

Quoted 3 lines

Or, as a plan B,
use pragma to disable this warning, it's clearly "expected" in this case.

Yes, I admit the use in this function is "expected" like you said because this file will be converted into a .h file. Could you kindly show me more hints on how to disable the warning when compiling? I tried to remove something like "-Wmissing-prototypes", but the warning still happens.

Thanks,
Jason

#6 lore raw
Quoted 60 lines · Jason Xing

Hello Andrii,

Quoted 31 lines · Andrii Nakryiko
Quoted 29 lines · Jason Xing
Quoted 14 lines · Alexei Starovoitov
Quoted 11 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 5 lines

samples/bpf/ doesn't accept patches any more.
If this samples/test is useful, refactor it to the test_progs framework. Otherwise delete it.

pw-bot: cr

After reconsidering what Alexei said, I still feel we could take this patch? It is because:
1) the patch itself is more of a fix instead of optimization, 2)as long as samples/bpf exists in the kernel, we cannot easily let it(issues) go and ignore it.

Quoted 7 lines
Quoted 4 lines

Applying such a patch won't cause any further confusion, right? As we can see, it's like a fix which does not introduce anything new here.

What do you bpf maintainers think?

I think it's fine to minimally fix the issue in samples/bpf, but I don't think this weirdly-looking extra declaration is the best fix.

Thanks for your reply.

Quoted 2 lines

Can you mark that function static? Will that work?

Not really, it will print:
samples/bpf/syscall_nrs.c:7:13: error: ‘syscall_defines’ defined but not used [-Werror=unused-function]
static void syscall_defines(void)

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

cc1: all warnings being treated as errors

Quoted 3 lines

Or, as a plan B,
use pragma to disable this warning, it's clearly "expected" in this case.

Quoted 6 lines

Yes, I admit the use in this function is "expected" like you said because this file will be converted into a .h file. Could you kindly show me more hints on how to disable the warning when compiling? I tried to remove something like "-Wmissing-prototypes", but the warning still happens.

Grep for "#pragma GCC diagnostic ignored" uses in kernel sources.

Quoted 2 lines

Thanks,
Jason

author
#7 lore raw
Quoted 62 lines · Andrii Nakryiko
Quoted 60 lines · Jason Xing

Hello Andrii,

Quoted 31 lines · Andrii Nakryiko
Quoted 29 lines · Jason Xing
Quoted 14 lines · Alexei Starovoitov
Quoted 11 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 5 lines

samples/bpf/ doesn't accept patches any more.
If this samples/test is useful, refactor it to the test_progs framework. Otherwise delete it.

pw-bot: cr

After reconsidering what Alexei said, I still feel we could take this patch? It is because:
1) the patch itself is more of a fix instead of optimization, 2)as long as samples/bpf exists in the kernel, we cannot easily let it(issues) go and ignore it.

Quoted 7 lines
Quoted 4 lines

Applying such a patch won't cause any further confusion, right? As we can see, it's like a fix which does not introduce anything new here.

What do you bpf maintainers think?

I think it's fine to minimally fix the issue in samples/bpf, but I don't think this weirdly-looking extra declaration is the best fix.

Thanks for your reply.

Quoted 2 lines

Can you mark that function static? Will that work?

Not really, it will print:
samples/bpf/syscall_nrs.c:7:13: error: ‘syscall_defines’ defined but not used [-Werror=unused-function]
static void syscall_defines(void)

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

cc1: all warnings being treated as errors

Quoted 3 lines

Or, as a plan B,
use pragma to disable this warning, it's clearly "expected" in this case.

Quoted 8 lines
Quoted 6 lines

Yes, I admit the use in this function is "expected" like you said because this file will be converted into a .h file. Could you kindly show me more hints on how to disable the warning when compiling? I tried to remove something like "-Wmissing-prototypes", but the warning still happens.

Grep for "#pragma GCC diagnostic ignored" uses in kernel sources.

Thanks a lot! It works. Let me re-post it to "fix" this issue.

Thanks,
Jason