qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Fix compiler warning (-Werror=uninitialized)
@ 2013-09-17 16:43 Stefan Weil
  2013-09-19 14:44 ` Stefan Hajnoczi
  2013-09-19 16:59 ` Andreas Färber
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Weil @ 2013-09-17 16:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Kevin Wolf, Stefan Hajnoczi, Stefan Weil

The patch fixes a warning from gcc (Debian 4.6.3-14+rpi1) 4.6.3:

block/stream.c:141:22: error:
‘copy’ may be used uninitialized in this function [-Werror=uninitialized]

This is not a real bug - a better compiler would not complain.

Now 'copy' has always a defined value, so the check for ret >= 0
can be removed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 block/stream.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/block/stream.c b/block/stream.c
index 078ce4a..fc19194 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -108,7 +108,7 @@ static void coroutine_fn stream_run(void *opaque)
 
     for (sector_num = 0; sector_num < end; sector_num += n) {
         uint64_t delay_ns = 0;
-        bool copy;
+        bool copy = false;
 
 wait:
         /* Note that even when no rate limit is applied we need to yield
@@ -123,7 +123,6 @@ wait:
                                 STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n);
         if (ret == 1) {
             /* Allocated in the top, no need to copy.  */
-            copy = false;
         } else if (ret >= 0) {
             /* Copy if allocated in the intermediate images.  Limit to the
              * known-unallocated area [sector_num, sector_num+n).  */
@@ -138,7 +137,7 @@ wait:
             copy = (ret == 1);
         }
         trace_stream_one_iteration(s, sector_num, n, ret);
-        if (ret >= 0 && copy) {
+        if (copy) {
             if (s->common.speed) {
                 delay_ns = ratelimit_calculate_delay(&s->limit, n);
                 if (delay_ns > 0) {
-- 
1.7.10.4

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

end of thread, other threads:[~2013-09-20 10:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-17 16:43 [Qemu-devel] [PATCH] block: Fix compiler warning (-Werror=uninitialized) Stefan Weil
2013-09-19 14:44 ` Stefan Hajnoczi
2013-09-19 16:59 ` Andreas Färber
2013-09-19 17:22   ` Paolo Bonzini
2013-09-20 10:42   ` Stefan Hajnoczi

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).