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 3CBFEA0565; Mon, 23 Mar 2020 14:59:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7CE311C068; Mon, 23 Mar 2020 14:59:32 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 768C41C05C for ; Mon, 23 Mar 2020 14:59:31 +0100 (CET) IronPort-SDR: cRyUKIkAQ03V2ZFfI0HLTfj+rm+EX8ZkppCdG69GKRstFmIQLQRD4jmrka4/IOLZQkzBTAZfJG 04qb34J3eEpg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2020 06:59:30 -0700 IronPort-SDR: J03aNhay4gDtYXHasjhYxmkiIXYIFqGw2q3LmnCf29KMFQIpmk46deKfiuVJ4eNyd+XJA/FOxa zkYs+VpXr22Q== X-IronPort-AV: E=Sophos;i="5.72,296,1580803200"; d="scan'208";a="235225616" Received: from bricha3-mobl.ger.corp.intel.com ([10.214.201.116]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 23 Mar 2020 06:59:24 -0700 Date: Mon, 23 Mar 2020 13:59:19 +0000 From: Bruce Richardson To: Thomas Monjalon 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 Message-ID: <20200323135919.GA1517@bricha3-MOBL.ger.corp.intel.com> References: <20200217222654.2218926-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200217222654.2218926-1-thomas@monjalon.net> 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" 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] Regards, /Bruce