qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, vsementsov@virtuozzo.com,
	"open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: [PATCH for-5.2?] nbd: Silence Coverity false positive
Date: Wed, 11 Nov 2020 10:35:10 -0600	[thread overview]
Message-ID: <20201111163510.713855-1-eblake@redhat.com> (raw)

Coverity noticed (CID 1436125) that we check the return value of
nbd_extent_array_add in most places, but not at the end of
bitmap_to_extents().  The return value exists to break loops before a
future iteration, so there is nothing to check if we are already done
iterating.  That said, a minor rearrangement to the code plus a better
comment pacifies Coverity.

Signed-off-by: Eric Blake <eblake@redhat.com>
---

Not a show-stopper by itself for 5.2, but perhaps worth including
in -rc2 if I collect other more-important patches.

 nbd/server.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/nbd/server.c b/nbd/server.c
index d145e1a69083..377698a2ce85 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -2128,9 +2128,8 @@ static void bitmap_to_extents(BdrvDirtyBitmap *bitmap,
         }
     }

-    if (!full) {
-        /* last non dirty extent */
-        nbd_extent_array_add(es, end - start, 0);
+    if (!full && nbd_extent_array_add(es, end - start, 0) < 0) {
+        /* last non dirty extent, nothing to do if array was already full */
     }

     bdrv_dirty_bitmap_unlock(bitmap);
-- 
2.28.0



             reply	other threads:[~2020-11-11 16:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 16:35 Eric Blake [this message]
2020-11-12 21:04 ` [PATCH for-5.2?] nbd: Silence Coverity false positive Richard Henderson
2020-11-12 21:09   ` Eric Blake
2020-11-12 21:18     ` Richard Henderson

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=20201111163510.713855-1-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /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).