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

[Xen-devel] [PATCH 07 of 18] tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id

  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Fri, 30 Mar 2012 10:25:24 +0200
  • Delivery-date: Fri, 30 Mar 2012 08:26:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1333046235 -7200
# Node ID 16f6fc42abaa781e52aa99cac5e197dee7a79098
# Parent  51c773447549ec98a5bd37739b9d87dc28b365c2
tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id

-O2 -Wall -Werror triggers these warnings:

block-qcow.c: In function 'tdqcow_get_parent_id':
block-qcow.c:1457:17: warning: 'type' may be used uninitialized in this 
function [-Wuninitialized]

The compiler can not know that open() writes to errno so it has to
assume that errno can be zero. Since tdqcow_get_image_type() has just
one caller which expects a bool as return type, adjust return codes so
that the compiler knows when 'type' is initialised.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

diff -r 51c773447549 -r 16f6fc42abaa tools/blktap2/drivers/block-qcow.c
--- a/tools/blktap2/drivers/block-qcow.c
+++ b/tools/blktap2/drivers/block-qcow.c
@@ -1408,12 +1408,12 @@ tdqcow_get_image_type(const char *file, 
        fd = open(file, O_RDONLY);
        if (fd == -1)
-               return -errno;
+               return -1;
        size = read(fd, &header, sizeof(header));
        if (size != sizeof(header))
-               return (errno ? -errno : -EIO);
+               return -1;
        if (header.magic == QCOW_MAGIC)

Xen-devel mailing list



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