aboutsummaryrefslogtreecommitdiff
path: root/block/vpc.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-12-17 17:20:00 +0100
committerKevin Wolf <kwolf@redhat.com>2020-12-18 12:43:23 +0100
commit3d6101a3f2c88176b3abfe60b0759a75243d0592 (patch)
tree32ff7b427f9d025b0b60c57dca83b83c9d1f386d /block/vpc.c
parente326f0783ed06ed7360f63c7223424cc1d910406 (diff)
downloadqemu-3d6101a3f2c88176b3abfe60b0759a75243d0592.zip
qemu-3d6101a3f2c88176b3abfe60b0759a75243d0592.tar.gz
qemu-3d6101a3f2c88176b3abfe60b0759a75243d0592.tar.bz2
block/vpc: Use sizeof() instead of 1024 for dynamic header size
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20201217162003.1102738-7-armbru@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/vpc.c')
-rw-r--r--block/vpc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/block/vpc.c b/block/vpc.c
index 08a0f71..6cb656a 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -344,7 +344,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
if (disk_type == VHD_DYNAMIC) {
ret = bdrv_pread(bs->file, be64_to_cpu(footer->data_offset),
- &dyndisk_header, 1024);
+ &dyndisk_header, sizeof(dyndisk_header));
if (ret < 0) {
error_setg(errp, "Error reading dynamic VHD header");
goto fail;
@@ -858,7 +858,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
}
/* Prepare the Dynamic Disk Header */
- memset(&dyndisk_header, 0, 1024);
+ memset(&dyndisk_header, 0, sizeof(dyndisk_header));
memcpy(dyndisk_header.magic, "cxsparse", 8);
@@ -872,12 +872,13 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
dyndisk_header.block_size = cpu_to_be32(block_size);
dyndisk_header.max_table_entries = cpu_to_be32(num_bat_entries);
- dyndisk_header.checksum = cpu_to_be32(vpc_checksum(&dyndisk_header, 1024));
+ dyndisk_header.checksum = cpu_to_be32(
+ vpc_checksum(&dyndisk_header, sizeof(dyndisk_header)));
/* Write the header */
offset = 512;
- ret = blk_pwrite(blk, offset, &dyndisk_header, 1024, 0);
+ ret = blk_pwrite(blk, offset, &dyndisk_header, sizeof(dyndisk_header), 0);
if (ret < 0) {
goto fail;
}