summaryrefslogtreecommitdiff
path: root/block/parallels.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2015-04-28 10:46:40 +0300
committerStefan Hajnoczi <stefanha@redhat.com>2015-05-22 09:37:31 +0100
commit912f31281a683a24b552a8cc6c293ab389b62013 (patch)
tree60dd63d9b7bdcbdc0e8d9b53d627e2c10ae596c6 /block/parallels.c
parent481fb9cf18925eab19e4af8a44bd86b82eb897ad (diff)
downloadqemu-912f31281a683a24b552a8cc6c293ab389b62013.tar.gz
block/parallels: replace magic constants 4, 64 with proper sizeofs
simple purification.. Signed-off-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Roman Kagan <rkagan@parallels.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Roman Kagan <rkagan@parallels.com> Message-id: 1430207220-24458-8-git-send-email-den@openvz.org CC: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/parallels.c')
-rw-r--r--block/parallels.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/block/parallels.c b/block/parallels.c
index f3ffecec34..138e61812c 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -32,7 +32,6 @@
#define HEADER_MAGIC "WithoutFreeSpace"
#define HEADER_MAGIC2 "WithouFreSpacExt"
#define HEADER_VERSION 2
-#define HEADER_SIZE 64
// always little-endian
typedef struct ParallelsHeader {
@@ -67,7 +66,7 @@ static int parallels_probe(const uint8_t *buf, int buf_size, const char *filenam
{
const ParallelsHeader *ph = (const void *)buf;
- if (buf_size < HEADER_SIZE)
+ if (buf_size < sizeof(ParallelsHeader))
return 0;
if ((!memcmp(ph->magic, HEADER_MAGIC, 16) ||
@@ -120,7 +119,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
}
s->catalog_size = le32_to_cpu(ph.catalog_entries);
- if (s->catalog_size > INT_MAX / 4) {
+ if (s->catalog_size > INT_MAX / sizeof(uint32_t)) {
error_setg(errp, "Catalog too large");
ret = -EFBIG;
goto fail;
@@ -131,7 +130,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
- ret = bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4);
+ ret = bdrv_pread(bs->file, sizeof(ParallelsHeader),
+ s->catalog_bitmap, s->catalog_size * sizeof(uint32_t));
if (ret < 0) {
goto fail;
}