From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59845 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3bad-00079S-HY for qemu-devel@nongnu.org; Wed, 06 Oct 2010 17:31:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P3bab-0006Se-7Y for qemu-devel@nongnu.org; Wed, 06 Oct 2010 17:31:54 -0400 Received: from mail-qy0-f173.google.com ([209.85.216.173]:50016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P3bab-0006OO-2B for qemu-devel@nongnu.org; Wed, 06 Oct 2010 17:31:53 -0400 Received: by mail-qy0-f173.google.com with SMTP id 32so3592212qyk.4 for ; Wed, 06 Oct 2010 14:31:52 -0700 (PDT) MIME-Version: 1.0 From: Blue Swirl Date: Wed, 6 Oct 2010 21:31:32 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] [PATCH 01/11] block: avoid a write only variable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel , Kevin Wolf 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 --- 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