In some cases, it may be useful to provide a way to skip a number of bytes in a vringh_iov. In order to keep vringh_iov consistent, let's reuse vringh_iov_xfer() logic and skip bytes when the ptr is NULL. Signed-off-by: Stefano Garzarella <sgarzare@xxxxxxxxxx> --- I'm not sure if this is the best option, maybe we can add a new function vringh_iov_skip(). Suggestions? --- drivers/vhost/vringh.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c index 8bd8b403f087..ed3290946ad7 100644 --- a/drivers/vhost/vringh.c +++ b/drivers/vhost/vringh.c @@ -75,7 +75,9 @@ static inline int __vringh_get_head(const struct vringh *vrh, return head; } -/* Copy some bytes to/from the iovec. Returns num copied. */ +/* Copy some bytes to/from the iovec. Returns num copied. + * If ptr is NULL, skips at most len bytes. + */ static inline ssize_t vringh_iov_xfer(struct vringh *vrh, struct vringh_kiov *iov, void *ptr, size_t len, @@ -89,12 +91,16 @@ static inline ssize_t vringh_iov_xfer(struct vringh *vrh, size_t partlen; partlen = min(iov->iov[iov->i].iov_len, len); - err = xfer(vrh, iov->iov[iov->i].iov_base, ptr, partlen); - if (err) - return err; + + if (ptr) { + err = xfer(vrh, iov->iov[iov->i].iov_base, ptr, partlen); + if (err) + return err; + ptr += partlen; + } + done += partlen; len -= partlen; - ptr += partlen; iov->consumed += partlen; iov->iov[iov->i].iov_len -= partlen; iov->iov[iov->i].iov_base += partlen; -- 2.26.2 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization