Message ID | 20210408011801.557004-3-yukuai3@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Christophe Leroy |
Headers | show |
Series | code optimizations for btext.c | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch powerpc/merge (571b0d1ccf5cd3dc1b9866a908769ee23f7d127e) |
snowpatch_ozlabs/build-ppc64le | success | Build succeeded |
snowpatch_ozlabs/build-ppc64be | success | Build succeeded and removed 2 sparse warnings |
snowpatch_ozlabs/build-ppc64e | success | Build succeeded |
snowpatch_ozlabs/build-pmac32 | success | Build succeeded and removed 2 sparse warnings |
snowpatch_ozlabs/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 8 lines checked |
snowpatch_ozlabs/needsstable | success | Patch has no Fixes tags |
Le 08/04/2021 à 03:18, Yu Kuai a écrit : > The sparse tool complains as follow: > > arch/powerpc/kernel/btext.c:48:5: warning: > symbol 'boot_text_mapped' was not declared. Should it be static? > > This symbol is not used outside of btext.c, so this commit make > it static. > > Signed-off-by: Yu Kuai <yukuai3@huawei.com> > --- > arch/powerpc/kernel/btext.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c > index 359d0f4ca532..8df9230be6fa 100644 > --- a/arch/powerpc/kernel/btext.c > +++ b/arch/powerpc/kernel/btext.c > @@ -45,7 +45,7 @@ unsigned long disp_BAT[2] __initdata = {0, 0}; > > static unsigned char vga_font[cmapsz]; > > -int boot_text_mapped __force_data = 0; > +static int boot_text_mapped __force_data; Are you sure the initialisation to 0 can be removed ? Usually initialisation to 0 is not needed because not initialised variables go in the BSS section which is zeroed at startup. But here the variable is flagged with __force_data so it is not going in the BSS section. > > extern void rmci_on(void); > extern void rmci_off(void); >
On 2021/04/08 13:04, Christophe Leroy wrote: > > > Le 08/04/2021 à 03:18, Yu Kuai a écrit : >> The sparse tool complains as follow: >> >> arch/powerpc/kernel/btext.c:48:5: warning: >> symbol 'boot_text_mapped' was not declared. Should it be static? >> >> This symbol is not used outside of btext.c, so this commit make >> it static. >> >> Signed-off-by: Yu Kuai <yukuai3@huawei.com> >> --- >> arch/powerpc/kernel/btext.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c >> index 359d0f4ca532..8df9230be6fa 100644 >> --- a/arch/powerpc/kernel/btext.c >> +++ b/arch/powerpc/kernel/btext.c >> @@ -45,7 +45,7 @@ unsigned long disp_BAT[2] __initdata = {0, 0}; >> static unsigned char vga_font[cmapsz]; >> -int boot_text_mapped __force_data = 0; >> +static int boot_text_mapped __force_data; > > Are you sure the initialisation to 0 can be removed ? Usually > initialisation to 0 is not needed because not initialised variables go > in the BSS section which is zeroed at startup. But here the variable is > flagged with __force_data so it is not going in the BSS section. Hi, I removed the initialisation to 0 because checkpatch complained about it, I do not familiar with '__force_data', thanks for pointing it out. Thanks, Yu Kuai > > >> extern void rmci_on(void); >> extern void rmci_off(void); >> > . >
Hi! On Thu, Apr 08, 2021 at 07:04:35AM +0200, Christophe Leroy wrote: > Le 08/04/2021 à 03:18, Yu Kuai a écrit : > >-int boot_text_mapped __force_data = 0; > >+static int boot_text_mapped __force_data; > > Are you sure the initialisation to 0 can be removed ? Usually > initialisation to 0 is not needed because not initialised variables go in > the BSS section which is zeroed at startup. But here the variable is > flagged with __force_data so it is not going in the BSS section. Any non-automatic (i.e. function-scope, not static) variable is initialised to 0. See e.g. C11 6.7.9/10 (this has been like that since times immemorial, C90 anyway). Segher
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c index 359d0f4ca532..8df9230be6fa 100644 --- a/arch/powerpc/kernel/btext.c +++ b/arch/powerpc/kernel/btext.c @@ -45,7 +45,7 @@ unsigned long disp_BAT[2] __initdata = {0, 0}; static unsigned char vga_font[cmapsz]; -int boot_text_mapped __force_data = 0; +static int boot_text_mapped __force_data; extern void rmci_on(void); extern void rmci_off(void);
The sparse tool complains as follow: arch/powerpc/kernel/btext.c:48:5: warning: symbol 'boot_text_mapped' was not declared. Should it be static? This symbol is not used outside of btext.c, so this commit make it static. Signed-off-by: Yu Kuai <yukuai3@huawei.com> --- arch/powerpc/kernel/btext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)