From 549a8ee962ebdcf5a9dbe4c694d024b63a4b3a61 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 10 May 2012 14:26:14 +0100 Subject: blktap2: Fix another uninitialised value error 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: Ian Jackson --- tools/blktap2/drivers/block-remus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/blktap2') diff --git a/tools/blktap2/drivers/block-remus.c b/tools/blktap2/drivers/block-remus.c index 0af01f13e7..079588d820 100644 --- a/tools/blktap2/drivers/block-remus.c +++ b/tools/blktap2/drivers/block-remus.c @@ -505,7 +505,7 @@ fail: static int ramdisk_flush(td_driver_t *driver, struct tdremus_state* s) { uint64_t* sectors; - char* buf; + char* buf = NULL; uint64_t base, batchlen; int i, j, count = 0; -- cgit v1.2.3