thebeanogamer / rpms / qemu-kvm

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