kernel/bounds: Provide prototype for foo
Subsystems (2)
PATCH 1/1 kernel/bounds: Provide prototype for foo
kernel/bounds.c is recompiled on every build, and shows the following warning when compiling with W=1:
CC kernel/bounds.slinux/kernel/bounds.c:16:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
void foo(void)
^~~
Provide a prototype to satisfy the compiler.
---
I compile all of my incremental builds with W=1, which allows me to know instantly if I add a new compiler warning in code I generate.
This warning always comes up and seems trivial to clean up.
--- kernel/bounds.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/bounds.c +2 -0
@@ -13,6 +13,8 @@#include <linux/log2.h> #include <linux/spinlock_types.h> +void foo (void ); +void foo (void ) {/* The enum constants to put into include/generated/bounds.h */
Signature · 1 line
2.17.1
Greg Kroah-Hartman
maintainerQuoted 2 lines · Kieran Bingham
kernel/bounds.cis recompiled on every build, and shows the following warning when compiling with W=1:
Don't do that, you will get a lot of warnings that really don't make much sense. Like this one :)
Quoted 25 lines
CC
kernel/bounds.slinux/kernel/bounds.c:16:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
void foo(void)^~~Provide a prototype to satisfy the compiler.
Signed-off-by Kieran Bingham <[email protected]>---
I compile all of my incremental builds with W=1, which allows me to know instantly if I add a new compiler warning in code I generate.This warning always comes up and seems trivial to clean up.
--- kernel/bounds.c | 2 ++ 1 file changed, 2 insertions(+)kernel/bounds.c +0
-0
kernel/bounds.c line 18
Quoted 6 lines
kernel/bounds.c +2
-0@@ -13,6 +13,8 @@#include <linux/log2.h> #include <linux/spinlock_types.h> +void foo (void ); +void foo (void )
This file is a userspace tool that is used to later generate the include/generated/bounds.h file.
If you really want to track this down and fix it properly, put the prototype in the .c file that ends up calling this function. That's a fun task to dig through the build system to find :)
good luck!
greg k-h
Hi Greg,
Thank you for quick response!
Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Kieran Bingham
kernel/bounds.cis recompiled on every build, and shows the following warning when compiling with W=1:
So it turns out after a bit more checking that my statement above was a small lie :)
My local build scripts were *causing* kernel/bounds.s to be rebuilt on every build, which is why this stood out to me - because of two competing compiles for the kernel image, and the dtb.
One with W=1 and the other without... (kbuild detected different flags, and thus rebuilt the common objects)
And that's why I saw this warning on every build... and thought this was a hot-path.
Quoted 2 lines
Don't do that, you will get a lot of warnings that really don't make much sense. Like this one :)
I know - but I can ignore all on my first build, then on incremental builds where only files I change are compiled - it's much quieter :)
I see it as a benefit to compile *my* code with a higher warning level, to prevent /me/ adding further warnings.
I realise of course this patch is just pandering to the compiler to shut it up, as this is essentially an 'unused' dummy function from it's perspective.
But in this instance, it's because the output is being compiled to an assembly output (kernel/bounds.s) which is then later parsed, so there isn't anywhere else to define the prototype, and the object code is only referenced from the assembly output.
Quoted 28 lines
Quoted 28 lines
CC
kernel/bounds.slinux/kernel/bounds.c:16:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
void foo(void)^~~Provide a prototype to satisfy the compiler.
Signed-off-by Kieran Bingham <[email protected]>---
I compile all of my incremental builds with W=1, which allows me to know instantly if I add a new compiler warning in code I generate.This warning always comes up and seems trivial to clean up.
--- kernel/bounds.c | 2 ++ 1 file changed, 2 insertions(+)kernel/bounds.c +0
-0@@ -13,6 +13,8 @@#include <linux/log2.h> #include <linux/spinlock_types.h>
Quoted 6 lines
kernel/bounds.c line 18
Quoted 3 lines
kernel/bounds.c +2
-0+void foo (void ); +void foo (void )This file is a userspace tool that is used to later generate the
include/generated/bounds.hfile.
Well more accurately it is a file compiled directly to assembly which is then later parsed to help generate the bounds.h file. It's not itself a userspace tool, nothing executes this code...
It's just a compilation object to allow utilisation of the preprocessor and compiler in ways that couldn't be done otherwise as far as I understand it.
Quoted 3 lines
If you really want to track this down and fix it properly, put the prototype in the .c file that ends up calling this function. That's a fun task to dig through the build system to find :)
This is the only location.
The compilation output from V=1 (https://paste.debian.net/1043598/ for the full output) shows the command generating this warning as:
(with many flags redacted for readability)
aarch64-linux-gnu-gcc -Wp,-MD,kernel/.bounds.s.d -nostdinc -Wall -Wstrict-prototypes -DKBUILD_BASENAME='"bounds"' -DKBUILD_MODNAME='"bounds"' -fverbose-asm -S -o kernel/bounds.s kernel/bounds.c
I still feel this patch has 'some' merit with the inaccurate leading statement regarding this being output on every build removed from the commit log.
What do you think ?
Worth a v2 with commit message fixed?
Or should I just drop this ?
Quoted 3 lines
good luck!
greg k-h
--
Cheers
Kieran
Quoted 3 lines · Kieran Bingham
Hi Greg,
Thank you for quick response!
Ahem; s/for quick/for your quick/
I hate re-reading mails after I hit send and spotting things like this. Sigh :-)
Regards
--
Kieran
PATCH 1/1 kbuild: fix kernel/bounds.c 'W=1' warning
In reply to Kieran BinghamBuilding any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]
When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
---
I have run into this problem several times before, and thought I had sent a fix at some point. Looking in the archives, I came across the suggested fix from Kieran, so I'm following up on that here.
--- kernel/bounds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/bounds.c +3 -1
@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +int main (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);
@@ -23,4 +23,6 @@ void foo(void)#endif DEFINE (SPINLOCK_SIZE ,sizeof (spinlock_t));/* End of constants */ + +return 0 ; }
Signature · 1 line
2.18.0
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
Hi Arnd,
Quoted 4 lines · Arnd Bergmann
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]
s/warnign/warning/ but I don't think that's too important :D
Quoted 6 lines
When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
Aha - even better! (and annoyingly fairly obvious, from the Why-didn't-I-think-of-that department).
Quoted 3 lines
Reported-by Kieran Bingham <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>
Quoted 29 lines
---
I have run into this problem several times before, and thought I had sent a fix at some point. Looking in the archives, I came across the suggested fix from Kieran, so I'm following up on that here.--- kernel/bounds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/bounds.c +3
-1@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +int main (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);@@ -23,4 +23,6 @@ void foo(void)#endif DEFINE (SPINLOCK_SIZE ,sizeof (spinlock_t));/* End of constants */ + +return 0 ; }
RE: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
In reply to Arnd BergmannFrom: Arnd Bergmann
Quoted 4 lines
Sent: 05 October 2018 09:33
Building any configuration with 'make W=1' produces a warning:
Quoted 8 lines
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
Ugg.main() might be special in other ways too.
It wouldn't surprise me if some linkers don't do special stuff for it.
What is wrong with just putting and extra "void foo(void);" before the function?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
Quoted 15 lines · David Laight
From: Arnd Bergmann
Quoted 4 lines
Sent: 05 October 2018 09:33
Building any configuration with 'make W=1' produces a warning:
Quoted 8 lines
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
Quoted 6 lines
Ugg.
main()might be special in other ways too.
It wouldn't surprise me if some linkers don't do special stuff for it.What is wrong with just putting and extra "void foo(void);" before the function?
Greg objected to that on the basis that we don't want declarations in .c files -- they should be in a shared header:
https://lkml.org/lkml/2018/9/21/735
I don't see what could go wrong here with calling it main(), after all we are just interested in the assembler output, not even creating an object file.
Arnd
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · David Laight
From: Arnd Bergmann
Quoted 10 lines
Sent: 05 October 2018 09:33
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
Ugg.
main()might be special in other ways too.
It wouldn't surprise me if some linkers don't do special stuff for it.
I worried about this but didn't think it would be too much of an issue. But perhaps we should check...
<compile bounds.s in both configurations> as bounds.s.foo and bounds.s.main:
diff -Nurp bounds.s.*
bounds.s.main 2018-10-05 10:20:31.375891260 +0100 renamed from bounds.s.foo 2018-10-05 10:20:53.269941404 +0100 +7 -5
@@ -108,11 +108,12 @@ .global _mcount #NO_APP + .section .text.startup,"ax",@progbits .align 2 .p2align 3,,7 - .global foo - .type foo, %function -foo: + .global main + .type main, %function +main: stp x29, x30, [sp, -16]! //,,, add x29, sp, 0 //,, // /home/linuxembedded/iob/renesas/vsp1/sources/linux/kernel/bounds.c:17: {
@@ -139,10 +140,11 @@ foo: .ascii "->SPINLOCK_SIZE 56 sizeof(spinlock_t)" // // 0 "" 2 -// /home/linuxembedded/iob/renesas/vsp1/sources/linux/kernel/bounds.c:26: } +// /home/linuxembedded/iob/renesas/vsp1/sources/linux/kernel/bounds.c:28: } #NO_APP + mov w0, 0 //, ldp x29, x30, [sp], 16 //,,, ret - .size foo, .-foo + .size main, .-main .ident "GCC: (Ubuntu/Linaro 7.3.0-16ubuntu3) 7.3.0" .section .note.GNU-stack,"",@progbits
compiled with aarch64-linux-gnu-gcc, and with no debug enabled.
Other than the entry point rename (and section name) and the return value being added, I can't see anything problematic here.
And as far as I know - this file gets processed after to extract definitions which should be independent. This file is not executed or further compiled as far as I am aware.
--
Kieran
Quoted 15 lines
Quoted 3 lines
What is wrong with just putting and extra "void foo(void);" before the function?
Greg objected to that on the basis that we don't want declarations in .c files -- they should be in a shared header:
https://lkml.org/lkml/2018/9/21/735
I don't see what could go wrong here with calling it
main(), after all we are just interested in the assembler output, not even creating an object file.Arnd
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
In reply to Arnd BergmannQuoted 9 lines · Arnd Bergmann
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Quoted 7 lines
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
Reported-by Kieran Bingham <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>---
Applied to kbuild/fixes
with 's/warnign/warning/'
Thanks!
Quoted 30 lines
I have run into this problem several times before, and thought I had sent a fix at some point. Looking in the archives, I came across the suggested fix from Kieran, so I'm following up on that here.
--- kernel/bounds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/bounds.c +3
-2@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +int main (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);@@ -23,4 +23,6 @@ void foo(void)#endif DEFINE (SPINLOCK_SIZE ,sizeof (spinlock_t));/* End of constants */ + +return 0 ; } --2.18.0
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
In reply to Arnd BergmannQuoted 11 lines · Arnd Bergmann
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
I think marking the function as static __used should do the trick and would be less confusing.
Cheers,
Miguel
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
Hi Miguel,
Quoted 11 lines · Miguel Ojeda
Quoted 9 lines · Arnd Bergmann
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Quoted 5 lines
Quoted 2 lines
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
I think marking the function as static
__usedshould do the trick and would be less confusing.
I tried __used, but I still see the warning.
masahiro@grover:~/ref/linux$ git diff
kernel/bounds.c +1 -1
@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +void __used foo (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);
masahiro@grover:~/ref/linux$ make W=1 prepare
CC kernel/bounds.s
kernel/bounds.c:16:13: warning: no previous prototype for ‘foo’
[-Wmissing-prototypes]
void __used foo(void)
^
CC arch/x86/kernel/asm-offsets.sSignature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
Quoted 43 lines · Masahiro Yamada
Hi Miguel,
Quoted 11 lines · Miguel Ojeda
Quoted 9 lines · Arnd Bergmann
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Quoted 5 lines
Quoted 2 lines
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
I think marking the function as static
__usedshould do the trick and would be less confusing.I tried
__used, but I still see the warning.masahiro@grover:~/ref/linux$ git diffkernel/bounds.c +1
-1@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +void __used foo (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);
Quoted 7 lines
masahiro@grover:~/ref/linux$ make W=1 prepare
CC kernel/bounds.s
kernel/bounds.c:16:13: warning: no previous prototype for ‘foo’
[-Wmissing-prototypes]
void __used foo(void)
^
CC arch/x86/kernel/asm-offsets.sSorry, I forgot to add 'static'.
Adding both static and __used worked for me,
and I like the idea.
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
Quoted 57 lines · Masahiro Yamada
Quoted 43 lines · Masahiro Yamada
Hi Miguel,
Quoted 11 lines · Miguel Ojeda
Quoted 9 lines · Arnd Bergmann
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Quoted 5 lines
Quoted 2 lines
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
I think marking the function as static
__usedshould do the trick and would be less confusing.I tried
__used, but I still see the warning.masahiro@grover:~/ref/linux$ git diffkernel/bounds.c +1
-1@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +void __used foo (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);Quoted 7 lines
masahiro@grover:~/ref/linux$ make W=1 prepare CC kernel/bounds.s kernel/bounds.c:16:13: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes] void __used foo(void) ^ CC arch/x86/kernel/asm-offsets.sSorry, I forgot to add 'static'.
Quoted 3 lines
Adding both static and
__usedworked for me,
and I like the idea.
Aha - I'd also tried converting to static in my earlier attempts, but didn't realise we had __used!
updating as "static __used" causes the following diff:
bounds.s.static-used 2018-10-08 10:51:18.079309049 +0100 renamed from bounds.s.foo 2018-10-05 10:20:53.269941404 +0100 +0 -1
@@ -110,7 +110,6 @@ #NO_APP .align 2 .p2align 3,,7 - .global foo .type foo, %function foo: stp x29, x30, [sp, -16]! //,,,
I'd say this is a pretty good alternative fix - however I see Arnd's version is already on it's way though akpm's tree...
https://ozlabs.org/~akpm/mmots/broken-out/kbuild-fix-kernel-boundsc-w%3D1-warning.patch
Anyway, as long as one of the variants gets there I'll be happy :)
--
Regards
Kieran
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
Quoted 81 lines · Kieran Bingham
Quoted 57 lines · Masahiro Yamada
Quoted 43 lines · Masahiro Yamada
Hi Miguel,
Quoted 11 lines · Miguel Ojeda
Quoted 9 lines · Arnd Bergmann
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Quoted 5 lines
Quoted 2 lines
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
I think marking the function as static
__usedshould do the trick and would be less confusing.I tried
__used, but I still see the warning.masahiro@grover:~/ref/linux$ git diffkernel/bounds.c +1
-1@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +void __used foo (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);Quoted 7 lines
masahiro@grover:~/ref/linux$ make W=1 prepare CC kernel/bounds.s kernel/bounds.c:16:13: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes] void __used foo(void) ^ CC arch/x86/kernel/asm-offsets.sSorry, I forgot to add 'static'.
Quoted 3 lines
Adding both static and
__usedworked for me,
and I like the idea.Aha - I'd also tried converting to static in my earlier attempts, but didn't realise we had
__used!updating as "static
__used" causes the following diff:diff -Nurp bounds.s.foo bounds.s.static-used
bounds.s.static-used 2018-10-08 10:51:18.079309049 +0100 renamed from bounds.s.foo 2018-10-05 10:20:53.269941404 +0100 +0
-1@@ -110,7 +110,6 @@ #NO_APP .align 2 .p2align 3,,7 - .global foo .type foo, %function foo: stp x29, x30, [sp, -16]! //,,,
Quoted 6 lines
I'd say this is a pretty good alternative fix - however I see Arnd's version is already on it's way though akpm's tree...
https://ozlabs.org/~akpm/mmots/broken-out/kbuild-fix-kernel-boundsc-w%3D1-warning.patch
Anyway, as long as one of the variants gets there I'll be happy :)
I will leave it to Arnd.
When we fix arch/{mips,sparc}/kernel/asm-offsets.c, 'static __used' is just additions.
The 'main(void)' solution would require a little bit restructuring.
FWIW, with my quick analysis, the following should be fixed as well:
arch/alpha/kernel/asm-offsets.carch/c6x/kernel/asm-offsets.carch/ia64/kernel/asm-offsets.carch/ia64/kernel/nr-irqs.carch/mips/kernel/asm-offsets.carch/riscv/kernel/asm-offsets.carch/sparc/kernel/asm-offsets.carch/x86/kernel/asm-offsets.carch/x86/um/shared/sysdep/kernel-offsets.hsamples/bpf/syscall_nrs.c
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
Quoted 102 lines · Masahiro Yamada
Quoted 80 lines · Kieran Bingham
Quoted 57 lines · Masahiro Yamada
Quoted 43 lines · Masahiro Yamada
Hi Miguel,
Quoted 11 lines · Miguel Ojeda
Quoted 9 lines · Arnd Bergmann
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Quoted 5 lines
Quoted 2 lines
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
I think marking the function as static
__usedshould do the trick and would be less confusing.I tried
__used, but I still see the warning.masahiro@grover:~/ref/linux$ git diffkernel/bounds.c +1
-1@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +void __used foo (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);Quoted 7 lines
masahiro@grover:~/ref/linux$ make W=1 prepare CC kernel/bounds.s kernel/bounds.c:16:13: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes] void __used foo(void) ^ CC arch/x86/kernel/asm-offsets.sSorry, I forgot to add 'static'.
Quoted 3 lines
Adding both static and
__usedworked for me,
and I like the idea.Aha - I'd also tried converting to static in my earlier attempts, but didn't realise we had
__used!updating as "static
__used" causes the following diff:diff -Nurp bounds.s.foo bounds.s.static-used
bounds.s.static-used 2018-10-08 10:51:18.079309049 +0100 renamed from bounds.s.foo 2018-10-05 10:20:53.269941404 +0100 +0
-1@@ -110,7 +110,6 @@ #NO_APP .align 2 .p2align 3,,7 - .global foo .type foo, %function foo: stp x29, x30, [sp, -16]! //,,,Quoted 6 lines
I'd say this is a pretty good alternative fix - however I see Arnd's version is already on it's way though akpm's tree...
https://ozlabs.org/~akpm/mmots/broken-out/kbuild-fix-kernel-boundsc-w%3D1-warning.patch
Anyway, as long as one of the variants gets there I'll be happy :)
I will leave it to Arnd.
When we fix
arch/{mips,sparc}/kernel/asm-offsets.c, 'static__used' is just additions.The 'main(void)' solution would require a little bit restructuring.
FWIW, with my quick analysis, the following should be fixed as well:
Quoted 10 lines
arch/alpha/kernel/asm-offsets.carch/c6x/kernel/asm-offsets.carch/ia64/kernel/asm-offsets.carch/ia64/kernel/nr-irqs.carch/mips/kernel/asm-offsets.carch/riscv/kernel/asm-offsets.carch/sparc/kernel/asm-offsets.carch/x86/kernel/asm-offsets.carch/x86/um/shared/sysdep/kernel-offsets.hsamples/bpf/syscall_nrs.c
All the other asm-offsets.c files already use "int main(void)" ;-)
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning
In reply to Masahiro YamadaHi Masahiro,
Quoted 8 lines · Masahiro Yamada
Quoted 3 lines · Miguel Ojeda
I think marking the function as static
__usedshould do the trick and would be less confusing.I tried
__used, but I still see the warning.
It has to be static __used, not only __used! :-)
Cheers,
Miguel