qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

util/ioc.c: try to reassure Coverity about qemu_iovec_init_extended

Make it more obvious, that filling qiov corresponds to qiov allocation,
which in turn corresponds to total_niov calculation, based on mid_niov
(not mid_len). Still add an assertion to show that there should be no
difference.

[Added mingw "error: 'mid_iov' may be used uninitialized in this
function" compiler error fix suggested by Vladimir.
--Stefan]

Reported-by: Coverity (CID 1405302)
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-id: 20190910090310.14032-1-vsementsov@virtuozzo.com
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190910090310.14032-1-vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

fixup! util/ioc.c: try to reassure Coverity about qemu_iovec_init_extended

authored by

Vladimir Sementsov-Ogievskiy and committed by
Stefan Hajnoczi
d38d6de2 560009f2

+3 -2
+3 -2
util/iov.c
··· 423 423 { 424 424 size_t mid_head, mid_tail; 425 425 int total_niov, mid_niov = 0; 426 - struct iovec *p, *mid_iov; 426 + struct iovec *p, *mid_iov = NULL; 427 427 428 428 if (mid_len) { 429 429 mid_iov = qiov_slice(mid_qiov, mid_offset, mid_len, ··· 446 446 p++; 447 447 } 448 448 449 - if (mid_len) { 449 + assert(!mid_niov == !mid_len); 450 + if (mid_niov) { 450 451 memcpy(p, mid_iov, mid_niov * sizeof(*p)); 451 452 p[0].iov_base = (uint8_t *)p[0].iov_base + mid_head; 452 453 p[0].iov_len -= mid_head;