aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2019-10-11 17:28:00 +0200
committerMax Reitz <mreitz@redhat.com>2019-10-28 11:51:08 +0100
commitd8fa8442ad4bdc869afd847ebb8e0fcedff6968c (patch)
treecfbc3b5c79255356a31c6de6afa96dadb31d01dd /block
parent5d5b33c08031cfe0e9872bde1f9dcb2215f9b30a (diff)
downloadqemu-d8fa8442ad4bdc869afd847ebb8e0fcedff6968c.zip
qemu-d8fa8442ad4bdc869afd847ebb8e0fcedff6968c.tar.gz
qemu-d8fa8442ad4bdc869afd847ebb8e0fcedff6968c.tar.bz2
qcow2: Use endof()
Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20191011152814.14791-3-mreitz@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/qcow2-snapshot.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index d0e7fa9..752883e 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -92,11 +92,12 @@ int qcow2_read_snapshots(BlockDriverState *bs)
}
offset += extra_data_size;
- if (extra_data_size >= 8) {
+ if (extra_data_size >= endof(QCowSnapshotExtraData,
+ vm_state_size_large)) {
sn->vm_state_size = be64_to_cpu(extra.vm_state_size_large);
}
- if (extra_data_size >= 16) {
+ if (extra_data_size >= endof(QCowSnapshotExtraData, disk_size)) {
sn->disk_size = be64_to_cpu(extra.disk_size);
} else {
sn->disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
@@ -251,7 +252,7 @@ static int qcow2_write_snapshots(BlockDriverState *bs)
}
QEMU_BUILD_BUG_ON(offsetof(QCowHeader, snapshots_offset) !=
- offsetof(QCowHeader, nb_snapshots) + sizeof(header_data.nb_snapshots));
+ endof(QCowHeader, nb_snapshots));
header_data.nb_snapshots = cpu_to_be32(s->nb_snapshots);
header_data.snapshots_offset = cpu_to_be64(snapshots_offset);