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 80819428C5; Mon, 3 Apr 2023 20:59:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0EE0241153; Mon, 3 Apr 2023 20:59:35 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 03FDE40A7E for ; Mon, 3 Apr 2023 20:59:31 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 3D55F210CBEC; Mon, 3 Apr 2023 11:59:31 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3D55F210CBEC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680548371; bh=Ebv5ylC68AJoBg5fAuYkjkq1HhGfkPxdFsl/C6yYofg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mYXxKqBrYWEA6xjloJtGb8Xr8/bikMFYNWxJEKTdavz62/sWC6FMuVB45p8WELxHa K3YaL9GKbDCjlsKX5q65NdT41A7dZ92m5zATAQoc/DZ/ysVdACLk41lLnhYjVcqQ2L G/F5Hsv5EiQyWaD/NYKFd0HN9sZu5USe8hZL83Ag= From: Tyler Retzlaff To: dev@dpdk.org Cc: ciara.power@intel.com, bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH v3] telemetry: use portable syntax to initialize array Date: Mon, 3 Apr 2023 11:59:25 -0700 Message-Id: <1680548365-16525-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680548365-16525-1-git-send-email-roretzla@linux.microsoft.com> References: <1680539424-20255-1-git-send-email-roretzla@linux.microsoft.com> <1680548365-16525-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. Use loops to initialize permitted characters on first use. Signed-off-by: Tyler Retzlaff --- 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; + static bool initialized; + static char allowed[128]; + + if (!initialized) { + for (index = '0'; index <= '9'; index++) + allowed[index] = 1; + for (index = 'A'; index <= 'Z'; index++) + allowed[index] = 1; + for (index = 'a'; index <= 'z'; index++) + allowed[index] = 1; + allowed[(int)'_'] = allowed[(int)'/'] = 1; + initialized = true; + } + while (*name != '\0') { if ((size_t)*name >= RTE_DIM(allowed) || allowed[(int)*name] == 0) return false; -- 1.8.3.1