powerpc: Remove the static variable initialisations to 0
PATCH 1/1 powerpc: Remove the static variable initialisations to 0
Initialise global and static variable to 0 is always unnecessary. Remove the unnecessary initialisations.
--- arch/powerpc/kexec/core_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kexec/core_64.c +1 -1
@@ -135,7 +135,7 @@ notrace void kexec_copy_flush(struct kimage *image)#ifdef CONFIG_SMP -static int kexec_all_irq_disabled =0 ; +static int kexec_all_irq_disabled;static void kexec_smp_down (void *arg) {
Signature · 1 line
2.35.1
Hello,
Quoted 2 lines · Jason Wang
Initialise global and static variable to 0 is always unnecessary. Remove the unnecessary initialisations.
Isn't this change also unnecessary?
Initializing to 0 does not affect correctness, or even any kind of semantics in any way.
The current code is slightly easier to understand.
And changing the code introduces history noise for na gain.
Thanks
Michal
Quoted 22 lines
Signed-off-by Jason Wang <[email protected]>--- arch/powerpc/kexec/core_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/kexec/core_64.c +1
-1@@ -135,7 +135,7 @@ notrace void kexec_copy_flush(struct kimage *image)#ifdef CONFIG_SMP -static int kexec_all_irq_disabled =0 ; +static int kexec_all_irq_disabled;static void kexec_smp_down (void *arg) {Signature · 1 line
2.35.1
Quoted 10 lines · Michal Suchánek
Hello,
Quoted 2 lines · Jason Wang
Initialise global and static variable to 0 is always unnecessary. Remove the unnecessary initialisations.
Isn't this change also unnecessary?
Initializing to 0 does not affect correctness, or even any kind of semantics in any way.
It did make a difference when the kernel was still compiled with -fcommon (which used to be the GCC default on most configurations, it is traditional on Unix). No explicit initialiser puts an object in .bss if you use -fcommon. This matters a bit for data layout.
Quoted 3 lines
The current code is slightly easier to understand.
And changing the code introduces history noise for na gain.
Yup.
This does give you some code golf points of course ;-)
Segher
Michael Ellerman
reviewerQuoted 9 lines · Segher Boessenkool
Quoted 8 lines · Michal Suchánek
Hello,
Quoted 2 lines · Jason Wang
Initialise global and static variable to 0 is always unnecessary. Remove the unnecessary initialisations.
Isn't this change also unnecessary?
Quoted 7 lines
Quoted 2 lines
Initializing to 0 does not affect correctness, or even any kind of semantics in any way.
It did make a difference when the kernel was still compiled with -fcommon (which used to be the GCC default on most configurations, it is traditional on Unix). No explicit initialiser puts an object in .bss if you use -fcommon. This matters a bit for data layout.
The kernel has built with -fno-common since ~2002.
I think the belief is that an explicit initialiser of 0 forces the variable into .data, but AFAICS that is not true with any compiler we support.
cheers
Quoted 13 lines · Michael Ellerman
Quoted 12 lines · Segher Boessenkool
Quoted 10 lines · Michal Suchánek
Hello,
Quoted 2 lines · Jason Wang
Initialise global and static variable to 0 is always unnecessary. Remove the unnecessary initialisations.
Isn't this change also unnecessary?
Initializing to 0 does not affect correctness, or even any kind of semantics in any way.
Quoted 6 lines
Quoted 4 lines
It did make a difference when the kernel was still compiled with -fcommon (which used to be the GCC default on most configurations, it is traditional on Unix). No explicit initialiser puts an object in .bss if you use -fcommon. This matters a bit for data layout.
The kernel has built with -fno-common since ~2002.
2001, yes (255649c18287). And before that it was important to initialise everything with static storage duration explicitly in the source code. It was part of the collective memory, I wondered if this patch originated that way?
Quoted 3 lines
I think the belief is that an explicit initialiser of 0 forces the variable into .data, but AFAICS that is not true with any compiler we support.
Exactly, you get identical code either way, if you use -fno-common. People will still see this difference if they use a compiler before GCC 10 for compiling most other things though.
Segher