qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/9] More truncate improvements


From: Eric Blake
Subject: Re: [PATCH 0/9] More truncate improvements
Date: Wed, 29 Apr 2020 08:14:47 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 4/28/20 9:24 PM, address@hidden wrote:
Patchew URL: https://patchew.org/QEMU/address@hidden/


/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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]