[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/14] vmdk: fix maybe uninitialized warnings
From: |
Laurent Vivier |
Subject: |
[PULL 05/14] vmdk: fix maybe uninitialized warnings |
Date: |
Tue, 13 Oct 2020 13:50:43 +0200 |
From: Christian Borntraeger <borntraeger@de.ibm.com>
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>
---
block/vmdk.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 8ec62c7ab798..a00dc00eb47a 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;
--
2.26.2
- [PULL 04/14] tests/test-char: Use a proper fallthrough comment, (continued)
- [PULL 04/14] tests/test-char: Use a proper fallthrough comment, Laurent Vivier, 2020/10/13
- [PULL 03/14] hw/block/nvme: Simplify timestamp sum, Laurent Vivier, 2020/10/13
- [PULL 07/14] softmmu/memory: Log invalid memory accesses, Laurent Vivier, 2020/10/13
- [PULL 06/14] hw/acpi/piix4: Rename piix4_pm_add_propeties() to piix4_pm_add_properties(), Laurent Vivier, 2020/10/13
- [PULL 08/14] hw/pci: Fix typo in PCI hot-plug error message, Laurent Vivier, 2020/10/13
- [PULL 12/14] target/sparc/int32_helper: Remove duplicated 'Tag Overflow' entry, Laurent Vivier, 2020/10/13
- [PULL 09/14] block/blkdebug: fix memory leak, Laurent Vivier, 2020/10/13
- [PULL 10/14] hw/char/serial: remove duplicate .class_init in serial_mm_info, Laurent Vivier, 2020/10/13
- [PULL 11/14] goldfish_rtc: change MemoryRegionOps endianness to DEVICE_NATIVE_ENDIAN, Laurent Vivier, 2020/10/13
- [PULL 13/14] mingw: fix error __USE_MINGW_ANSI_STDIO redefined, Laurent Vivier, 2020/10/13
- [PULL 05/14] vmdk: fix maybe uninitialized warnings,
Laurent Vivier <=
- [PULL 14/14] meson.build: drop duplicate 'sparc64' entry, Laurent Vivier, 2020/10/13
- Re: [PULL 00/14] Trivial branch for 5.2 patches, Peter Maydell, 2020/10/13