qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] util/ioc.c: try to reassure Coverity about qemu_iovec_init_extended
@ 2019-09-10  9:03 Vladimir Sementsov-Ogievskiy
  2019-09-12 16:06 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-09-10  9:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, vsementsov, stefanha, den

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.

Reported-by: Coverity (CID 1405302)
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 util/iov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util/iov.c b/util/iov.c
index 5059e10431..a4689ff3c9 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -446,7 +446,8 @@ void qemu_iovec_init_extended(
         p++;
     }
 
-    if (mid_len) {
+    assert(!mid_niov == !mid_len);
+    if (mid_niov) {
         memcpy(p, mid_iov, mid_niov * sizeof(*p));
         p[0].iov_base = (uint8_t *)p[0].iov_base + mid_head;
         p[0].iov_len -= mid_head;
-- 
2.18.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] util/ioc.c: try to reassure Coverity about qemu_iovec_init_extended
  2019-09-10  9:03 [Qemu-devel] [PATCH] util/ioc.c: try to reassure Coverity about qemu_iovec_init_extended Vladimir Sementsov-Ogievskiy
@ 2019-09-12 16:06 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2019-09-12 16:06 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy; +Cc: peter.maydell, qemu-devel, den

[-- Attachment #1: Type: text/plain, Size: 677 bytes --]

On Tue, Sep 10, 2019 at 12:03:10PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> 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.
> 
> Reported-by: Coverity (CID 1405302)
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  util/iov.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-12 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-10  9:03 [Qemu-devel] [PATCH] util/ioc.c: try to reassure Coverity about qemu_iovec_init_extended Vladimir Sementsov-Ogievskiy
2019-09-12 16:06 ` Stefan Hajnoczi

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).