From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3EF4EA0565; Mon, 23 Mar 2020 17:12:39 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 588EE1C07E; Mon, 23 Mar 2020 17:12:38 +0100 (CET) Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) by dpdk.org (Postfix) with ESMTP id 271601C07D for ; Mon, 23 Mar 2020 17:12:37 +0100 (CET) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id 667CB580263; Mon, 23 Mar 2020 12:12:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 23 Mar 2020 12:12:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=unCBd8aJxt9OtKv/iWdPEJ8KB1IP2Gmgg9yHzu13ygw=; b=DaAj2hvXVnFb JYWz0LXN5Gso1dR1miQltpv28HV5AFPnKAhQt5J1OaEn8xFc78CXjwNHpQ5SAVuT OFNHvTy5/oWLyMQGPb721XzdhMGg8RnY1qOxUQPX5pFTQXZT0Jj6FUgDKnwGZ5Im bfeVUkXj1kUbh7D6iNOSLzXV19dFaA0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=unCBd8aJxt9OtKv/iWdPEJ8KB1IP2Gmgg9yHzu13y gw=; b=IVpiglPngDdS6WnpHgxb+6k2NchpcxBAJymg+mIiEZlfkUUrIQXBOSO6H e+Mr9kaWxGxZHoIXp7gqQ5LvoAWPCQCEhNdB7IKx5UPWV1sUpl2IJcBuJZNyk80O LD76nkgWbIMJehF+YuZHl5OrIEeNRbT07gCBjs3zOnuAvBTKdE5BEtQzPfGQ9Z1a fARS4eKXes2CQnLgf9XBRtrB9vEA3vf+JerRHxuaFGcqSxzRERnohOo9zifMCLyn 64hXVEuRA/5PW/nDWkbYSDiur3wJR3W2Mar/RmvET+uj2LWzofehOjcqQfKyjxdK vrKzGCVnRTYnOjW/004cYGb735kmw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudegkedgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecuff homhgrihhnpeguphgukhdrohhrghenucfkphepjeejrddufeegrddvtdefrddukeegnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrg hssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 7B82C30626D3; Mon, 23 Mar 2020 12:12:33 -0400 (EDT) From: Thomas Monjalon To: Bruce Richardson Cc: dev@dpdk.org, Vladimir Medvedkin , John McNamara , Marko Kovacevic , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Gagandeep Singh , Hemant Agrawal , Sachin Saxena , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon Date: Mon, 23 Mar 2020 17:12:32 +0100 Message-ID: <1776915.IobQ9Gjlxr@xps> In-Reply-To: <20200323135919.GA1517@bricha3-MOBL.ger.corp.intel.com> References: <20200217222654.2218926-1-thomas@monjalon.net> <20200323135919.GA1517@bricha3-MOBL.ger.corp.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] devtools: forbid variable declaration inside for X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 23/03/2020 14:59, Bruce Richardson: > On Mon, Feb 17, 2020 at 11:26:54PM +0100, Thomas Monjalon wrote: > > Some compilers raise an error when declaring a variable > > in the middle of a function. This is a C99 allowance. > > Even if DPDK switches globally to C99 or C11 standard, > > the coding rules are for declarations at the beginning > > of a block: > > http://doc.dpdk.org/guides/contributing/coding_style.html#local-variables > > > > This coding style is enforced by adding a check of > > the common patterns like "for (int i;" > > > > Could we, or should we, not also revisit the coding standards for this. > Those standards are quite old now, and could do with being updated to take > account of things like the newer C standards. Obviously for consistency > reasons any changes should not be major, but I don't think we should view > the guidelines as set in stone either. > > For this particular issue, I think generally having all declarations at the > beginning of a block is the right thing to do, however, I would support > relaxing this rule in a couple of scenarios, specifically: > > * declaring a variable like i in a for loop, i.e. the case above > * using const on a variable declaration, marking it as const at first > assignment [because I take the view that increased use of const is almost > always a good thing] I would tend to agree in general for updating guidelines, and especially in this case. But because we are not enforcing C99 (or C11) when compiling, some users are still trying to compile with old compilers. As a result, a declaration in a for loop will break compilation with some compilers: http://git.dpdk.org/dpdk/commit/?id=bc3282125b I am OK either way: - switch globally to C99/C11 - or forbid declaration in for loop I took the second option because it is easier, and because it maximizes our compiler tolerance.