* [Qemu-devel] [PATCH] block: Fix 32 bit truncation in mark_request_serialising()
@ 2014-02-08 9:47 Kevin Wolf
2014-02-08 9:53 ` Laszlo Ersek
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Wolf @ 2014-02-08 9:47 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, lersek, stefanha
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>
---
block.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index b0c5025..636aa11 100644
--- 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++;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] block: Fix 32 bit truncation in mark_request_serialising()
2014-02-08 9:47 [Qemu-devel] [PATCH] block: Fix 32 bit truncation in mark_request_serialising() Kevin Wolf
@ 2014-02-08 9:53 ` Laszlo Ersek
0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2014-02-08 9:53 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel, stefanha
On 02/08/14 10:47, Kevin Wolf wrote:
> 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>
> ---
> block.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/block.c b/block.c
> index b0c5025..636aa11 100644
> --- 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++;
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Thanks!
Laszlo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-08 9:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-08 9:47 [Qemu-devel] [PATCH] block: Fix 32 bit truncation in mark_request_serialising() Kevin Wolf
2014-02-08 9:53 ` Laszlo Ersek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).