From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 103B542A50; Wed, 3 May 2023 17:01:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 00D2542D12; Wed, 3 May 2023 17:01:09 +0200 (CEST) Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by mails.dpdk.org (Postfix) with ESMTP id 9B95D41144 for ; Wed, 3 May 2023 17:01:07 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 484113200982; Wed, 3 May 2023 11:01:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 03 May 2023 11:01:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1683126064; x=1683212464; bh=4doy1vL8yjDHvkm/bO8QXbTVbOV7JoPzkVx lcsOJ700=; b=TH16e6sP61HZolbwHOJYy3F6V2vLaUazayqCab2C5B0YxnRHhU9 nQoVH916P0fEjUuKUuqxrjFjtHWNUzqgwkl+axG06hiY65LrjRlCfz7UiE2VgOqG NfHnSkWM9zPsoNL+fFGbUh/bmxkuh8YlbJp2yRni+wsBlgdSw7jSeTMIgkIqNACc wippezh59W5wtNxHCOkD87kJk5DVpBaltNi9OTKxhxiLRjN9z7G6LUf3cVPihmDt xWrAicyM2Ibqvvn2YD3BqWNqJyCvye28IqM2siUf+0Fgf0LldqOlLoLk4XoqFgI5 aQn7Smwv8z9I1IakOYMMSFwgH8k0spbtugw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683126064; x=1683212464; bh=4doy1vL8yjDHvkm/bO8QXbTVbOV7JoPzkVx lcsOJ700=; b=aa27g6HLJD/ClpjwCJVlAo42VUyuiJcZubCvVDOz6eTPI3/32To InEqHfglhUTtcTcqRTusNwwgdw7cirIfclHrwBORbwDudTj23YPMJ158yN92z+EK yby6SDfgZoCgtAM/VPzmcPTaMOLOYOFIzJILRnfDsKVZi15ssPRnNDJswOiPx4pk +m8qhoIWUX5XHJnjHrZYt3gmFKYj6UOI4h1Mh97hBQYSmIHi7P4QlMTTirq/RQ04 Wu8iIJ3vniy0S5q6MBsZzENMymj1ZNoTTWMGiFNpuyiCtIfRNNbVwb6EhB3hfMyw P3El4V7OfzIT+Nq0gg5Qp7KcF2aWnBwlqBA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedvkedgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkjghfggfgtgesthhqredttddtudenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpeegjeeivdelheduhfeugfefvefgheeiteegiefggffgffffieeu gfeukedtfeefveenucffohhmrghinhepughpughkrdhorhhgnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 3 May 2023 11:01:03 -0400 (EDT) From: Thomas Monjalon To: Bruce Richardson , Ferruh Yigit , Morten =?ISO-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org, David Marchand Subject: Re: [PATCH v2] devtools: allow variable declaration inside for loop Date: Wed, 03 May 2023 17:01:01 +0200 Message-ID: <2878762.e9J7NaK4W3@thomas> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D878DC@smartserver.smartshare.dk> References: <20230503095018.1710769-1-ferruh.yigit@amd.com> <98CBD80474FA8B44BF855DF32C47DC35D878DC@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 03/05/2023 14:19, Morten Br=F8rup: > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > Sent: Wednesday, 3 May 2023 12.57 > >=20 > > On Wed, May 03, 2023 at 11:30:53AM +0100, Ferruh Yigit wrote: > > > Declaring variable inside for loop is not supported via C89 and it was > > > checked in checkpatch.sh via commit [1]. > > > But as DPDK supported C standard is becoming C99/C11 [2], declaring > > > variable inside loop can be allowed. > > > > > > [1] > > > Commit 43e73483a4b8 ("devtools: forbid variable declaration inside > > for") > > > > > > [2] > > > https://dpdk.org/patch/121912 > > > > > > Signed-off-by: Ferruh Yigit > > > --- > > > Cc: Bruce Richardson > > > Cc: David Marchand > > > > > > v2: > > > * Update coding convention too > > > --- > >=20 > > Acked-by: Bruce Richardson >=20 > Acked-by: Morten Br=F8rup >=20 > [...] >=20 > > > @@ -558,6 +558,7 @@ Local Variables > > > > > > * Variables should be declared at the start of a block of code rather > > than in the middle. > >=20 > > I'd love to see this restriction removed in future too. Having a > > variable > > declared on first use in the middle of block I find a far easier way of > > working as a) it saves scrolling to look for variable definitions and b) > > it > > makes it far easier when adding/removing blocks of code e.g. commenting > > out > > for testing, to have all the code together rather than having variables > > at > > the top to add/remove also. >=20 > And c) Initializing the variables close to where they are used the first = time reduces the risk of initializing them incorrectly. Especially when mod= ifying a block of code, initialization of its variables might be missed if = out of sight. (Although this is probably a consequence of "a)".) >=20 > I consider it old style to only declare variables at the start of a block= of code, and this style of coding should be considered obsolete. >=20 > If you are really old (like me?), you might remember when function parame= ters were provided like this: >=20 > int main(argc, argv) > int argc; > char *argv[]; > { > return(0); > } >=20 > We have moved on from that to a more modern coding style a long time ago.= We should also move on to a more modern coding style regarding variable de= clarations. Old men are used to look for variable types at the beginning of functions. Having only new code adopting a different style may be confusing a little. Note I'm not against it, just asking for more feedbacks.