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 8C267428BA; Tue, 4 Apr 2023 11:01:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28672410FA; Tue, 4 Apr 2023 11:01:53 +0200 (CEST) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id 9283540EE3 for ; Tue, 4 Apr 2023 11:01:51 +0200 (CEST) Received: from frapeml100007.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4PrMCY5T5sz6J73t; Tue, 4 Apr 2023 16:59:53 +0800 (CST) Received: from frapeml500007.china.huawei.com (7.182.85.172) by frapeml100007.china.huawei.com (7.182.85.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 4 Apr 2023 11:01:50 +0200 Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2507.023; Tue, 4 Apr 2023 11:01:50 +0200 From: Konstantin Ananyev To: Tyler Retzlaff , "dev@dpdk.org" CC: "ciara.power@intel.com" , "bruce.richardson@intel.com" , "david.marchand@redhat.com" , "thomas@monjalon.net" Subject: RE: [PATCH v3] telemetry: use portable syntax to initialize array Thread-Topic: [PATCH v3] telemetry: use portable syntax to initialize array Thread-Index: AQHZZl6CsrdWQlfmA0mABaTNg/ZJta8a2dqw Date: Tue, 4 Apr 2023 09:01:50 +0000 Message-ID: <65480e4a272445779710dcc4c6f21dfa@huawei.com> 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> In-Reply-To: <1680548365-16525-2-git-send-email-roretzla@linux.microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.48.151.27] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected 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 > -----Original Message----- > From: Tyler Retzlaff > Sent: Monday, April 3, 2023 7:59 PM > To: dev@dpdk.org > Cc: ciara.power@intel.com; bruce.richardson@intel.com; david.marchand@red= hat.com; thomas@monjalon.net; Tyler Retzlaff > > Subject: [PATCH v3] telemetry: use portable syntax to initialize array >=20 > Use of ranges in designated initialization are a non-standard gcc > extension. Use loops to initialize permitted characters on first use. >=20 > Signed-off-by: Tyler Retzlaff > --- > lib/telemetry/telemetry_data.c | 22 +++++++++++++++------- > 1 file changed, 15 insertions(+), 7 deletions(-) >=20 > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_dat= a.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] =3D { > - ['0' ... '9'] =3D 1, > - ['A' ... 'Z'] =3D 1, > - ['a' ... 'z'] =3D 1, > - ['_'] =3D 1, > - ['/'] =3D 1, > - }; > + int index; > + static bool initialized; > + static char allowed[128]; > + > + if (!initialized) { > + for (index =3D '0'; index <=3D '9'; index++) > + allowed[index] =3D 1; > + for (index =3D 'A'; index <=3D 'Z'; index++) > + allowed[index] =3D 1; > + for (index =3D 'a'; index <=3D 'z'; index++) > + allowed[index] =3D 1; > + allowed[(int)'_'] =3D allowed[(int)'/'] =3D 1; > + initialized =3D true; > + } > + > while (*name !=3D '\0') { > if ((size_t)*name >=3D RTE_DIM(allowed) || allowed[(int)*name] =3D=3D = 0) > return false; Wonder isn't the same as: while (*name !=3D 0) if (!isascii(name[0] || (!isalnum(name[0]) && name[0] !=3D '_' && name[0]= !=3D '/')) return false;=20 Or MSVC doesn't support these macros? =20 > -- > 1.8.3.1