From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Laurent Vivier <lvivier@redhat.com>
Subject: Re: [PATCH] vu_common: Clarify prototype of vu_collect()
Date: Fri, 5 Dec 2025 13:55:49 +1100 [thread overview]
Message-ID: <aTJJtX9cnc52d_WL@zatzit> (raw)
In-Reply-To: <20251205005105.2577221-1-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2517 bytes --]
On Fri, Dec 05, 2025 at 01:51:05AM +0100, Stefano Brivio wrote:
> The last argument of vu_collect() can't exceed @size, but this isn't
> documented and it wasn't obvious to me, to the point that I actually
> proposed a change to "fix" callers so that they wouldn't overrun input
> buffers.
>
> Rename @frame_size to @collected, and clarify that it can only be up
> to @size bytes.
>
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> vu_common.c | 8 ++++----
> vu_common.h | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/vu_common.c b/vu_common.c
> index b13b7c3..ce61fa6 100644
> --- a/vu_common.c
> +++ b/vu_common.c
> @@ -76,13 +76,13 @@ void vu_init_elem(struct vu_virtq_element *elem, struct iovec *iov, int elem_cnt
> * in the in_sg array.
> * @max_elem: Number of virtqueue elements in the array
> * @size: Maximum size of the data in the frame
> - * @frame_size: The total size of the buffers (output)
> + * @collected: Collected buffer length, up to @size, set on return
> *
> * Return: number of elements used to contain the frame
> */
> int vu_collect(const struct vu_dev *vdev, struct vu_virtq *vq,
> struct vu_virtq_element *elem, int max_elem,
> - size_t size, size_t *frame_size)
> + size_t size, size_t *collected)
> {
> size_t current_size = 0;
> int elem_cnt = 0;
> @@ -113,8 +113,8 @@ int vu_collect(const struct vu_dev *vdev, struct vu_virtq *vq,
> break;
> }
>
> - if (frame_size)
> - *frame_size = current_size;
> + if (collected)
> + *collected = current_size;
>
> return elem_cnt;
> }
> diff --git a/vu_common.h b/vu_common.h
> index f538f23..c0883b2 100644
> --- a/vu_common.h
> +++ b/vu_common.h
> @@ -48,7 +48,7 @@ void vu_init_elem(struct vu_virtq_element *elem, struct iovec *iov,
> int elem_cnt);
> int vu_collect(const struct vu_dev *vdev, struct vu_virtq *vq,
> struct vu_virtq_element *elem, int max_elem, size_t size,
> - size_t *frame_size);
> + size_t *collected);
> void vu_set_vnethdr(const struct vu_dev *vdev,
> struct virtio_net_hdr_mrg_rxbuf *vnethdr,
> int num_buffers);
> --
> 2.43.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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2025-12-05 3:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 0:51 Stefano Brivio
2025-12-05 2:55 ` David Gibson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aTJJtX9cnc52d_WL@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).