From 68dbc9269577747455be55f209066926d1994d3c Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Sat, 8 Feb 2014 10:42:18 +0100 Subject: [PATCH 22/37] block: Fix 32 bit truncation in mark_request_serialising() Message-id: <1392117622-28812-23-git-send-email-kwolf@redhat.com> Patchwork-id: 57187 O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 22/37] block: Fix 32 bit truncation in mark_request_serialising() Bugzilla: 748906 RH-Acked-by: Laszlo Ersek RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Max Reitz 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 Reviewed-by: Laszlo Ersek Signed-off-by: Kevin Wolf --- block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- block.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 24e94e6..94fd702 100644 --- a/block.c +++ b/block.c @@ -2088,11 +2088,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++; -- 1.7.1