diff options
| author | Stefano Brivio <sbrivio@redhat.com> | 2025-12-04 23:18:51 +0100 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2025-12-07 23:18:04 +0100 |
| commit | 834982c0a35145754de38f77de6e41815cb33178 (patch) | |
| tree | 39bf623cb8f1a7657981a33f00a6f70a1c35e008 | |
| parent | 7c7be67ddf264281f192084521af23a1c429dd99 (diff) | |
| download | passt-834982c0a35145754de38f77de6e41815cb33178.tar passt-834982c0a35145754de38f77de6e41815cb33178.tar.gz passt-834982c0a35145754de38f77de6e41815cb33178.tar.bz2 passt-834982c0a35145754de38f77de6e41815cb33178.tar.lz passt-834982c0a35145754de38f77de6e41815cb33178.tar.xz passt-834982c0a35145754de38f77de6e41815cb33178.tar.zst passt-834982c0a35145754de38f77de6e41815cb33178.zip | |
vu_common: Clarify prototype of vu_collect()
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>
| -rw-r--r-- | vu_common.c | 8 | ||||
| -rw-r--r-- | 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); |
