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 7ECDA428D0; Wed, 5 Apr 2023 20:52:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 106B041611; Wed, 5 Apr 2023 20:52:57 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9C9B741611 for ; Wed, 5 Apr 2023 20:52:54 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id DE261210DEE4; Wed, 5 Apr 2023 11:52:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DE261210DEE4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680720773; bh=o1Thsf1Crholpteoqk6kFs3lceV6iU9WhQcevqUMOJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EzdetbzE0eoqzP8J60h2Jy/lTJz2yWJZnQfgn6DGS6GasB++P9XXC7A/FBni1R6rp TTBu9XmVCIUHA9PVC2F4zchBqhueWCHmL4CjciBwx1wMm0jQYe6Qy/OVKesYffQG4D FdwkdUIFitA2GDRjZIYmr8LVYOdeMDhMl72hUv94= From: Tyler Retzlaff To: dev@dpdk.org Cc: ciara.power@intel.com, bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, konstantin.ananyev@huawei.com, Tyler Retzlaff Subject: [PATCH v5] telemetry: remove non-portable array initialization syntax Date: Wed, 5 Apr 2023 11:52:52 -0700 Message-Id: <1680720772-31405-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680720772-31405-1-git-send-email-roretzla@linux.microsoft.com> References: <1680539424-20255-1-git-send-email-roretzla@linux.microsoft.com> <1680720772-31405-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 Acked-by: Bruce Richardson --- 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..0c7187b 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-alphanumeric characters allowed in names */ + static 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