From: Andrea Parri <parri.andrea@gmail.com>
To: Michael Kelley <mikelley@microsoft.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
KY Srinivasan <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Sasha Levin <sashal@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
vkuznets <vkuznets@redhat.com>, Dexuan Cui <decui@microsoft.com>
Subject: Re: [PATCH v2 1/3] Drivers: hv: vmbus: Introduce table of VMBus protocol versions
Date: Mon, 14 Oct 2019 11:52:00 +0200 [thread overview]
Message-ID: <20191014095200.GA11206@andrea.guest.corp.microsoft.com> (raw)
In-Reply-To: <DM5PR21MB013798776480FFA5DCD22442D7960@DM5PR21MB0137.namprd21.prod.outlook.com>
> > @@ -244,20 +232,18 @@ int vmbus_connect(void)
> > * version.
> > */
> >
> > - version = VERSION_CURRENT;
> > + for (i = 0; i < ARRAY_SIZE(vmbus_versions); i++) {
> > + version = vmbus_versions[i];
> >
> > - do {
> > ret = vmbus_negotiate_version(msginfo, version);
> > if (ret == -ETIMEDOUT)
> > goto cleanup;
> >
> > if (vmbus_connection.conn_state == CONNECTED)
> > break;
> > + }
> >
> > - version = vmbus_get_next_version(version);
> > - } while (version != VERSION_INVAL);
> > -
> > - if (version == VERSION_INVAL)
> > + if (vmbus_connection.conn_state != CONNECTED)
> > goto cleanup;
> >
>
> This is a nit, but the loop exit path bugs me. When a connection
> is established, the loop is exited by the "break", and then
> conn_state has to be tested again to decide whether the loop
> exited due to getting a connection vs. hitting the end of the list.
> Slightly cleaner in my mind would be:
>
> for (i=0; ; i++) {
> if (i == ARRAY_SIZE(vmbus_versions))
> goto cleanup;
>
> version = vmbus_versions[i];
> ret = vmbus_negotiate_version(msginfo, version);
> if (ret == -ETIMEDOUT)
> goto cleanup;
>
> if (vmbus_connection.conn_state == CONNECTED)
> break;
> }
Indeed. I applied this locally, for the next iteration. Thank you for
the review, Michael.
Andrea
next prev parent reply other threads:[~2019-10-14 9:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 15:45 [PATCH v2 0/3] Drivers: hv: vmbus: Miscellaneous improvements Andrea Parri
2019-10-10 15:45 ` [PATCH v2 1/3] Drivers: hv: vmbus: Introduce table of VMBus protocol versions Andrea Parri
2019-10-12 13:47 ` Michael Kelley
2019-10-14 9:52 ` Andrea Parri [this message]
2019-10-10 15:45 ` [PATCH v2 2/3] Drivers: hv: vmbus: Enable VMBus protocol versions 4.1, 5.1 and 5.2 Andrea Parri
2019-10-12 13:34 ` Michael Kelley
2019-10-14 10:09 ` Andrea Parri
2019-10-10 15:46 ` [PATCH v2 3/3] Drivers: hv: vmbus: Add module parameter to cap the VMBus version Andrea Parri
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=20191014095200.GA11206@andrea.guest.corp.microsoft.com \
--to=parri.andrea@gmail.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=sthemmin@microsoft.com \
--cc=vkuznets@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.
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 NNTP newsgroup(s).