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 E28B2428D4; Wed, 5 Apr 2023 17:27:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3D5D41153; Wed, 5 Apr 2023 17:27:38 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 0807C41133 for ; Wed, 5 Apr 2023 17:27:37 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 01BCA210DED5; Wed, 5 Apr 2023 08:27:35 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 01BCA210DED5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680708456; bh=9kCbQl81n+C38Kr1VcT5yjhKTzVgk2foEkBJL4rV5Yc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JN/Q9Im+VYMxjzZrz3MCYbdk+IN5Rvttl/KVnsUSyIVeu7rRGUerFduLYZPID8J5c 8XxJTMoo3339BT8zke2BaKus1E2PN6PC7L4tyFwT0tKAI1qM8BbW3PqpklCmwYlwnm qbXOwEPRdH0RSwppahlqbHWNxtjVNn3ZSF4qFHdI= Date: Wed, 5 Apr 2023 08:27:35 -0700 From: Tyler Retzlaff To: Bruce Richardson Cc: dev@dpdk.org, ciara.power@intel.com, david.marchand@redhat.com, thomas@monjalon.net, konstantin.ananyev@huawei.com Subject: Re: [PATCH v4] telemetry: remove non-portable array initialization syntax Message-ID: <20230405152735.GC28418@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1680539424-20255-1-git-send-email-roretzla@linux.microsoft.com> <1680631756-7222-1-git-send-email-roretzla@linux.microsoft.com> <1680631756-7222-2-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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, Apr 05, 2023 at 09:56:24AM +0100, Bruce Richardson wrote: > On Tue, Apr 04, 2023 at 11:09:16AM -0700, Tyler Retzlaff wrote: > > Use of ranges in designated initialization are a non-standard gcc > > extension. > > > > Only initialize '_' and '/' elements of the array and filter tests > > of characters through name with standard C isalnum before checking > > the array. > > > > Suggested-by: Konstantin Ananyev > > Suggested-by: Bruce Richardson > > Signed-off-by: Tyler Retzlaff > > Acked-by: Bruce Richardson > > The array should probably be "static", which was a miss in the original > version too. micro optimization trade off image size vs stack usage yeah. i'd be inclined to use static so i can update that. > > > --- > > lib/telemetry/telemetry_data.c | 16 +++++++--------- > > 1 file changed, 7 insertions(+), 9 deletions(-) > > > > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > > index 2bac2de..0dc091a 100644 > > --- a/lib/telemetry/telemetry_data.c > > +++ b/lib/telemetry/telemetry_data.c > > @@ -2,6 +2,7 @@ > > * Copyright(c) 2020 Intel Corporation > > */ > > > > +#include > > #include > > #include > > #include > > @@ -152,17 +153,14 @@ > > static bool > > valid_name(const char *name) > > { > > - char allowed[128] = { > > - ['0' ... '9'] = 1, > > - ['A' ... 'Z'] = 1, > > - ['a' ... 'z'] = 1, > > - ['_'] = 1, > > - ['/'] = 1, > > - }; > > - while (*name != '\0') { > > + /* non-alpha-numeric characters allowed in names */ > > + const char allowed[128] = { ['_'] = 1, ['/'] = 1 }; > > + > > + for (; *name != '\0'; name++) { > > + if (isalnum(*name)) > > + continue; > > if ((size_t)*name >= RTE_DIM(allowed) || allowed[(int)*name] == 0) > > return false; > > - name++; > > } > > return true; > > } > > -- > > 1.8.3.1 > >