On 4/28/20 9:24 PM, [email protected] wrote:
Patchew URL: https://patchew.org/QEMU/[email protected]/
/tmp/qemu-test/src/block/parallels.c: In function 'parallels_co_writev':
/tmp/qemu-test/src/block/parallels.c:218:12: error: 'ret' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
if (ret < 0) {
^
/tmp/qemu-test/src/block/parallels.c:169:9: note: 'ret' was declared here
int ret;
^
False positive: the code is roughly:
int ret;
if (cond1) {
ret = ...;
}
if (cond2) {
ret = ...;
}
if (ret < 0)
but the compiler can't prove that cond1 + cond2 covers all
possibilities. The obvious fix is to initialize ret; squash this into 7/9:
diff --git i/block/parallels.c w/block/parallels.c
index eb6c6c01b998..e7717c508e62 100644
--- i/block/parallels.c
+++ w/block/parallels.c
@@ -166,7 +166,7 @@ static int64_t block_status(BDRVParallelsState *s,
int64_t sector_num,
static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int *pnum)
{
- int ret;
+ int ret = 0;
BDRVParallelsState *s = bs->opaque;
int64_t pos, space, idx, to_allocate, i, len;
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org