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 <ebl...@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