summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristian Borntraeger2020-09-30 17:58:56 +0200
committerLaurent Vivier2020-10-13 13:33:45 +0200
commitcd466702f042f435cf8661e2cdcafeb0482e6b3d (patch)
treefd66eb8ea6d2ea96cba3d386c50f580b309e88a8 /block
parenttests/test-char: Use a proper fallthrough comment (diff)
downloadqemu-cd466702f042f435cf8661e2cdcafeb0482e6b3d.tar.gz
qemu-cd466702f042f435cf8661e2cdcafeb0482e6b3d.tar.xz
qemu-cd466702f042f435cf8661e2cdcafeb0482e6b3d.zip
vmdk: fix maybe uninitialized warnings
Fedora 32 gcc 10 seems to give false positives: Compiling C object libblock.fa.p/block_vmdk.c.o ../block/vmdk.c: In function ‘vmdk_parse_extents’: ../block/vmdk.c:587:5: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 587 | g_free(extent->l1_table); | ^~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:754:17: note: ‘extent’ was declared here 754 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 620 | ret = vmdk_init_tables(bs, extent, errp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:598:17: note: ‘extent’ was declared here 598 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c:1178:39: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1178 | extent->flat_start_offset = flat_offset << 9; | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ ../block/vmdk.c: In function ‘vmdk_open_vmdk4’: ../block/vmdk.c:581:22: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 581 | extent->l2_cache = | ~~~~~~~~~~~~~~~~~^ 582 | g_malloc(extent->entry_size * extent->l2_size * L2_CACHE_SIZE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:872:17: note: ‘extent’ was declared here 872 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c: In function ‘vmdk_open’: ../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 620 | ret = vmdk_init_tables(bs, extent, errp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:598:17: note: ‘extent’ was declared here 598 | VmdkExtent *extent; | ^~~~~~ cc1: all warnings being treated as errors make: *** [Makefile.ninja:884: libblock.fa.p/block_vmdk.c.o] Error 1 fix them by assigning a default value. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Fam Zheng <fam@euphon.net> Message-Id: <20200930155859.303148-2-borntraeger@de.ibm.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'block')
-rw-r--r--block/vmdk.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/block/vmdk.c b/block/vmdk.c
index 8ec62c7ab7..a00dc00eb4 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -595,7 +595,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
int ret;
uint32_t magic;
VMDK3Header header;
- VmdkExtent *extent;
+ VmdkExtent *extent = NULL;
ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header));
if (ret < 0) {
@@ -751,7 +751,7 @@ static int vmdk_open_se_sparse(BlockDriverState *bs,
int ret;
VMDKSESparseConstHeader const_header;
VMDKSESparseVolatileHeader volatile_header;
- VmdkExtent *extent;
+ VmdkExtent *extent = NULL;
ret = bdrv_apply_auto_read_only(bs,
"No write support for seSparse images available", errp);
@@ -869,7 +869,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
uint32_t magic;
uint32_t l1_size, l1_entry_sectors;
VMDK4Header header;
- VmdkExtent *extent;
+ VmdkExtent *extent = NULL;
BDRVVmdkState *s = bs->opaque;
int64_t l1_backup_offset = 0;
bool compressed;
@@ -1088,7 +1088,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
BdrvChild *extent_file;
BdrvChildRole extent_role;
BDRVVmdkState *s = bs->opaque;
- VmdkExtent *extent;
+ VmdkExtent *extent = NULL;
char extent_opt_prefix[32];
Error *local_err = NULL;