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 3D2AF42A4E; Wed, 3 May 2023 12:57:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11CBF4114B; Wed, 3 May 2023 12:57:26 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 2129741144 for ; Wed, 3 May 2023 12:57:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683111443; x=1714647443; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=dbO3W9rGEVys7nqB4DTluMQDlOvMjY2BTLXeXy5Iilk=; b=DwJcwuBfLQ34uKv66PNbVw3B9i+CqomEUm6JsiOym8+8FF5sWq04+IqH 637LOC+ABRs7QiUQvAvccW5V31H4ngsggFeS2yhAa4LOEFDzAsJBrMsUq MWLF/Tkr9E/Mdbsn2NZFek759nHXdxLwf0eAPIcXpiilsuIE1GRwEfXt9 8XdR3Ts6FnBXfpFEw5jfyhejOk695cTs+ZSchHvoYezgUJeJWXf9wd8Eu 9OXBC6jtaQQH8CFQVmycB80se4XGFbzals+7CL7U6B1MkNgbdxJ55rBqw 0z38VUdSRFG1J44fDGzJBX1aU5xn6HAMPyVnIojs9i/pzj452tAY/nF9R A==; X-IronPort-AV: E=McAfee;i="6600,9927,10698"; a="346104964" X-IronPort-AV: E=Sophos;i="5.99,247,1677571200"; d="scan'208";a="346104964" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 May 2023 03:57:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10698"; a="729304208" X-IronPort-AV: E=Sophos;i="5.99,247,1677571200"; d="scan'208";a="729304208" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga001.jf.intel.com with ESMTP; 03 May 2023 03:57:20 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 3 May 2023 03:57:20 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 3 May 2023 03:57:19 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Wed, 3 May 2023 03:57:19 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.172) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Wed, 3 May 2023 03:57:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zh6uqMS1jyD2Q1OAkWKlPyJYlcm2e/S5O1VU/4bXlnUYmRAq4yRTiypD4gGg1GJN0gtwpA4sf5ukgvtJr//MQs/rMeECZdZJJuwJqNM8udeWP4VH3/6kUFEcc/PvmXFgLlEaSgubfXe3hb20JJl0pzMdc3t0mBwd7aQnkf5AIx19E2m/JcN5XPnp9C1fo5NYCvax9PjpyzmtNFr2P/s7R/34OGgHflWblq0TtXFykh/Gwx83HZc7Qlk8IGOj6ctKyavhRSGbOSNK1EM6e0CeMrl+ccyTmDq7PmZKkqYAj2s8WPOCDkhho8RvVWaeLxO06ItIepuS1zHBgprWruWuCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5U/4XJgRM9cay48avJz9fuUbMfpiiOXYNosVogM18YU=; b=GahWvJ9RP5IBxofAMCd1gDovN4bCrknyhhSy+30mND8Eoa16Jr54eeiVTWDwGw7aDG84nuJxYDkphNzJ/zcYIg9zZ1WrVyMEOWY6BOuZiYQmykawMi4CmhlUnesMf4TLodFKXOERV6dEnWZunf4ojwwHaFXm66EpXcnwMjNYoJqN8M1pXxhB67Mjl8TWOyXiYInBJpbDCIy/DWmPH708XhlwMj+KPX7YMTtwGV13LD1Ces5ASUSdkJIuFPQctH1S6xr8AGseHnzJOtnnMNKoK8DPP+oGIrIu/voGTSR5FiY2Sok/iyGTzmZYlBILjO4wYLARp2wFfQNdkWChsx1nyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by SA3PR11MB7625.namprd11.prod.outlook.com (2603:10b6:806:305::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Wed, 3 May 2023 10:57:17 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::b8f3:958:d2c5:2232]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::b8f3:958:d2c5:2232%7]) with mapi id 15.20.6340.023; Wed, 3 May 2023 10:57:10 +0000 Date: Wed, 3 May 2023 11:57:02 +0100 From: Bruce Richardson To: Ferruh Yigit CC: Thomas Monjalon , , David Marchand Subject: Re: [PATCH v2] devtools: allow variable declaration inside for loop Message-ID: References: <20230503095018.1710769-1-ferruh.yigit@amd.com> <20230503103053.3087445-1-ferruh.yigit@amd.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20230503103053.3087445-1-ferruh.yigit@amd.com> X-ClientProxiedBy: LO2P265CA0128.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::20) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|SA3PR11MB7625:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e7fd88a-5fa3-493a-32fb-08db4bc524b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NBA8xpjYCAdiTCrlyto2lagLX2mpDafLWNQLqAs0Z2uUg6cbYhYF06qBuz12Pn5HfrUhb/kvI3g+qKSjOLOgkM6iD0FmnlOjdbZv0Ea5VFq6yQWNiiIYGRbO7le7MrhGoJIWLWTXllmE2NvZFDHhpmb87gxLcluumY9jSkoYWmAbdowt6TaZrB90Nei/+dTLNsHBCrMBHwZ6lIgDoXwydBIGFSHhiV6RfcLNbhITctrTUX7ETOF44UsUTnVajzqahLntG1RvYm/AWNf/IK68txa+RYaFnaPsQ1K+zcKoYKZThKYyEbCmHLgjpKtQKnnXeBDBDp+Fh04t3wQxbCiJIgyJ4LgThEAE0YIik1ZxfgnszpWA97WhnLbVw/SaE53DBeN25igcMi2QQKsnt7nXS7/YOtQCtGh3ZrEiqrR1qwb/+23Bbq8io7xKKZDssXGhkbxEnQptA7vHEqM+9AAK/HCAWP8wZsbU/cB34DXfBAF6uLDkck0iCw3K4db82U0nxp56tMybmgTwSnxIPQaIL8e6ogdblabnYh2lZ4M3fUYHNwOFnScRtnVgIel4yT2HT9SK1KtqHx5P5Ry/CAxs48GbvuzYIlwbN9uZXYKYIYg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(396003)(136003)(346002)(39860400002)(366004)(376002)(451199021)(6512007)(26005)(6506007)(8936002)(966005)(8676002)(5660300002)(186003)(316002)(66946007)(66556008)(66476007)(54906003)(4326008)(6666004)(6916009)(6486002)(41300700001)(478600001)(82960400001)(38100700002)(86362001)(83380400001)(44832011)(2906002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?scOnJdC59jY6EXvjddOEzuPTuRcHTuaAVMN8eShHHo11rEobW3vTM63U5580?= =?us-ascii?Q?mIJZvWKSWk2jLVUrkpg+C1b2l5S06JE7BNhyPvQIUAHqToofMlX/C142lS0y?= =?us-ascii?Q?GNJT4DYKVsLQZzEY4aH7nLf8tBiyXaJ8ou5mRzvD3hLLei9Po62bf0IylnXn?= =?us-ascii?Q?sjC4Q8wBxsZJF2rVngSPwMme9JrmPJiTG5JeEQoc9BP2Pp/Xz92ZgxmV7gQa?= =?us-ascii?Q?oD1AY5oENyRkTVQyEvu/D3lTB3SVw+OSE9wmNUENf2u/haR/HPC1nCqp/SDv?= =?us-ascii?Q?OUg919L6ICY3P19OH43fu8/td8s9YFopyuU7sWHQEUkXhUY15NxTig9DLqBj?= =?us-ascii?Q?ZrcDvtnTduS21J/aT9p36RpW6/dFZlb6FaRPeH36WevPoC3ZAp8SDiZNqsjH?= =?us-ascii?Q?C992nQ76TOAy8TMCHruvxuPjoql9+d2nr+kvl3BbbynV6wMPmez0Np8C6HFJ?= =?us-ascii?Q?Skl5CpzSVeAr7en6Qfni1qalrHIS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gaOsgiXb5LMeQkcH8JybbCDEg7dcyctLU2wT4tbY4t6T/RyG7bGJ?= =?us-ascii?Q?/PUjKgW524tmWgC3Wx1TkvRcIZyTBJyGGL3tfWmbR6Qpts1eSAUVNma76qLR?= =?us-ascii?Q?EcOW7d5GdU/e7T6mFapmwnqC3tlBkbz7Ozvn9pOaWrhmAB3uzB/wrHF+e5Z0?= =?us-ascii?Q?SsjCeqOhMF+whqYb9dEcaF2+4D2YOfg3rBg4YW4SjvlbuN8MI+HUXUbb+baX?= =?us-ascii?Q?oQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5e7fd88a-5fa3-493a-32fb-08db4bc524b6 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2023 10:57:10.1708 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0ChAi3uG8wmfQU6HRDM6NxeYrHk72ooJDzIIIFOjfUpaJmqWp39jzSPQvxsKpUOmwPD1LfCy8pGgnRILgegDfMXYSJFv+TWzVA/L2GLRplE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR11MB7625 X-OriginatorOrg: intel.com 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 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 > --- Acked-by: Bruce Richardson > devtools/checkpatches.sh | 8 -------- > doc/guides/contributing/coding_style.rst | 1 + > 2 files changed, 1 insertion(+), 8 deletions(-) > > diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh > index 15d5d6709445..b5baf6f2b161 100755 > --- a/devtools/checkpatches.sh > +++ b/devtools/checkpatches.sh > @@ -78,14 +78,6 @@ check_forbidden_additions() { # > -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ > "$1" || res=1 > > - # forbid variable declaration inside "for" loop > - awk -v FOLDERS='.' \ > - -v EXPRESSIONS='for[[:space:]]*\\((char|u?int|unsigned|s?size_t)' \ > - -v RET_ON_FAIL=1 \ > - -v MESSAGE='Declaring a variable inside for()' \ > - -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ > - "$1" || res=1 > - > # refrain from new additions of 16/32/64 bits rte_atomicNN_xxx() > awk -v FOLDERS="lib drivers app examples" \ > -v EXPRESSIONS="rte_atomic[0-9][0-9]_.*\\\(" \ > diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst > index 89db6260cfbf..e18b8d4439ea 100644 > --- a/doc/guides/contributing/coding_style.rst > +++ b/doc/guides/contributing/coding_style.rst > @@ -558,6 +558,7 @@ Local Variables > > * Variables should be declared at the start of a block of code rather than in the middle. 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. > The exception to this is when the variable is ``const`` in which case the declaration must be at the point of first use/assignment. > + Declaring variable inside a for loop is OK. > * When declaring variables in functions, multiple variables per line are OK. > However, if multiple declarations would cause the line to exceed a reasonable line length, begin a new set of declarations on the next line rather than using a line continuation. > * Be careful to not obfuscate the code by initializing variables in the declarations, only the last variable on a line should be initialized. > -- > 2.34.1 >