iov: Helper macro to construct iovs covering existing variables or fields

Laurent's recent changes mean we use IO vectors much more heavily in the
TCP code.  In many of those cases, and few others around the code base,
individual iovs of these vectors are constructed to exactly cover existing
variables or fields.  We can make initializing such iovs shorter and
clearer with a macro for the purpose.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson
2024-05-01 16:53:52 +10:00
committed by Stefano Brivio
parent 40f8b2976a
commit 3559899586
4 changed files with 16 additions and 21 deletions

3
tap.c
View File

@@ -79,8 +79,7 @@ void tap_send_single(const struct ctx *c, const void *data, size_t l2len)
size_t iovcnt = 0;
if (c->mode == MODE_PASST) {
iov[iovcnt].iov_base = &vnet_len;
iov[iovcnt].iov_len = sizeof(vnet_len);
iov[iovcnt] = IOV_OF_LVALUE(vnet_len);
iovcnt++;
}