]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Fix 32 bit truncation in mark_request_serialising()
authorKevin Wolf <kwolf@redhat.com>
Sat, 8 Feb 2014 09:42:18 +0000 (10:42 +0100)
committerKevin Wolf <kwolf@redhat.com>
Sun, 9 Feb 2014 08:12:39 +0000 (09:12 +0100)
On 32 bit hosts, size_t is too small for align as the bitmask
~(align - 1) will zero out the higher 32 bits of the offset.

While at it, change the local overlap_bytes variable to unsigned to
match the field in BdrvTrackedRequest.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
block.c

diff --git a/block.c b/block.c
index b0c5025977f49ce1d8a71c6d66ef52f4c84ed96a..636aa117c3099efc28dea7144d0d47d01e64ac41 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2240,11 +2240,11 @@ static void tracked_request_begin(BdrvTrackedRequest *req,
     QLIST_INSERT_HEAD(&bs->tracked_requests, req, list);
 }
 
-static void mark_request_serialising(BdrvTrackedRequest *req, size_t align)
+static void mark_request_serialising(BdrvTrackedRequest *req, uint64_t align)
 {
     int64_t overlap_offset = req->offset & ~(align - 1);
-    int overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
-                      - overlap_offset;
+    unsigned int overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
+                               - overlap_offset;
 
     if (!req->serialising) {
         req->bs->serialising_in_flight++;