]> Git Repo - qemu.git/commitdiff
block/parallels: replace magic constants 4, 64 with proper sizeofs
authorDenis V. Lunev <[email protected]>
Tue, 28 Apr 2015 07:46:40 +0000 (10:46 +0300)
committerStefan Hajnoczi <[email protected]>
Fri, 22 May 2015 08:37:31 +0000 (09:37 +0100)
simple purification..

Signed-off-by: Denis V. Lunev <[email protected]>
Reviewed-by: Roman Kagan <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Roman Kagan <[email protected]>
Message-id: 1430207220[email protected]
CC: Kevin Wolf <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
block/parallels.c

index f3ffecec34ae14bf81de8eca07cb2861e7084434..138e61812cfdda835bd79f5521fd2c4a1c637865 100644 (file)
@@ -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;
     }
This page took 0.029761 seconds and 4 git commands to generate.