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 582C3428CE; Tue, 4 Apr 2023 20:09:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 297AA410FB; Tue, 4 Apr 2023 20:09:22 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9E93240A7E for ; Tue, 4 Apr 2023 20:09:20 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id C321B210DDB6; Tue, 4 Apr 2023 11:09:19 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C321B210DDB6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680631759; bh=WJ6j9IXICs7TVW8s45JyTgMqnd1Kv2bRAnX+UqG3Y/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LXQBuYSJ1nU/POxKOMUCmJqRSCMdYypfPJ6Cqlvt6IAIsqZ9Ff0MS+8EOK4T/b9tN gUSbqI1eAGWr1nXTJy2N8L1r6MkoNvyGvOZxl2/+A3ed1RUivy6Cx1BVuzfZV6CBkA lQLd5DMiLVQAUvO1d8yEc30o1GsCDmNAYMhkhd3g= From: Tyler Retzlaff To: dev@dpdk.org Cc: ciara.power@intel.com, david.marchand@redhat.com, thomas@monjalon.net, konstantin.ananyev@huawei.com, Tyler Retzlaff Subject: [PATCH v4] telemetry: remove non-portable array initialization syntax Date: Tue, 4 Apr 2023 11:09:16 -0700 Message-Id: <1680631756-7222-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680631756-7222-1-git-send-email-roretzla@linux.microsoft.com> References: <1680539424-20255-1-git-send-email-roretzla@linux.microsoft.com> <1680631756-7222-1-git-send-email-roretzla@linux.microsoft.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 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 --- 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