sparc: us3_cpufreq.c: fix warnings/errors
PATCH 1/2 sparc: us3_cpufreq.c: fix warnings/errors
Fix warnings which become build errors since -Werror is used. arch/sparc/kernel/us3_cpufreq.c:60: error: 'ret' may be used uninitialized in this function arch/sparc/kernel/us3_cpufreq.c:101: error: 'new_bits' may be used uninitialized in this function
--- arch/sparc/kernel/us3_cpufreq.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/sparc/kernel/us3_cpufreq.c +2 -2
@@ -57,7 +57,7 @@ static void write_safari_cfg(unsigned long val)static unsigned long get_current_freq (unsigned int cpu,unsigned long safari_cfg) {unsigned long clock_tick =sparc64_get_clock_tick (cpu) /1000 ; -unsigned long ret; +unsigned long ret =0 ;switch (safari_cfg &SAFARI_CFG_DIV_MASK ) {case SAFARI_CFG_DIV_1 :
@@ -98,7 +98,7 @@ static unsigned int us3_freq_get(unsigned int cpu)static void us3_set_cpu_divider_index (unsigned int cpu,unsigned int index) { -unsigned long new_bits, new_freq, reg; +unsigned long new_bits =0 , new_freq, reg;cpumask_t cpus_allowed;struct cpufreq_freqs freqs;
Signature · 1 line
1.6.6.rc3
David Miller
maintainerFrom: Alexander Beregalov <[email protected]>
Date: Sun, 20 Dec 2009 15:16:35 +0300
Quoted 5 lines
Fix warnings which become build errors since -Werror is used.
arch/sparc/kernel/us3_cpufreq.c:60: error: 'ret' may be used uninitialized in this functionarch/sparc/kernel/us3_cpufreq.c:101: error: 'new_bits' may be used uninitialized in this functionSigned-off-by Alexander Beregalov <[email protected]>
The default switch case is BUG(), therefore the end of the function is unreachable.
What changed recently to cause this to start generating a warning, it never did before?
Quoted 3 lines · Alexander Beregalov
Fix warnings which become build errors since -Werror is used.
arch/sparc/kernel/us3_cpufreq.c:60: error: 'ret' may be used uninitialized in this functionarch/sparc/kernel/us3_cpufreq.c:101: error: 'new_bits' may be used uninitialized in this function
What config produces these warnings?
Do you have CONFIG_BUG_VERBOSE set?
Also what gcc versio?
Sam
2009/12/21 Sam Ravnborg <[email protected]>:
Quoted 10 lines · Alexander Beregalov
Quoted 3 lines
Fix warnings which become build errors since -Werror is used.
arch/sparc/kernel/us3_cpufreq.c:60: error: 'ret' may be used uninitialized in this functionarch/sparc/kernel/us3_cpufreq.c:101: error: 'new_bits' may be used uninitialized in this functionWhat config produces these warnings?
Do you haveCONFIG_BUG_VERBOSEset?Also what gcc versio?
Hi
I do not know what has changed.
I have not tried these options before.
I tested randconfig builds.
Config is attached.
gcc is 4.3.4
sparc64-unknown-linux-gnu-gcc -Wp,-MD,arch/sparc/kernel/.us3_cpufreq.o.d -nostdinc -isystem /usr/lib/gcc/sparc64-unknown-linux-gnu/4.3.4/include -I/home/alexb/src/linux-2.6/arch/sparc/include -Iinclude -include include/generated/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare -Wa,--undeclared-regs -mtune=ultrasparc3 -pg -fno-stack-protector -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -Werror -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(us3_cpufreq)" -D"KBUILD_MODNAME=KBUILD_STR(us3_cpufreq)" -D"DEBUG_HASH=11" -D"DEBUG_HASH2=39" -c -o arch/sparc/kernel/.tmp_us3_cpufreq.o arch/sparc/kernel/us3_cpufreq.c
cc1: warnings being treated as errors arch/sparc/kernel/us3_cpufreq.c: In function 'get_current_freq':arch/sparc/kernel/us3_cpufreq.c:60: error: 'ret' may be used uninitialized in this function arch/sparc/kernel/us3_cpufreq.c: In function 'us3_set_cpu_divider_index':arch/sparc/kernel/us3_cpufreq.c:101: error: 'new_bits' may be used uninitialized in this function
make[1]: *** [arch/sparc/kernel/us3_cpufreq.o] Error 1
2009/12/21 Alexander Beregalov <[email protected]>:
Quoted 11 lines
2009/12/21 Sam Ravnborg <[email protected]>:
Quoted 10 lines · Alexander Beregalov
Quoted 3 lines
Fix warnings which become build errors since -Werror is used.
arch/sparc/kernel/us3_cpufreq.c:60: error: 'ret' may be used uninitialized in this functionarch/sparc/kernel/us3_cpufreq.c:101: error: 'new_bits' may be used uninitialized in this functionWhat config produces these warnings?
Do you haveCONFIG_BUG_VERBOSEset?Also what gcc versio?
Ah, this is it.
# CONFIG_BUG is not set
Is it sane config ?
Quoted 36 lines
Hi
I do not know what has changed.
I have not tried these options before.
I tested randconfig builds.
Config is attached.gcc is 4.3.4
sparc64-unknown-linux-gnu-gcc -Wp,-MD,arch/sparc/kernel/.us3_cpufreq.o.d -nostdinc -isystem
/usr/lib/gcc/sparc64-unknown-linux-gnu/4.3.4/include-I/home/alexb/src/linux-2.6/arch/sparc/include -Iinclude -includeinclude/generated/autoconf.h-D__KERNEL__ -Wall -Wundef(quoted diff) +0
-11-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare -Wa,--undeclared-regs -mtune=ultrasparc3 -pg -fno-stack-protector -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -Werror -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(us3_cpufreq)" -D"KBUILD_MODNAME=KBUILD_STR(us3_cpufreq)" -D"DEBUG_HASH" -D"DEBUG_HASH29" -c -o arch/sparc/kernel/.tmp_us3_cpufreq.o
arch/sparc/kernel/us3_cpufreq.c
cc1: warnings being treated as errorsarch/sparc/kernel/us3_cpufreq.c: In function 'get_current_freq':arch/sparc/kernel/us3_cpufreq.c:60: error: 'ret' may be used uninitialized in this functionarch/sparc/kernel/us3_cpufreq.c: In function 'us3_set_cpu_divider_index':arch/sparc/kernel/us3_cpufreq.c:101: error: 'new_bits' may be used uninitialized in this function
make[1]: *** [arch/sparc/kernel/us3_cpufreq.o] Error 1
Quoted 10 lines · Alexander Beregalov
2009/12/21 Alexander Beregalov <[email protected]>:
Quoted 9 lines
2009/12/21 Sam Ravnborg <[email protected]>:
Quoted 8 lines · Alexander Beregalov
Quoted 3 lines
Fix warnings which become build errors since -Werror is used.
arch/sparc/kernel/us3_cpufreq.c:60: error: 'ret' may be used uninitialized in this functionarch/sparc/kernel/us3_cpufreq.c:101: error: 'new_bits' may be used uninitialized in this functionWhat config produces these warnings?
Do you haveCONFIG_BUG_VERBOSEset?
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Also what gcc versio?
Ah, this is it.
#
CONFIG_BUGis not setIs it sane config ?
Only embedded size constrained configs would
consider this.
The reason for the warning is this snippet frominclude/asm-generic/bug.h:
#define BUG() do {} while(0)
The above only comes into effect when CONFIG_BUG is not set.
I dunno what the best fix is here.
Embedded or not - I cannot see why we should continue execution after a BUG().
Code will assume we panicked and following code not to be executed.
As the comment says:
"Don't use BUG() or BUG_ON() unless there's really no way out;"
I would have expected to see something like this:
#define BUG() do {} while(1)
A never ending loop so the watchdog on embedded systems could force a reboot. IMO more safe than continue and do random curruption of stuff all over.
David Howells added the do {} while(0) - so cc: on this mail.
Sam
David Miller
maintainerFrom: Sam Ravnborg <[email protected]>
Date: Mon, 21 Dec 2009 20:59:21 +0100
Quoted 5 lines
As the comment says:
"Don't useBUG()orBUG_ON()unless there's really no way out;"I would have expected to see something like this:
#defineBUG()do {} while(1)
Maybe we can use "unreachable()" here.
Quoted 10 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Mon, 21 Dec 2009 20:59:21 +0100Quoted 5 lines
As the comment says:
"Don't useBUG()orBUG_ON()unless there's really no way out;"I would have expected to see something like this:
#defineBUG()do {} while(1)Maybe we can use "
unreachable()" here.
Makes sense.
Alexander - could you please try to add anunreachable() call in in bug.h and if it
kills the warnings as expected then send
a patch to Arnd including a proper
changelog describing why this was need.
I copied Arnd on this mail albeit he may miss some context... In short - Alexandar posted a few patches to get rid of a set of warnings on sparc.
The root cause of the warnings was the definition of BUG() when CONFIG_BUG is not set.
Sam
2009/12/21 Sam Ravnborg <[email protected]>:
Quoted 10 lines · David Miller
Quoted 9 lines
From: Sam Ravnborg <[email protected]>
Date: Mon, 21 Dec 2009 20:59:21 +0100Quoted 5 lines
As the comment says:
"Don't useBUG()orBUG_ON()unless there's really no way out;"I would have expected to see something like this:
#defineBUG()do {} while(1)
Quoted 8 lines
Quoted 1 line
Maybe we can use "
unreachable()" here.Makes sense.
Alexander - could you please try to add an
unreachable()call in inbug.hand if it kills the warnings as expected then send a patch to Arnd including a proper changelog describing why this was need.
It fixes the problem, thanks!