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 62767A0543; Wed, 14 Dec 2022 18:50:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C37940684; Wed, 14 Dec 2022 18:50:36 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 42CB6400D6 for ; Wed, 14 Dec 2022 18:50:34 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 899F120B87CB; Wed, 14 Dec 2022 09:50:33 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 899F120B87CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1671040233; bh=NMnJNEcEquYGcZ8dHBD/BVOGxidJh8K2mgHCRO1dZzs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=R5+VOWYVD1Y781l2Y2e8KYYb+yqwPI8Av11Ys+w/SwwsKTUb3KyfArGLfNJRgF8F+ OM6QVLwtvZvO6s2PING9sJosjuZGmyQxS2HwIRi8c6VQuYo0M3G8M7Odfp3Wv8AUnb 5a5/3NNAowKs63dG6YVt6WjR4dy6VXYXO+ce4pP0= Date: Wed, 14 Dec 2022 09:50:33 -0800 From: Tyler Retzlaff To: Bruce Richardson Cc: dev@dpdk.org Subject: Re: [RFC PATCH 4/7] telemetry: make array initialization more robust Message-ID: <20221214175033.GD31935@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <20221213182730.97065-1-bruce.richardson@intel.com> <20221213182730.97065-5-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221213182730.97065-5-bruce.richardson@intel.com> 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 Tue, Dec 13, 2022 at 06:27:27PM +0000, Bruce Richardson wrote: > Rather than relying on a specific ordering of elements in the array > matching that of elements in the enum definition, we can explicitly mark > each array entry using the equivalent enum value as an index. > > Signed-off-by: Bruce Richardson > --- > lib/telemetry/telemetry_data.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > index d51724e1f5..9a180937fd 100644 > --- a/lib/telemetry/telemetry_data.c > +++ b/lib/telemetry/telemetry_data.c > @@ -16,10 +16,10 @@ int > rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type) > { > enum tel_container_types array_types[] = { > - TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */ > - TEL_ARRAY_INT, /* RTE_TEL_INT_VAL = 1 */ > - TEL_ARRAY_UINT, /* RTE_TEL_UINT_VAL = 2 */ > - TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */ > + [RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING, > + [RTE_TEL_INT_VAL] = TEL_ARRAY_INT, > + [RTE_TEL_UINT_VAL] = TEL_ARRAY_UINT, > + [RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER, > }; i might be a bit fuzzy and didn't double check but doesn't doing this require C99? though it would be great to move to a minimum of C99/C11 > d->type = array_types[type]; > d->data_len = 0; > -- > 2.34.1