mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	ppandit@redhat.com
Subject: Re: [PATCH net] vhost_net: fix possible infinite loop
Date: Wed, 15 May 2019 10:57:27 +0800	[thread overview]
Message-ID: <4b51161e-37b1-cf76-d418-1574b8f6e73b@redhat.com> (raw)
In-Reply-To: <20190514173016-mutt-send-email-mst@kernel.org>


On 2019/5/15 上午5:39, Michael S. Tsirkin wrote:
> Let me try to explain again.
> At the moment how does handle_tx_copy exit?
> It's for(;;) so you know you need to look for a break.
>
> When reading code you also notice there's a goto done
> which could exit the loop. if you scan forward
> you notice that it does not.
> This is confusing, but oh well. Worth fixing maybe ...
>
> Now you add the next round check.
> And there is also special code that
> detects whether you exited with break
> and whenever you did it acts specially.
>
> Yea it works. But I think it's clearer if we
> just make things obvious.
> If we want something to happen on error then
>
> 	if (error)
> 		handle
> 		break
>
> is imho clearer than
>
> 	flag = true
> 	if (error)
> 		break
> 	flag = false
>
>
> if (flag)
> 	handle
>
> in partucular - less branches on data path.
>
> you point out code duplication correctly,
> but we can solve it just by adding functions.
> like i suggested.


Ok, I think I get you.

Will try in next version.

Thanks


      reply	other threads:[~2019-05-15  2:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25  7:33 Jason Wang
2019-04-25 17:52 ` Michael S. Tsirkin
2019-04-26  7:35   ` Jason Wang
2019-05-05  4:20     ` Jason Wang
2019-05-12 17:10       ` Michael S. Tsirkin
2019-05-13  5:42         ` Jason Wang
2019-05-14 21:39           ` Michael S. Tsirkin
2019-05-15  2:57             ` Jason Wang [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=4b51161e-37b1-cf76-d418-1574b8f6e73b@redhat.com \
    --to=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=ppandit@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®