[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH for-4.7 4/6] blktap2: initialise buf in vhd_util_check_footer



Gcc complains:

vhd-util-check.c: In function ‘vhd_util_check_footer’:
vhd-util-check.c:413:2: error: ‘buf’ may be used uninitialized in this function 
[-Werror=maybe-uninitialized]
  memcpy(&backup, buf, sizeof(backup));

In fact buf is initialised a few lines above.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
I can't figure out why buf may be uninitialised and this seems to be the
only way to convince gcc it is ok to proceed.
---
 tools/blktap2/vhd/lib/vhd-util-check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/blktap2/vhd/lib/vhd-util-check.c 
b/tools/blktap2/vhd/lib/vhd-util-check.c
index af07426..40565ac 100644
--- a/tools/blktap2/vhd/lib/vhd-util-check.c
+++ b/tools/blktap2/vhd/lib/vhd-util-check.c
@@ -335,7 +335,7 @@ vhd_util_check_footer(int fd, vhd_footer_t *footer, int 
ignore)
 {
        size_t size;
        int err, opened;
-       char *msg, *buf;
+       char *msg, *buf = NULL;
        off_t eof, off;
        vhd_footer_t primary, backup;
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.