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

[Xen-devel] [PATCH] Fix the build of blktap



This patch fixes the following compilation error introduced by the recent change
in block-qcow2.c. 

-----------------------------------------------
gcc  -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -g 
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value 
-Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF .block-qcow2.o.d  
-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -Werror -Wno-unused -I../lib 
-I../../../tools/libxc -I../../../tools/include -I../../../tools/xenstore 
-I../../../tools/include -I ../../libaio/src -D_GNU_SOURCE -c -o block-qcow2.o 
block-qcow2.c
cc1: warnings being treated as errors
block-qcow2.c: In function 'qcow2_create':
block-qcow2.c:2045: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block-qcow2.c:2047: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block-qcow2.c:2052: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block-qcow2.c:2055: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block-qcow2.c:2058: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
make[5]: *** [block-qcow2.o] Error 1
---------------------------------------------

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@xxxxxxxxxxxxx>

diff -r 7f573cb76db4 tools/blktap/drivers/block-qcow2.c
--- a/tools/blktap/drivers/block-qcow2.c        Tue Mar 03 13:22:28 2009 +0000
+++ b/tools/blktap/drivers/block-qcow2.c        Thu Mar 05 11:20:41 2009 +0900
@@ -1984,6 +1984,7 @@
                       const char *backing_file, int flags)
 {
     int fd, header_size, backing_filename_len, l1_size, i, shift, l2_bits;
+    int ret = 0;
     QCowHeader header;
     uint64_t tmp, offset;
     QCowCreateState s1, *s = &s1;
@@ -2042,25 +2043,37 @@
     create_refcount_update(s, s->refcount_block_offset, s->cluster_size);
 
     /* write all the data */
-    write(fd, &header, sizeof(header));
+    ret = write(fd, &header, sizeof(header));
+    if (ret < 0)
+        goto out;
     if (backing_file) {
-        write(fd, backing_file, backing_filename_len);
+        ret = write(fd, backing_file, backing_filename_len);
+        if (ret < 0)
+            goto out;
     }
     lseek(fd, s->l1_table_offset, SEEK_SET);
     tmp = 0;
     for(i = 0;i < l1_size; i++) {
-        write(fd, &tmp, sizeof(tmp));
+        ret = write(fd, &tmp, sizeof(tmp));
+        if (ret < 0)
+            goto out;
     }
     lseek(fd, s->refcount_table_offset, SEEK_SET);
-    write(fd, s->refcount_table, s->cluster_size);
+    ret = write(fd, s->refcount_table, s->cluster_size);
+    if (ret < 0)
+        goto out;
 
     lseek(fd, s->refcount_block_offset, SEEK_SET);
-    write(fd, s->refcount_block, s->cluster_size);
+    ret = write(fd, s->refcount_block, s->cluster_size);
+    if (ret < 0)
+        goto out;
+    ret = 0;
 
+  out:
     qemu_free(s->refcount_table);
     qemu_free(s->refcount_block);
     close(fd);
-    return 0;
+    return ret;
 }
 
 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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