From 47ebd5fed1ad96130b51f9518f86cd6e34faef38 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 25 Mar 2014 11:46:00 +0100 Subject: [PATCH 42/48] dmg: use uint64_t consistently for sectors and lengths RH-Author: Kevin Wolf Message-id: <1395744364-16049-42-git-send-email-kwolf@redhat.com> Patchwork-id: n/a O-Subject: [EMBARGOED RHEL-6.6/6.5.z qemu-kvm PATCH v2 41/45] dmg: use uint64_t consistently for sectors and lengths Bugzilla: 1079518 RH-Acked-by: Max Reitz RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Laszlo Ersek Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1079518 Upstream status: Series embargoed 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 Signed-off-by: Kevin Wolf --- block/dmg.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index eb1717d..93786fe 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -273,7 +273,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) { @@ -283,7 +283,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; @@ -300,7 +300,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; -- 1.7.1