From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH] tap: Use single counter for iov elements in tap_send_frames_pasta()
Date: Thu, 16 Feb 2023 14:47:23 +1100 [thread overview]
Message-ID: <Y+2nS43t5swoXGjG@yekko> (raw)
In-Reply-To: <20230216010819.2224243-1-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1441 bytes --]
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.
>
> Simply use 'i' to iterate over the array.
>
> Link: https://archives.passt.top/passt-dev/Y+mfenvLn3VJ7Dg5@yekko/
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> tap.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> 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;
>
> - for (i = 0; i < n; i++, iov++) {
> - if (write(c->fd_tap, (char *)iov->iov_base, iov->iov_len) < 0) {
> + for (i = 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 != EAGAIN && errno != EWOULDBLOCK)
> tap_handler(c, c->fd_tap, EPOLLERR, NULL);
> i--;
> - iov--;
> }
> }
> }
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2023-02-16 5:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 1:08 [PATCH] tap: Use single counter for iov elements in tap_send_frames_pasta() Stefano Brivio
2023-02-16 3:47 ` David Gibson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+2nS43t5swoXGjG@yekko \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).