Skip to contentSkip to conversation

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

PATCH Applied Vladimir Sementsov-Ogievskiy 2 participants 2 messages Sep 10, 2019 – Sep 12, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Reported-by Coverity (CID 1405302)
---
 util/iov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
util/iov.c +2 -1
index 5059e10431..a4689ff3c9 100644
@@ -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;
Signature · 1 line
2.18.0
#1 lore raw
Quoted 11 lines · Vladimir Sementsov-Ogievskiy

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