summaryrefslogtreecommitdiffstats
path: root/nbd
diff options
context:
space:
mode:
authorEric Blake2018-06-22 14:58:14 +0200
committerPeter Maydell2018-06-22 15:18:36 +0200
commit45eb6fb6cea28cdc937764aac6585751047bb294 (patch)
tree6b14129f199ca6320466eb1af4558e8252e80ace /nbd
parentMerge remote-tracking branch 'remotes/dgilbert/tags/pull-hmp-20180621' into s... (diff)
downloadqemu-45eb6fb6cea28cdc937764aac6585751047bb294.tar.gz
qemu-45eb6fb6cea28cdc937764aac6585751047bb294.tar.xz
qemu-45eb6fb6cea28cdc937764aac6585751047bb294.zip
nbd/server: Silence gcc false positive
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> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20180622125814.345274-1-eblake@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'nbd')
-rw-r--r--nbd/server.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/nbd/server.c b/nbd/server.c
index 274604609f..50ac8bfafc 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;
}