build warning question - gcc 4.4.5
Andrew Haley
aph@redhat.com
Mon Jan 6 13:46:00 GMT 2014
On 01/06/2014 12:43 PM, Marc Glisse wrote:
> On Mon, 6 Jan 2014, Nicholas Mc Guire wrote:
>
>> during Linux kernel build I got the following build warning
>>
>> kernel/trace/trace.c: In function 'tracing_mark_write':
>> kernel/trace/trace.c:3818: warning: 'page2' may be used uninitialized in this function
>>
>> after looking at this function I was not able to figure out how
>> this uninitialized usage could happen - all access to page2
>> is "protected" by an "if (nr_pages == 2)" so no uninitialized
>> access should be possible.
>
> Note the word "may": gcc isn't able (at least at this optimization level)
> to prove that page2 is always initialized before use, so it warns.
>
>> is there some way to make gcc happy here ?
>
> Initialize page2 to 0 where you declare it?
<aside>
I'm very nervous about advice like this in general: see
https://www.schneier.com/blog/archives/2008/05/random_number_b.html
http://anonscm.debian.org/viewvc/pkg-openssl/openssl/trunk/rand/md_rand.c?p2=%2Fopenssl%2Ftrunk%2Frand%2Fmd_rand.c&p1=openssl%2Ftrunk%2Frand%2Fmd_rand.c&r1=141&r2=140&view=diff&pathrev=141
This happened because the maintainer saw a warning about uninitialized
data and "fixed" the code.
But, in this specific case, I have no such worries.
</aside>
Andrew.
More information about the Gcc-help
mailing list