diff mbox

[V11,4/8] qcow2: return int for qcow2_free_clusters()

Message ID 1392146588-12120-5-git-send-email-xiawenc@linux.vnet.ibm.com
State New
Headers show

Commit Message

Wayne Xia Feb. 11, 2014, 7:23 p.m. UTC
The return value can help caller check whether error happens,
and it does not need to have *errp since the return value already tips
what happend.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/qcow2-refcount.c |    8 +++++---
 block/qcow2.h          |    6 +++---
 2 files changed, 8 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index c974abe..4eb413a 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -761,9 +761,9 @@  int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
     return offset;
 }
 
-void qcow2_free_clusters(BlockDriverState *bs,
-                          int64_t offset, int64_t size,
-                          enum qcow2_discard_type type)
+int qcow2_free_clusters(BlockDriverState *bs,
+                        int64_t offset, int64_t size,
+                        enum qcow2_discard_type type)
 {
     int ret;
 
@@ -773,6 +773,8 @@  void qcow2_free_clusters(BlockDriverState *bs,
         fprintf(stderr, "qcow2_free_clusters failed: %s\n", strerror(-ret));
         /* TODO Remember the clusters to free them later and avoid leaking */
     }
+
+    return ret;
 }
 
 /*
diff --git a/block/qcow2.h b/block/qcow2.h
index f8390ed..a66ac9b 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -435,9 +435,9 @@  int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size);
 int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
     int nb_clusters);
 int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size);
-void qcow2_free_clusters(BlockDriverState *bs,
-                          int64_t offset, int64_t size,
-                          enum qcow2_discard_type type);
+int qcow2_free_clusters(BlockDriverState *bs,
+                        int64_t offset, int64_t size,
+                        enum qcow2_discard_type type);
 void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry,
                              int nb_clusters, enum qcow2_discard_type type);