[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] vhost-user-bridge: fix iov_restore_front() warn
From: |
Jens Freimann |
Subject: |
Re: [Qemu-devel] [PATCH] vhost-user-bridge: fix iov_restore_front() warning |
Date: |
Fri, 2 Jun 2017 14:43:02 +0200 |
User-agent: |
NeoMutt/20170428 (1.8.2) |
On Fri, Jun 02, 2017 at 12:15:19PM +0400, Marc-André Lureau wrote:
> CC tests/vhost-user-bridge.o
> /home/dgilbert/git/qemu-world3/tests/vhost-user-bridge.c:228:23: warning:
> variables 'front' and 'iov' used in loop condition not modified in loop body
> [-Wfor-loop-analysis]
> for (cur = front; front != iov; cur++) {
> ^~~~~ ~~~
> 1 warning generated.
>
> Fix the loop, document the function, and fix some related assert().
>
> In practice, the loop bug was harmless because the front sg buffer is
> enough to discard/restore the header size.
>
> Reported-by: Dr. David Alan Gilbert <address@hidden>
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
> tests/vhost-user-bridge.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c
> index 8618c20d53..1e5b5ca3da 100644
> --- a/tests/vhost-user-bridge.c
> +++ b/tests/vhost-user-bridge.c
> @@ -220,12 +220,18 @@ vubr_handle_tx(VuDev *dev, int qidx)
> free(elem);
> }
>
> +
> +/* this function reverse the effect of iov_discard_front() it must be
> + * called with 'front' being the original struct iovec and 'bytes'
> + * being the number of bytes you shaved off
> + */
> static void
> iov_restore_front(struct iovec *front, struct iovec *iov, size_t bytes)
> {
> struct iovec *cur;
>
> - for (cur = front; front != iov; cur++) {
> + for (cur = front; cur != iov; cur++) {
> + assert(bytes >= cur->iov_len);
> bytes -= cur->iov_len;
This fixes a problem I saw when trying to pxe-boot
with vhost-user and vhost-user-bridge. It was running in an endless
loop here. Fixed with this patch.
Tested-by: Jens Freimann <address@hidden>
regards,
Jens