]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
nbd: Silence Coverity false positive
authorEric Blake <eblake@redhat.com>
Fri, 6 Nov 2020 20:36:11 +0000 (14:36 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 16 Nov 2020 20:51:12 +0000 (14:51 -0600)
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.  Adding a cast to void, plus a comment why, pacifies
Coverity.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20201111163510.713855-1-eblake@redhat.com>
[eblake: Prefer cast to void over odd && usage]
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
nbd/server.c

index d145e1a690834dae403fbb43c912627f90db1164..613ed2634ada0e629a4ec087d4591fbdf7d14658 100644 (file)
@@ -2129,8 +2129,8 @@ static void bitmap_to_extents(BdrvDirtyBitmap *bitmap,
     }
 
     if (!full) {
-        /* last non dirty extent */
-        nbd_extent_array_add(es, end - start, 0);
+        /* last non dirty extent, nothing to do if array is now full */
+        (void) nbd_extent_array_add(es, end - start, 0);
     }
 
     bdrv_dirty_bitmap_unlock(bitmap);