Compiling with GCC 4.6.0 20100925 produced a warning:
/src/qemu/block/qcow2-refcount.c: In function 'update_refcount':
/src/qemu/block/qcow2-refcount.c:552:13: error: variable 'dummy' set
but not used [-Werror=unused-but-set-variable]

Fix by adding a function that does not generate a warning when
the result is unused.

Signed-off-by: Blue Swirl <blauwir...@gmail.com>
---
 block/qcow2-refcount.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 7082601..dc0851f 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -27,10 +27,15 @@
 #include "block/qcow2.h"

 static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size);
-static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
-                            int64_t offset, int64_t length,
-                            int addend);
+static int update_refcount_nowarn(BlockDriverState *bs,
+                                  int64_t offset, int64_t length, int addend);

+static inline int QEMU_WARN_UNUSED_RESULT
+update_refcount(BlockDriverState *bs, int64_t offset, int64_t length,
+                int addend)
+{
+    return update_refcount_nowarn(bs, offset, length, addend);
+}

 static int cache_refcount_updates = 0;

@@ -457,8 +462,8 @@ static int
write_refcount_block_entries(BlockDriverState *bs,
 }

 /* XXX: cache several refcount block clusters ? */
-static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
-    int64_t offset, int64_t length, int addend)
+static int update_refcount_nowarn(BlockDriverState *bs,
+                                  int64_t offset, int64_t length, int addend)
 {
     BDRVQcowState *s = bs->opaque;
     int64_t start, last, cluster_offset;
@@ -549,8 +554,7 @@ fail:
      * some cases like ENOSPC for allocating a new refcount block)
      */
     if (ret < 0) {
-        int dummy;
-        dummy = update_refcount(bs, offset, cluster_offset - offset, -addend);
+        update_refcount_nowarn(bs, offset, cluster_offset - offset, -addend);
     }

     return ret;
-- 
1.6.2.4

Reply via email to