Message ID | 1261311396-609-1-git-send-email-a.beregalov@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
From: Alexander Beregalov <a.beregalov@gmail.com> Date: Sun, 20 Dec 2009 15:16:35 +0300 > 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 > > Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com> 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? -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sun, Dec 20, 2009 at 03:16:35PM +0300, Alexander Beregalov wrote: > 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 What config produces these warnings? Do you have CONFIG_BUG_VERBOSE set? Also what gcc versio? Sam -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
2009/12/21 Sam Ravnborg <sam@ravnborg.org>: > On Sun, Dec 20, 2009 at 03:16:35PM +0300, Alexander Beregalov wrote: >> 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 > > What config produces these warnings? > Do you have CONFIG_BUG_VERBOSE set? > > 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 <a.beregalov@gmail.com>: > 2009/12/21 Sam Ravnborg <sam@ravnborg.org>: >> On Sun, Dec 20, 2009 at 03:16:35PM +0300, Alexander Beregalov wrote: >>> 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 >> >> What config produces these warnings? >> Do you have CONFIG_BUG_VERBOSE set? >> >> Also what gcc versio? >> Ah, this is it. # CONFIG_BUG is not set Is it sane config ? > > 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 > -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Dec 21, 2009 at 10:28:39PM +0300, Alexander Beregalov wrote: > 2009/12/21 Alexander Beregalov <a.beregalov@gmail.com>: > > 2009/12/21 Sam Ravnborg <sam@ravnborg.org>: > >> On Sun, Dec 20, 2009 at 03:16:35PM +0300, Alexander Beregalov wrote: > >>> 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 > >> > >> What config produces these warnings? > >> Do you have CONFIG_BUG_VERBOSE set? > >> > >> Also what gcc versio? > >> > Ah, this is it. > > # CONFIG_BUG is not set > > Is it sane config ? Only embedded size constrained configs would consider this. The reason for the warning is this snippet from include/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 -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Sam Ravnborg <sam@ravnborg.org> Date: Mon, 21 Dec 2009 20:59:21 +0100 > 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) Maybe we can use "unreachable()" here. -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Dec 21, 2009 at 12:14:11PM -0800, David Miller wrote: > From: Sam Ravnborg <sam@ravnborg.org> > Date: Mon, 21 Dec 2009 20:59:21 +0100 > > > 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) > > Maybe we can use "unreachable()" here. Makes sense. Alexander - could you please try to add an unreachable() 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 -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
2009/12/21 Sam Ravnborg <sam@ravnborg.org>: > On Mon, Dec 21, 2009 at 12:14:11PM -0800, David Miller wrote: >> From: Sam Ravnborg <sam@ravnborg.org> >> Date: Mon, 21 Dec 2009 20:59:21 +0100 >> >> > 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) >> >> Maybe we can use "unreachable()" here. > Makes sense. > > Alexander - could you please try to add an > unreachable() 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. It fixes the problem, thanks! -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c index 365b646..7eb12fc 100644 --- a/arch/sparc/kernel/us3_cpufreq.c +++ b/arch/sparc/kernel/us3_cpufreq.c @@ -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;
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 Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com> --- arch/sparc/kernel/us3_cpufreq.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)