Skip to content
  • Ian Jackson's avatar
    blktap2: Fix another uninitialised value error · 7aae1999
    Ian Jackson authored
    
    
    gcc  -O1 -fno-omit-frame-pointer -m32 -march=i686 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement   -D__XEN_TOOLS__ -MMD -MF .block-remus.o.d -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls -mno-tls-direct-seg-refs -Werror -g -Wno-unused -fno-strict-aliasing -I../include -I../drivers -I/home/osstest/build.12828.build-i386/xen-unstable/tools/blktap2/drivers/../../../tools/libxc -I/home/osstest/build.12828.build-i386/xen-unstable/tools/blktap2/drivers/../../../tools/include -D_GNU_SOURCE -DUSE_NFS_LOCKS  -c -o block-remus.o block-remus.c
    
    block-remus.c: In function 'ramdisk_flush':
    block-remus.c:508: error: 'buf' may be used uninitialized in this function
    make[5]: *** [block-remus.o] Error 1
    
    This is because gcc can see that merge_requests doesn't always set
    *mergedbuf but gcc isn't able to prove that it always does so if
    merge_requests returns 0 and that in that case the value of
    ramdisk_flush::buf isn't used.
    
    This is too useful a warning to disable, despite the occasional false
    positive of this form.  The conventional approach is to suppress the
    warning by explicitly initialising the variable to 0.
    
    This has just come to light because 25275:27d63b9f111a reenabled
    optimisation for this area of code, and gcc's data flow analysis
    (which is required to trigger the uninitialised variable warning) only
    occurs when optimisation is turned on.
    
    Signed-off-by: default avatarIan Jackson <ian.jackson@eu.citrix.com>
    7aae1999