]> git.proxmox.com Git - qemu.git/commitdiff
qcow2: return errno instead of -1
authorJuan Quintela <quintela@redhat.com>
Thu, 4 Mar 2010 09:00:32 +0000 (10:00 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 9 Mar 2010 17:23:00 +0000 (11:23 -0600)
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block/qcow2.c

index bf8170ed02bee983b2da37ffe3b5a279397ac5d0..5b6dad9d5994eb854eab428562f629907ede0fa3 100644 (file)
@@ -851,7 +851,7 @@ static int qcow_create2(const char *filename, int64_t total_size,
 
     fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
     if (fd < 0)
-        return -1;
+        return -errno;
     memset(&header, 0, sizeof(header));
     header.magic = cpu_to_be32(QCOW_MAGIC);
     header.version = cpu_to_be32(QCOW_VERSION);
@@ -930,7 +930,7 @@ static int qcow_create2(const char *filename, int64_t total_size,
     /* write all the data */
     ret = qemu_write_full(fd, &header, sizeof(header));
     if (ret != sizeof(header)) {
-        ret = -1;
+        ret = -errno;
         goto exit;
     }
     if (backing_file) {
@@ -943,25 +943,25 @@ static int qcow_create2(const char *filename, int64_t total_size,
             cpu_to_be32s(&ext_bf.len);
             ret = qemu_write_full(fd, &ext_bf, sizeof(ext_bf));
             if (ret != sizeof(ext_bf)) {
-                ret = -1;
+                ret = -errno;
                 goto exit;
             }
             ret = qemu_write_full(fd, backing_format, backing_format_len);
             if (ret != backing_format_len) {
-                ret = -1;
+                ret = -errno;
                 goto exit;
             }
             if (padding > 0) {
                 ret = qemu_write_full(fd, zero, padding);
                 if (ret != padding) {
-                    ret = -1;
+                    ret = -errno;
                     goto exit;
                 }
             }
         }
         ret = qemu_write_full(fd, backing_file, backing_filename_len);
         if (ret != backing_filename_len) {
-            ret = -1;
+            ret = -errno;
             goto exit;
         }
     }
@@ -970,14 +970,14 @@ static int qcow_create2(const char *filename, int64_t total_size,
     for(i = 0;i < l1_size; i++) {
         ret = qemu_write_full(fd, &tmp, sizeof(tmp));
         if (ret != sizeof(tmp)) {
-            ret = -1;
+            ret = -errno;
             goto exit;
         }
     }
     lseek(fd, s->refcount_table_offset, SEEK_SET);
     ret = qemu_write_full(fd, s->refcount_table, s->cluster_size);
     if (ret != s->cluster_size) {
-        ret = -1;
+        ret = -errno;
         goto exit;
     }
 
@@ -985,7 +985,7 @@ static int qcow_create2(const char *filename, int64_t total_size,
     ret = qemu_write_full(fd, s->refcount_block,
                    ref_clusters * s->cluster_size);
     if (ret != ref_clusters * s->cluster_size) {
-        ret = -1;
+        ret = -errno;
         goto exit;
     }