From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 169645A026D for ; Thu, 16 Feb 2023 06:43:20 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PHP4K4VcDz4x5X; Thu, 16 Feb 2023 16:43:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1676526193; bh=J3b6nvJVPDuL3+qvpD8LrBMi955nHzcjjWd8ttxE1+I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PZAI9HxBNnkDAKodPMVQWUhA0FMck4TJbIFmQ8uyde5dIhUvrlySrlEUPbC8wT5Ek WlPrUd8SdH+daaeRTyiXBES1yj927JbqATrXFjE/wlhwCFCA8GKg5XHHVRjTyuvIOb oSit1Q4UGOxBWWyp/yo4455OtRy0N+o3t+aKSBZI= Date: Thu, 16 Feb 2023 14:47:23 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] tap: Use single counter for iov elements in tap_send_frames_pasta() Message-ID: References: <20230216010819.2224243-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="SeWl3ZmUdqWSlcYy" Content-Disposition: inline In-Reply-To: <20230216010819.2224243-1-sbrivio@redhat.com> Message-ID-Hash: RXUWOYENITQ75SQH6HYSTMPUXMPBIUQF X-Message-ID-Hash: RXUWOYENITQ75SQH6HYSTMPUXMPBIUQF X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --SeWl3ZmUdqWSlcYy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 16, 2023 at 02:08:19AM +0100, Stefano Brivio wrote: > David points out that using multiple counters to go over the iov > array, namely 'i' and 'iov', makes mistakes easier. We can't just use > 'iov', unless we reserve an element with zero iov_len at the end, > which isn't really justified. >=20 > Simply use 'i' to iterate over the array. >=20 > Link: https://archives.passt.top/passt-dev/Y+mfenvLn3VJ7Dg5@yekko/ > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tap.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/tap.c b/tap.c > index 02da84d..e4c5b5b 100644 > --- a/tap.c > +++ b/tap.c > @@ -316,13 +316,13 @@ static void tap_send_frames_pasta(struct ctx *c, > { > size_t i; > =20 > - for (i =3D 0; i < n; i++, iov++) { > - if (write(c->fd_tap, (char *)iov->iov_base, iov->iov_len) < 0) { > + for (i =3D 0; i < n; i++) { > + if (write(c->fd_tap, (char *)iov[i].iov_base, > + iov[i].iov_len) < 0) { > debug("tap write: %s", strerror(errno)); > if (errno !=3D EAGAIN && errno !=3D EWOULDBLOCK) > tap_handler(c, c->fd_tap, EPOLLERR, NULL); > i--; > - iov--; > } > } > } --=20 David Gibson | 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 --SeWl3ZmUdqWSlcYy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmPtp0UACgkQzQJF27ox 2GdIMA//YBmRhV75HzI5LHF37gzWCRo8mcFL1zeoqq+QXmW4pkJJS8r7Lf6+MDTm wInJCSKEISMoCvxypdcCySrlPhXD4bx+uBy6sk0wtXontSHVSM7mcD5YKhbnanAf NcJHIShHVs58VSs6t/JESSwW64jXbPP8ukG3SyyIa5mMb/3l9Jy0ITdpQXoHZMBK 6a5Y0Tj+bW7zsCLRLcgTYibreWW2O0sOviNo36DJQv5EGOGpvGLMUY8qwyhu9ttH 1r36VSSHefv/VRURujd2dd/9D1XceTLDmFo6gCwwtwDSh9Z9HOBl8GaAynKkJq4y GhTnaEjCKvJYnbi/W7BJXzKekVfmaDfwc38VMK+QsidPVO5IJU5xZbHA6ks/Ulnv YgAn1xpDe+1xUmDWHpmX7cd0RwuNiXonrns+fGXXq6/8grgx0uJ6W5BREHBtay45 V3Vd9UXf6iRKZh6ZaTf7au6QiBL/BKu63bdwL2VpjoMlbHewMyfrZuZYAEPq/t9e B7e+J+/CdYqblWYjYeZ9UUwaBwjEM+Q8dwrv6L5o7yFTcAsAhNGKjNB8YIpIiZuD O9Os1BHmke8rLVVqAgxi1BMXu04qzw2zCrcgK82eqgvKSR2N4P9MQSTkVdSCR2M3 sVQKE6BTe17Lrtp1oGIyImZAbhfxHXMJ+9wn6h/uU76lUxIHsCY= =xXSH -----END PGP SIGNATURE----- --SeWl3ZmUdqWSlcYy--