Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4327602ybp; Mon, 14 Oct 2019 02:55:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/NtQHAbUNvbzE/LOjaL8tWNlV2xiiRoLHs5e7tXOIy+1qyWC6zGR5/oifLqAkpPyEd5Y7 X-Received: by 2002:a17:906:e108:: with SMTP id gj8mr1294776ejb.1.1571046941780; Mon, 14 Oct 2019 02:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571046941; cv=none; d=google.com; s=arc-20160816; b=L35/67ro+n7Co5FrXIzFZjrYvteN9xJL2akmXpaftsnV+gtHxK/oCiRUrVzdprGJPc 66hhDILI6xk7iDLT+2HiidZsi4ZGgSSPEgsbfN5fER7WPzsXXE+q36I9zPBInbNcBwI5 gv/habxpkli40FrdRpMgCTvG+CF0KNRvL09P47B86Dmn5TlhgEjrDyd8F8YRscfZgN4x 5zGmRFYSJlM4CTtg+r+m/RbY7dARgrGRi6wp4jKrFvTCZ8EpqIO2QFfCfJKYgFO/PjPk QlXc3JWJB6E1M4nTsxeC8hABX1v/0vbSC53r+lIkcPW/k0fw6AjV8q3FXUr4XG9S/2oB hH+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TgbHwKMY+OVVpJwkvai2RZenJKOMFPjpVaxMPbCBN5c=; b=zmDKwKimKeSKaIvTEvF7jlH7HIEkhHUMfGz/xvmWJ3ffeGCpLOetxnxTksG77WBFgw I9egfVr36lNEKklUj9Pu4aOiDnkqgJ+uJ+t8+D4QCu05P0qp+G4iv4/avxQP04RqeHFl GraQnaOmKSPGq9afXlGLQuOCvo9GA2G/FfczQMeVjUNXszT5Ub03l9CjwPtV5DhfxSyq jgXUMIoPXY9pYRXgCqXT+qBfRvzjtvz+4nuvac14RpE7C0Ozm6UZPy7aSCv0ixl5xhGE i49Hr0lGt5NN54kRRB4M5aUt1Hlu8s+ZKjzTsI5NFvLX/SJ+Al3kEpsTQx1JKQ+iuQru SKcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=elRGhDdY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si10456824ejc.424.2019.10.14.02.55.18; Mon, 14 Oct 2019 02:55:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=elRGhDdY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731187AbfJNJwJ (ORCPT + 99 others); Mon, 14 Oct 2019 05:52:09 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35475 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730740AbfJNJwJ (ORCPT ); Mon, 14 Oct 2019 05:52:09 -0400 Received: by mail-wr1-f67.google.com with SMTP id v8so18924527wrt.2; Mon, 14 Oct 2019 02:52:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TgbHwKMY+OVVpJwkvai2RZenJKOMFPjpVaxMPbCBN5c=; b=elRGhDdYM5z0fh+u2IZyo1JzQV3H7y+UrHsWM7o/96lM7+Ebs6p8gPbSvJ3AVhwJBj 0NaTzI4MZEPEaXP6FqpGKddIbjjUo/h3yv+u1gRnlgcU8DFQDR0lPjDD1lxDWyHvLKqK 3/O6c+NKmB9mGLM3ikw52QIHKw9zDHJjlz8o2NVxkvnT8MyK0RVkOfE41JxQgyBHuZS+ sK0H63CzgAsyROvFwi1LQbLicVptacN6HMiQtFR/kYFrXLewZJEeKfjSGdD0taVpV33/ +/SoMOlx52DP38EiUcth+pT1z/j4ZsVeUg8nXnPW8OG8OCvUVZICpLt6TxV0bJCsTH/i NRDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=TgbHwKMY+OVVpJwkvai2RZenJKOMFPjpVaxMPbCBN5c=; b=Ji+Zgwo1BSJnYe32mb3kSSurSzRHMQEQpvOt20XDBJjrg5ELwcN8+t6ddmmoe+O62e QoJOA3pLIuQ46KU+xg66XEvgI8KPKN07vwK56HNQuI7QTYBLcvUDA7T0oP7368HdVfza XWy7wGyTRK798KpsAQzxfpNV7P/4sN5aPxJ3f3b/rFK/X9UwAdUN9Yy7P1nR5AIi0K9l zRe0W+u2xZCKiC8yVq8yqbjM19/frpCWZRVv2fcqL7gj+MAqbCqtNeCTJg/3Y87UtK6+ 2Vt03JKSLWn/jrl+dE8vs7JlK6TBG2Df+I5o6ric4liH9EuDM+pMe0YIYQtUEz+akWuS RcVA== X-Gm-Message-State: APjAAAVyuDdAjx9yOC6R3hs+0IRpee1YNhYd9aOvB5udUJiJh4qKUs9I 8KdtlJkKB7oAccoTOhLWZi2P/B3RJu8= X-Received: by 2002:adf:e90d:: with SMTP id f13mr25249204wrm.104.1571046726846; Mon, 14 Oct 2019 02:52:06 -0700 (PDT) Received: from andrea.guest.corp.microsoft.com ([2a01:110:8012:1012:484d:bbc3:12dc:348b]) by smtp.gmail.com with ESMTPSA id r6sm19715339wmh.38.2019.10.14.02.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 02:52:06 -0700 (PDT) Date: Mon, 14 Oct 2019 11:52:00 +0200 From: Andrea Parri To: Michael Kelley Cc: "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Sasha Levin , "David S . Miller" , vkuznets , Dexuan Cui Subject: Re: [PATCH v2 1/3] Drivers: hv: vmbus: Introduce table of VMBus protocol versions Message-ID: <20191014095200.GA11206@andrea.guest.corp.microsoft.com> References: <20191010154600.23875-1-parri.andrea@gmail.com> <20191010154600.23875-2-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > @@ -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