On Wed, Jul 08, 2026 at 06:31:58PM -0400, Jon Maloy wrote: > iov_tail_clone() returns ssize_t, but its return value was assigned > directly to msg.msg_iovlen which is size_t. Add an assert to document > the invariant that the clone into a VIRTQUEUE_MAX_SIZE array cannot Nit: I think s/invariant/assumption/ would be clearer. > fail. > > Signed-off-by: Jon Maloy Reviewed-by: David Gibson > --- > udp_vu.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/udp_vu.c b/udp_vu.c > index e4fb1057..5d6f45ec 100644 > --- a/udp_vu.c > +++ b/udp_vu.c > @@ -67,11 +67,14 @@ static ssize_t udp_vu_sock_recv(struct iov_tail *payload, size_t *cnt, int s) > struct iovec msg_iov[VIRTQUEUE_MAX_SIZE]; > struct msghdr msg = { 0 }; > size_t iov_used; > + ssize_t iovlen; > ssize_t dlen; > > + iovlen = iov_tail_clone(msg_iov, ARRAY_SIZE(msg_iov), payload); > + assert(iovlen >= 0); > + > msg.msg_iov = msg_iov; > - msg.msg_iovlen = iov_tail_clone(msg.msg_iov, ARRAY_SIZE(msg_iov), > - payload); > + msg.msg_iovlen = iovlen; > > /* read data from the socket */ > dlen = recvmsg(s, &msg, 0); > -- > 2.52.0 > -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson