qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 01/11] block: avoid a write only variable
@ 2010-10-06 21:31 Blue Swirl
  2010-10-07  9:37 ` Markus Armbruster
  0 siblings, 1 reply; 4+ messages in thread
From: Blue Swirl @ 2010-10-06 21:31 UTC (permalink / raw)
  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 <blauwirbel@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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH 01/11] block: avoid a write only variable
  2010-10-06 21:31 [Qemu-devel] [PATCH 01/11] block: avoid a write only variable Blue Swirl
@ 2010-10-07  9:37 ` Markus Armbruster
  2010-10-07 11:55   ` Kevin Wolf
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2010-10-07  9:37 UTC (permalink / raw)
  To: Blue Swirl; +Cc: Kevin Wolf, qemu-devel

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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH 01/11] block: avoid a write only variable
  2010-10-07  9:37 ` Markus Armbruster
@ 2010-10-07 11:55   ` Kevin Wolf
  2010-10-07 18:27     ` Blue Swirl
  0 siblings, 1 reply; 4+ messages in thread
From: Kevin Wolf @ 2010-10-07 11:55 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Blue Swirl, qemu-devel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH 01/11] block: avoid a write only variable
  2010-10-07 11:55   ` Kevin Wolf
@ 2010-10-07 18:27     ` Blue Swirl
  0 siblings, 0 replies; 4+ messages in thread
From: Blue Swirl @ 2010-10-07 18:27 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Markus Armbruster, qemu-devel

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-10-07 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-06 21:31 [Qemu-devel] [PATCH 01/11] block: avoid a write only variable Blue Swirl
2010-10-07  9:37 ` Markus Armbruster
2010-10-07 11:55   ` Kevin Wolf
2010-10-07 18:27     ` Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).