thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
26ba25
From c24b1c565318bada6133e9489d9fcf8f589da56f Mon Sep 17 00:00:00 2001
26ba25
From: John Snow <jsnow@redhat.com>
26ba25
Date: Wed, 18 Jul 2018 22:55:07 +0200
26ba25
Subject: [PATCH 249/268] nbd/server: Silence gcc false positive
26ba25
26ba25
RH-Author: John Snow <jsnow@redhat.com>
26ba25
Message-id: <20180718225511.14878-32-jsnow@redhat.com>
26ba25
Patchwork-id: 81425
26ba25
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 31/35] nbd/server: Silence gcc false positive
26ba25
Bugzilla: 1207657
26ba25
RH-Acked-by: Eric Blake <eblake@redhat.com>
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
RH-Acked-by: Fam Zheng <famz@redhat.com>
26ba25
26ba25
From: Eric Blake <eblake@redhat.com>
26ba25
26ba25
The code has a while() loop that always initialized 'end', and
26ba25
the loop always executes at least once (as evidenced by the assert()
26ba25
just prior to the loop).  But some versions of gcc still complain
26ba25
that 'end' is used uninitialized, so silence them.
26ba25
26ba25
Signed-off-by: Eric Blake <eblake@redhat.com>
26ba25
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
26ba25
Message-id: 20180622125814.345274-1-eblake@redhat.com
26ba25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26ba25
(cherry picked from commit 45eb6fb6cea28cdc937764aac6585751047bb294)
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 nbd/server.c | 3 ++-
26ba25
 1 file changed, 2 insertions(+), 1 deletion(-)
26ba25
26ba25
diff --git a/nbd/server.c b/nbd/server.c
26ba25
index 2746046..50ac8bf 100644
26ba25
--- a/nbd/server.c
26ba25
+++ b/nbd/server.c
26ba25
@@ -1937,7 +1937,7 @@ static unsigned int bitmap_to_extents(BdrvDirtyBitmap *bitmap, uint64_t offset,
26ba25
                                       unsigned int nb_extents,
26ba25
                                       bool dont_fragment)
26ba25
 {
26ba25
-    uint64_t begin = offset, end;
26ba25
+    uint64_t begin = offset, end = offset;
26ba25
     uint64_t overall_end = offset + *length;
26ba25
     unsigned int i = 0;
26ba25
     BdrvDirtyBitmapIter *it;
26ba25
@@ -1977,6 +1977,7 @@ static unsigned int bitmap_to_extents(BdrvDirtyBitmap *bitmap, uint64_t offset,
26ba25
 
26ba25
     bdrv_dirty_bitmap_unlock(bitmap);
26ba25
 
26ba25
+    assert(offset > end);
26ba25
     *length = end - offset;
26ba25
     return i;
26ba25
 }
26ba25
-- 
26ba25
1.8.3.1
26ba25