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 592FD423B5; Thu, 12 Jan 2023 11:59:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A97A442D32; Thu, 12 Jan 2023 11:59:24 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 90BB642D28 for ; Thu, 12 Jan 2023 11:59:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673521163; x=1705057163; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OqoJOM6rFcJxK6PURdiVEKd5oXyQmmZ9ICU3M2eYC9U=; b=KFOdJ9VIarA8Gfaj9/ebLP2FR1vapxHmyV2RGBBxE2kQXiK0bOnKke50 qp0IeFpoeHGVyyvpZVlm6HyOCCrd9XvCtmbEfTAfN6vZ3d6KPEs4EDP8q tudvtCPk9rgWh+QAQLknDVBbmjISkrLJE70sSS4M8PEV02LyJPNV2G/EI osUGZteCj9dKyEk3Rt7kZM9cF0j1IPRAHf9qprL2D4eSVD9MEBnYqPjgL ZNkjtO7vQu9h3ct8mjJvT1bqU+IwVivRTQMdrmz+yHtMeGRH7RMdVFeJ2 bXLCgIt0hgqHWR7Z0qi4c99CiwGX4dK1MHEtOp2jzo1ydruoJ/kB700LZ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="321365663" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="321365663" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 02:59:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="781746863" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="781746863" Received: from silpixa00401385.ir.intel.com ([10.237.214.166]) by orsmga004.jf.intel.com with ESMTP; 12 Jan 2023 02:59:21 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Tyler Retzlaff , Ciara Power Subject: [PATCH v2 2/9] telemetry: make array initialization more robust Date: Thu, 12 Jan 2023 10:58:56 +0000 Message-Id: <20230112105903.46341-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230112105903.46341-1-bruce.richardson@intel.com> References: <20221213182730.97065-1-bruce.richardson@intel.com> <20230112105903.46341-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- 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 76fae720e3..3f5ef3979b 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_U64, /* RTE_TEL_U64_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_U64_VAL] = TEL_ARRAY_U64, + [RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER, }; d->type = array_types[type]; d->data_len = 0; -- 2.37.2