49 lines
1.7 KiB
Diff
49 lines
1.7 KiB
Diff
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
Date: Wed, 26 Mar 2014 13:05:59 +0100
|
|
Subject: [PATCH] dmg: use uint64_t consistently for sectors and lengths
|
|
|
|
The DMG metadata is stored as uint64_t, so use the same type for
|
|
sector_num. int was a particularly poor choice since it is only 32-bit
|
|
and would truncate large values.
|
|
|
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
(cherry picked from commit 686d7148ec23402a172628c800022b3a95a022c9)
|
|
---
|
|
block/dmg.c | 6 +++---
|
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/block/dmg.c b/block/dmg.c
|
|
index 1a751ea..5229876 100644
|
|
--- a/block/dmg.c
|
|
+++ b/block/dmg.c
|
|
@@ -280,7 +280,7 @@ fail:
|
|
}
|
|
|
|
static inline int is_sector_in_chunk(BDRVDMGState* s,
|
|
- uint32_t chunk_num, int sector_num)
|
|
+ uint32_t chunk_num, uint64_t sector_num)
|
|
{
|
|
if (chunk_num >= s->n_chunks || s->sectors[chunk_num] > sector_num ||
|
|
s->sectors[chunk_num] + s->sectorcounts[chunk_num] <= sector_num) {
|
|
@@ -290,7 +290,7 @@ static inline int is_sector_in_chunk(BDRVDMGState* s,
|
|
}
|
|
}
|
|
|
|
-static inline uint32_t search_chunk(BDRVDMGState *s, int sector_num)
|
|
+static inline uint32_t search_chunk(BDRVDMGState *s, uint64_t sector_num)
|
|
{
|
|
/* binary search */
|
|
uint32_t chunk1 = 0, chunk2 = s->n_chunks, chunk3;
|
|
@@ -307,7 +307,7 @@ static inline uint32_t search_chunk(BDRVDMGState *s, int sector_num)
|
|
return s->n_chunks; /* error */
|
|
}
|
|
|
|
-static inline int dmg_read_chunk(BlockDriverState *bs, int sector_num)
|
|
+static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num)
|
|
{
|
|
BDRVDMGState *s = bs->opaque;
|
|
|