qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org
Subject: Re: [PATCH 0/9] More truncate improvements
Date: Wed, 29 Apr 2020 08:14:47 -0500	[thread overview]
Message-ID: <dba78fab-b7a7-1f33-e65d-52d6ab654c46@redhat.com> (raw)
In-Reply-To: <158812705840.2837.3534564330691034557@39012742ff91>

On 4/28/20 9:24 PM, no-reply@patchew.org wrote:
> Patchew URL: https://patchew.org/QEMU/20200428202905.770727-1-eblake@redhat.com/
> 

> /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	other threads:[~2020-04-29 13:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 20:28 [PATCH 0/9] More truncate improvements Eric Blake
2020-04-28 20:28 ` [PATCH 1/9] gluster: Drop useless has_zero_init callback Eric Blake
2020-04-28 20:28 ` [PATCH 2/9] file-win32: Support BDRV_REQ_ZERO_WRITE for truncate Eric Blake
2020-04-28 20:28 ` [PATCH 3/9] nfs: " Eric Blake
2020-04-28 20:29 ` [PATCH 4/9] rbd: " Eric Blake
2020-04-28 20:29 ` [PATCH 5/9] sheepdog: " Eric Blake
2020-04-28 20:29 ` [PATCH 6/9] ssh: " Eric Blake
2020-04-29  9:01   ` Richard W.M. Jones
2020-04-28 20:29 ` [PATCH 7/9] parallels: Rework truncation logic Eric Blake
2020-05-07 11:14   ` Denis V. Lunev
2020-04-28 20:29 ` [PATCH 8/9] vhdx: " Eric Blake
2020-04-28 20:29 ` [PATCH 9/9] block: Drop unused .bdrv_has_zero_init_truncate Eric Blake
2020-04-29  9:02   ` Richard W.M. Jones
2020-04-29  2:24 ` [PATCH 0/9] More truncate improvements no-reply
2020-04-29 13:14   ` Eric Blake [this message]
2020-04-29  2:24 ` no-reply
2020-05-06 13:03 ` Eric Blake
2020-05-07 10:15 ` Kevin Wolf
2020-05-07 14:29   ` Eric Blake
2020-05-07 14:32     ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dba78fab-b7a7-1f33-e65d-52d6ab654c46@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).