From nobody Wed Nov 5 17:48:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496392011308543.4717952727075; Fri, 2 Jun 2017 01:26:51 -0700 (PDT) Received: from localhost ([::1]:48496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGhuz-0006Za-Qx for importer@patchew.org; Fri, 02 Jun 2017 04:26:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGhkE-0005dp-UC for qemu-devel@nongnu.org; Fri, 02 Jun 2017 04:15:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGhk9-0004HM-VN for qemu-devel@nongnu.org; Fri, 02 Jun 2017 04:15:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGhk9-0004HE-Pd for qemu-devel@nongnu.org; Fri, 02 Jun 2017 04:15:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CEB1E659AD for ; Fri, 2 Jun 2017 08:15:36 +0000 (UTC) Received: from localhost (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0760E7A402; Fri, 2 Jun 2017 08:15:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CEB1E659AD Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CEB1E659AD From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 2 Jun 2017 12:15:19 +0400 Message-Id: <20170602081519.15648-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 02 Jun 2017 08:15:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] vhost-user-bridge: fix iov_restore_front() warning X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , dgilbert@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" CC tests/vhost-user-bridge.o /home/dgilbert/git/qemu-world3/tests/vhost-user-bridge.c:228:23: warning: v= ariables 'front' and 'iov' used in loop condition not modified in loop body= [-Wfor-loop-analysis] for (cur =3D front; front !=3D 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 Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Dr. David Alan Gilbert Tested-by: Jens Freimann --- 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); } =20 + +/* 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; =20 - for (cur =3D front; front !=3D iov; cur++) { + for (cur =3D front; cur !=3D iov; cur++) { + assert(bytes >=3D cur->iov_len); bytes -=3D cur->iov_len; } =20 @@ -302,7 +308,8 @@ vubr_backend_recv_cb(int sock, void *ctx) } iov_from_buf(sg, elem->in_num, 0, &hdr, sizeof hdr); total +=3D hdrlen; - assert(iov_discard_front(&sg, &num, hdrlen) =3D=3D hdrlen); + ret =3D iov_discard_front(&sg, &num, hdrlen); + assert(ret =3D=3D hdrlen); } =20 struct msghdr msg =3D { --=20 2.13.0.91.g00982b8dd