[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191014095200.GA11206@andrea.guest.corp.microsoft.com>
Date: Mon, 14 Oct 2019 11:52:00 +0200
From: Andrea Parri <parri.andrea@...il.com>
To: Michael Kelley <mikelley@...rosoft.com>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
KY Srinivasan <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Sasha Levin <sashal@...nel.org>,
"David S . Miller" <davem@...emloft.net>,
vkuznets <vkuznets@...hat.com>, Dexuan Cui <decui@...rosoft.com>
Subject: Re: [PATCH v2 1/3] Drivers: hv: vmbus: Introduce table of VMBus
protocol versions
> > @@ -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
Powered by blists - more mailing lists