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 E92F1428C6; Tue, 4 Apr 2023 18:13:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 825E140EE3; Tue, 4 Apr 2023 18:13:58 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id D176340A7E for ; Tue, 4 Apr 2023 18:13:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680624836; x=1712160836; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=Lly0FQuo6s2FLPH4KGaCp1IaSjlq33YdnymBIjeSQ+Q=; b=Xe0MudDBNuwaPmCin70F/Lgm52xQkNt59iunCqfO+NOdawMKnu0oY4Bo 971QQDq3n85u37WrbzheoeTOIM28hr2y4deY/gLhfMV9A/L0GMdwflDYz Prv+XAbFSdWKAqWVedDg+ladW9iSvH1VpgMuwVMi2ChDd04XdvmOyUuPW sTW1PQY5SM49h3ZTeHcJvz/pm8lZ4vS7OzYmmVy+a7ET/KlX0hBbqpRxw JE+8oC82+m2DywSXV3tld/plSHLaqk1r1HEMqaEZQDSoA506Eya9whMsC 5ANvg+x4Sm8P/J5h3AKFQCebLuhs5s39gBMYJU+KPq6C4iMZfbTumTLLe A==; X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="342251842" X-IronPort-AV: E=Sophos;i="5.98,318,1673942400"; d="scan'208";a="342251842" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2023 09:09:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="1016160620" X-IronPort-AV: E=Sophos;i="5.98,318,1673942400"; d="scan'208";a="1016160620" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga005.fm.intel.com with ESMTP; 04 Apr 2023 09:09:27 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Tue, 4 Apr 2023 09:09:27 -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.21 via Frontend Transport; Tue, 4 Apr 2023 09:09:27 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.170) 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.21; Tue, 4 Apr 2023 09:08:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HUZKjTyIXiKX7OdycBByxcelaxxryYQTowFYg14/O2mz63bDLJvJyk9MOMLZWbQrPPoBlcTNpLycxCd2j0TYjV57wX9yp8MguDytT6CtuwlRXyzhOYEHMP/MokukF2T/nH+9ElbuII4RU+LCTPnE7SStLp4Ms13QdhN9a+QdVVCco0XBlyL5e5PL6knvHjlv+UT9uQMwCYzx1WNu+nNoMmVF/I6IqSLLZEJrVnlfLLvDP0HoiuU2SxGNGFyUugp2TpZJaj4S8JHZMf6GbJ0KO+13+W4FUlOoyE0b6wqYG4W+RecCvUTYicgAl8YqorrZlCu6I/+DWJzI+qXRQ8g7sQ== 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=r3pFPv0yzbefu2sFocaijXQ0KQBXWX+dYq0MwC7D1uk=; b=O6fbRfs0WbL/bXcfwQkXYJ+mRH3W09CUktSHpIiGXXAHYpWg/hh0ew43PTf+NldRdGj2F07eKYnryU/vzllHCyAQ0Z/T5bSttDkoH4gDoJS+k8gkaVMWepAFCZ9cgftElePyi/UvTNKlyh5mEU4bz8nHcsIIVkkSZc0fw7WPH6NyHv/ykoccBmyZAaWoWjGiF7+GffSD/khrAY8B6ld/jMqjlocgyGZt5NtHIIhUXW6rrwqLU4ZZOzqLMRN6HJMDPrDCt4Ik4J0UE76Afkzdk6l2ThIDX//D+I09RTh1oijoA4APc+5N3ldl+PUDlf1irFbkhU+r1qrzkcsAlkZ/Ww== 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 MW4PR11MB6982.namprd11.prod.outlook.com (2603:10b6:303:228::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.35; Tue, 4 Apr 2023 16:08:54 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::18d0:ac53:aa1d:d19c]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::18d0:ac53:aa1d:d19c%6]) with mapi id 15.20.6254.035; Tue, 4 Apr 2023 16:08:53 +0000 Date: Tue, 4 Apr 2023 17:08:47 +0100 From: Bruce Richardson To: Tyler Retzlaff CC: , , , Subject: Re: [PATCH v3] telemetry: use portable syntax to initialize array Message-ID: References: <1680539424-20255-1-git-send-email-roretzla@linux.microsoft.com> <1680548365-16525-1-git-send-email-roretzla@linux.microsoft.com> <1680548365-16525-2-git-send-email-roretzla@linux.microsoft.com> <20230404155430.GD23247@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20230404155430.GD23247@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> X-ClientProxiedBy: LO4P302CA0042.GBRP302.PROD.OUTLOOK.COM (2603:10a6:600:317::14) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|MW4PR11MB6982:EE_ X-MS-Office365-Filtering-Correlation-Id: b3d41c14-17aa-4e0a-85c0-08db3526e2fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OLVLRkgKQFjEHqEwc830/Wnj+6vgY0MF8zxkHd6BTf4l00RGjoRYA9yWD8zTqxuf/SFM5do8vyta3F5qnPiBf/TeZ/uTIUB8QSp7pHE1qTedlE+H8XQus1U1yBAhOQUMrAAki0FUioh73mSnsKuboCgNwqIg+38A5Ie31Et0F1NmOaYFnagS3XPz6dVH1NL/U7evl7/8ov+FzRsT1jfiZzluGf3l3qyHs9UfQNhwV4itkGjphKrpARev6mY3Wlt8fYQYhWYdb9MrVG7zRd9Sps/faqrRRO0Sff8UOzG2BXyZL1n87l3QImTghI0oyFEx1dp2g/MnO07FwmUaa4MMEwzfgaPI4xrzjdH2J22q4RZGD+eocaMbIbWnkQKGcTj1W9VfWjOUNJZ4jGP3dHlThb2lwBgHT8wxmf7CNBESvyqQUpyXCiZ4ONTL8izrQFudHqPqPXzI9CBOvp4jTKAMWai7JHZbtshddHOSCNuoHrI0fYdFzzisFUKp8XddWb3W+NM9uPVFGcWLhmcPLUl3gMfBL4sHA0EptmL8kky9r7M= 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)(366004)(346002)(39860400002)(376002)(451199021)(8676002)(66476007)(8936002)(86362001)(26005)(186003)(6506007)(6512007)(38100700002)(82960400001)(83380400001)(44832011)(5660300002)(478600001)(966005)(6666004)(6486002)(316002)(41300700001)(6916009)(4326008)(66946007)(2906002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?5voE314OlcktGvEvBuBieNWR4vrKafLHM7SAmETaOir0d5lB5ATGF1t4tIYb?= =?us-ascii?Q?IS4PkCrL8kJw2gwZoUQZIMA0MI/VjpUZ7RzZC6yX6RW06nOvxPfU8uAe3kgC?= =?us-ascii?Q?348sIgVUhhGvmEe7Qz/N2xkFa1qGU4Y+AblhA+cYQpxm/+cN5+PdPjdm5cO7?= =?us-ascii?Q?Kc5mCE7HrYo9kUobxmT3B6EKGfjTTRyMsbj8VmfxGCXCYlD2PiF3J4MXGswJ?= =?us-ascii?Q?5dC6QSwOG57QVZbH+pEAgNi8+k10bnFbCvylJI/19XRmgHQnIpasLer/AIVV?= =?us-ascii?Q?lgrFAlEkeQpTJXxuY2Gqn3E56yckVlHlDCWVIaVUpa4S3MfPC6rhDUAqnXRv?= =?us-ascii?Q?HSEWqh+Lt4Oyr8OO1ikWNhFBmERFm2R2RAw4lZQcnmmob9LTWf1JKuYYoG0J?= =?us-ascii?Q?BOomgsgRKErHqldFc+n3sQaG3+mtHzHzwFjMJeKRePQ9Ate/HymvnwLtmiQT?= =?us-ascii?Q?yABQ7yGWeXKu0QQ5CH+vXyTNgTDOZkZMUKQoLYcTExIClPXOURLNe+dRCrqz?= =?us-ascii?Q?ZjqLmVtZQFqj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= =?us-ascii?Q?9FkplTe/lcLGhnSsn9ucuiEJ7WAT9RmDH6fb2ju+mmYSq/xCFwtoUhqBEsFe?= =?us-ascii?Q?3CjTAkTyC2n4aQf3IAUWzcemoMYInR7QRpKCgV/PzNjvQzh/7aVrPQH+Yla4?= =?us-ascii?Q?soHQv8zadLIpRPzIIXGRy9kux2UCiDjfiTk3A5rT0Cl2AhadsXx4rCN3tV4E?= =?us-ascii?Q?mQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: b3d41c14-17aa-4e0a-85c0-08db3526e2fb X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2023 16:08:53.8154 (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: Lj2G8l8VuF6punrzsw7jWRrKcSsUqUtB63EtH1nZUji0G6mia9OH0A8ALOWzrIVM0y5Q9rFnWuRatOTfoF93UHt7MX+dV31syYwK4zDxxvU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB6982 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 Tue, Apr 04, 2023 at 08:54:30AM -0700, Tyler Retzlaff wrote: > On Tue, Apr 04, 2023 at 09:51:04AM +0100, Bruce Richardson wrote: > > On Mon, Apr 03, 2023 at 11:59:25AM -0700, Tyler Retzlaff wrote: > > > Use of ranges in designated initialization are a non-standard gcc > > > extension. Use loops to initialize permitted characters on first use. > > > > > > Signed-off-by: Tyler Retzlaff > > > > Acked-by: Bruce Richardson > > > > > --- > > > lib/telemetry/telemetry_data.c | 22 +++++++++++++++------- > > > 1 file changed, 15 insertions(+), 7 deletions(-) > > > > > > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > > > index 2bac2de..562b387 100644 > > > --- a/lib/telemetry/telemetry_data.c > > > +++ b/lib/telemetry/telemetry_data.c > > > @@ -152,13 +152,21 @@ > > > static bool > > > valid_name(const char *name) > > > { > > > - char allowed[128] = { > > > - ['0' ... '9'] = 1, > > > - ['A' ... 'Z'] = 1, > > > - ['a' ... 'z'] = 1, > > > - ['_'] = 1, > > > - ['/'] = 1, > > > - }; > > > + int index; > > > > My preference would be to limit the scope of index to the if block, but ok > > to keep as here. > > yes, mine too. but i forgot we aren't C99 (yet) so i had to move it for > this patch. > We do allow variable declarations within blocks, so no need to move it up here. However, I believe our coding standards currently require them at the *top* of each block, not in the middle - but also not just at the top of each function. See [1] for the details. [For some reason this is in the sub-section under "indentation" in the guide!] [1] https://doc.dpdk.org/guides-22.11/contributing/coding_style.html#local-variables > > > > [In fact, when we switch to C11, I'd love to see the coding standards > > relaxed to allow loop variable definition inside the for statement itself] > > i'm for it, in fact for any variable i prefer declaration at or near > first use because it let's me const more. but i know that can be an > unpopular opinion so no need to hit 'r' to tell me off, i will follow > any and all documented convention the community has. > For const, our coding standards already call this out as an exception, where it's allowed to define a variable in the middle of a block. Generally though, I too prefer vars to be defined at site of first use, rather than all together at the top of the block. Makes it easier when commenting out code for debugging, not to get unused var warnings. /Bruce