qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] nbd/server: Silence gcc false positive
@ 2018-06-22 12:58 Eric Blake
  2018-06-22 12:59 ` Peter Maydell
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Eric Blake @ 2018-06-22 12:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, Paolo Bonzini, open list:Network Block Dev...

The code has a while() loop that always initialized 'end', and
the loop always executes at least once (as evidenced by the assert()
just prior to the loop).  But some versions of gcc still complain
that 'end' is used uninitialized, so silence them.

Signed-off-by: Eric Blake <eblake@redhat.com>
---

Peter, do you want to apply this directly as a build fix, or shall
I submit a pull request?

 nbd/server.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/nbd/server.c b/nbd/server.c
index 274604609f4..50ac8bfafc6 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1937,7 +1937,7 @@ static unsigned int bitmap_to_extents(BdrvDirtyBitmap *bitmap, uint64_t offset,
                                       unsigned int nb_extents,
                                       bool dont_fragment)
 {
-    uint64_t begin = offset, end;
+    uint64_t begin = offset, end = offset;
     uint64_t overall_end = offset + *length;
     unsigned int i = 0;
     BdrvDirtyBitmapIter *it;
@@ -1977,6 +1977,7 @@ static unsigned int bitmap_to_extents(BdrvDirtyBitmap *bitmap, uint64_t offset,

     bdrv_dirty_bitmap_unlock(bitmap);

+    assert(offset > end);
     *length = end - offset;
     return i;
 }
-- 
2.14.4

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

end of thread, other threads:[~2018-06-22 16:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-22 12:58 [Qemu-devel] [PATCH] nbd/server: Silence gcc false positive Eric Blake
2018-06-22 12:59 ` Peter Maydell
2018-06-22 14:12   ` Peter Maydell
2018-06-22 15:26 ` Eric Blake
2018-06-22 16:31 ` no-reply
2018-06-22 16:34   ` Peter Maydell

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