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 99F80423B9; Thu, 12 Jan 2023 18:42:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 26C0742DAE; Thu, 12 Jan 2023 18:41:59 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 7C7D042DA8 for ; Thu, 12 Jan 2023 18:41:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673545316; x=1705081316; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OqoJOM6rFcJxK6PURdiVEKd5oXyQmmZ9ICU3M2eYC9U=; b=FYAY8N/HP86tRGb6iGLNlXdghz9AyaU/f4SZHXKLoIJZmAofSBl5KP6B JUKb6cnGeUdH26kZ4tcth/us1hFjn5qWPN0kj2F+QRxMkhwKufWkzS/wL y+iUnIfB8XW1pG2MLKoZg6ih31se+FvChlfyTyG82BKqQ1cdmpTY0Vx7/ kcJSIEQudolcWX+9GJ9gKu0TBVpTCUMV5lkC9I8UE8fQHMLPU7GAl0lw4 wIQwhrYAQGMB1/Diq+z1f1sOUa2Rjg/eVaSJC5SWwk/PFFL1E4YPiEb+N HD1sskHI0hs2x6odMQ97H8JQNmEkR7PuqvlzrLdvCboWDzyKa+efhnQvB Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="388264800" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="388264800" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 09:41:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="986678019" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="986678019" Received: from silpixa00401385.ir.intel.com ([10.237.214.166]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 09:41:53 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Tyler Retzlaff , Ciara Power Subject: [PATCH v3 2/9] telemetry: make array initialization more robust Date: Thu, 12 Jan 2023 17:41:09 +0000 Message-Id: <20230112174116.2105237-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230112174116.2105237-1-bruce.richardson@intel.com> References: <20221213182730.97065-1-bruce.richardson@intel.com> <20230112174116.2105237-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