Message ID | AANLkTimZGXaYE7rvVOBFUmdyn4sQVApY7SS3+3vseap-@mail.gmail.com |
---|---|
State | New |
Headers | show |
Blue Swirl <blauwirbel@gmail.com> writes: > 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. What about a simple "(void)dummy" instead?
Am 07.10.2010 11:37, schrieb Markus Armbruster: > Blue Swirl <blauwirbel@gmail.com> writes: > >> 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. > > What about a simple "(void)dummy" instead? I would prefer that, too. Kevin
On Thu, Oct 7, 2010 at 11:55 AM, Kevin Wolf <kwolf@redhat.com> wrote: > Am 07.10.2010 11:37, schrieb Markus Armbruster: >> Blue Swirl <blauwirbel@gmail.com> writes: >> >>> 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. >> >> What about a simple "(void)dummy" instead? > > I would prefer that, too. That also works. I'll use that in the next version.
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;
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 <blauwirbel@gmail.com> --- block/qcow2-refcount.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) 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;