On Mon, 2015-04-20 at 03:42 -0700, Joe Perches wrote: > On Mon, 2015-04-20 at 11:33 +0300, Dan Carpenter wrote: > > You would hope that GCC would warn about the uninitialized variable but > > it doesn't. > > That's odd. So I filed this new gcc bugzilla: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65812) > > gcc 4.9.1 doesn't warn about uninitialized variable use > declared in a switch/case statement when compiled with -O Hey Dan/Yorick A bit more investigation: It's true that gcc doesn't report the uninitialized variable for the code I showed, but that's probably not the reason the "may be used uninitialized" warning is not shown for the dgnc code as patched by Yorick. The example code doesn't show the "uninitialized" warning because gcc's dead code elimination is set by -O and the sample code foo_2 function switch/case is eliminated. Perhaps the warning is not shown for this dgnc patch because your .config has CONFIG_GCOV_PROFILE_ALL set. That enables the gcc -fprofile-arcs option which masks the warning, I don't know why. Maybe see: commit 2521f2c228ad750701ba4702484e31d876dbc386 Author: Peter Oberparleiter <oberpar@xxxxxxxxxxxxxxxxxx> Date: Wed Jun 17 16:28:08 2009 -0700 gcov: add gcov profiling infrastructure Enable the use of GCC's coverage testing tool gcov [1] with the Linux kernel. gcov may be useful for: * debugging (has this code been reached at all?) * test improvement (how do I change my test to cover these lines?) * minimizing kernel configurations (do I need this option if the associated code is never run?) The profiling patch incorporates the following changes: * change kbuild to include profiling flags * provide functions needed by profiling code * present profiling data as files in debugfs Note that on some architectures, enabling gcc's profiling option "-fprofile-arcs" for the entire kernel may trigger compile/link/ run-time problems, some of which are caused by toolchain bugs and others which require adjustment of architecture code. For this reason profiling the entire kernel is initially restricted to those architectures for which it is known to work without changes. This restriction can be lifted once an architecture has been tested and found compatible with gcc's profiling. Profiling of single files or directories is still available on all platforms (see config help text). [1] http://gcc.gnu.org/onlinedocs/gcc/Gcov.html _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel