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 B5441A0540; Tue, 13 Dec 2022 19:28:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EDA8042D24; Tue, 13 Dec 2022 19:27:57 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id D154740395 for ; Tue, 13 Dec 2022 19:27:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670956074; x=1702492074; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c/YwvSpj6ssxiZioC7ibUnQlx1mCa4ylmjtfqs6Xf64=; b=MoysRIySPQW4Wk2VH0TFi2bTJ0S2TEfe9wPPQMkKzLazzhWyC9JXaCv5 bXf1nT6Qh1wZDnONGYT9tARMz7eL8iKTBxE8Y/EzWnFfH9BGTReqaduYR 3AVJBZDwjmiXPTSsD5qqvztRIKHvDpxSuodY3OsUtTsrN3ptvGWfwgM0f qxwzKz6o/WVq+m/jzDPORMXzLKKCS+lV/ZH6maTcLVsl6miCYHem+91mc IKfjBxhsAcrWtLHavuNdbqGYGGB1w8SaaOaUWOuDKxz0EeeMyrOifgGBY PAaGOEGifX5WysVgqgj4vD2w60N22spgbO8o0TwzjP4s9nhLpN9DhfRJ0 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="382506984" X-IronPort-AV: E=Sophos;i="5.96,242,1665471600"; d="scan'208";a="382506984" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2022 10:27:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="626445216" X-IronPort-AV: E=Sophos;i="5.96,242,1665471600"; d="scan'208";a="626445216" Received: from silpixa00401459.ir.intel.com (HELO silpixa00401459.ger.corp.intel.com) ([10.237.223.55]) by orsmga006.jf.intel.com with ESMTP; 13 Dec 2022 10:27:52 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Subject: [RFC PATCH 4/7] telemetry: make array initialization more robust Date: Tue, 13 Dec 2022 18:27:27 +0000 Message-Id: <20221213182730.97065-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213182730.97065-1-bruce.richardson@intel.com> References: <20221213182730.97065-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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, }; d->type = array_types[type]; d->data_len = 0; -- 2.34.1