lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1429532893.4216.36.camel@perches.com>
Date:	Mon, 20 Apr 2015 05:28:13 -0700
From:	Joe Perches <joe@...ches.com>
To:	Dan Carpenter <dan.carpenter@...cle.com>
Cc:	Yorick Rommers <yorick-rommers@...mail.com>,
	devel@...verdev.osuosl.org, lidza.louina@...il.com,
	driverdev-devel@...uxdriverproject.org,
	linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org
Subject: Re: gcc doesn't warn about uninitialized variable use in
 switch/case with -O (was: Re: [PATCH] Staging: dgnc: Using temporary value
 for repeated dereferences)

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@...ux.vnet.ibm.com>
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
  

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ