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 039EF423B9; Thu, 12 Jan 2023 18:42:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BEBB42DD9; Thu, 12 Jan 2023 18:42:13 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 1E7C442DC9 for ; Thu, 12 Jan 2023 18:42:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673545332; x=1705081332; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NzMmEw5aBR90292DDv4v5ZgjVaQFtB7RarGz+7QorAo=; b=CZ2xOd91MJY/mfJx1gHjhFPPz0FE5J60i8yEFCazuLemWRk81AW3qL1B g3C7x8rXQBK1wj0n/AXa+Mff+/t1e/ETdU5XoBLM2XSFIqZgI8DDQD9sI rY+6o5LvFsH2oYKoK/G3qIX/X9O3/iGZ7nxUoj5TQBXjTq2dBrYqC0mT3 2dpwEVJpJboTMbc4U3RdRNQzwZG93ddc2F3IPVtueMBH168fZE/juYbIY dDYp2DsUoMPd9aDuOdbuYT2MlQKBGHjVwVEMjmUiaPZGwEL783rEZ90nM pHRnguTTz/YdDlHGywEuaMzvFHfQ6Wan648tRMamEAWtF4x5qVim8SZvA g==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="388264919" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="388264919" 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:42:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="986678222" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="986678222" Received: from silpixa00401385.ir.intel.com ([10.237.214.166]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 09:42:09 -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 7/9] telemetry: update json functions to use int/uint in names Date: Thu, 12 Jan 2023 17:41:14 +0000 Message-Id: <20230112174116.2105237-8-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 Since we are standardizing on using uint in place of u64, and expanding the int values to 64-bit, we can update the internal json functions to use the new names and expanded signed type. Suggested-by: Morten Brørup Signed-off-by: Bruce Richardson Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- app/test/test_telemetry_json.c | 9 ++++----- lib/telemetry/telemetry.c | 8 ++++---- lib/telemetry/telemetry_json.h | 16 ++++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/test/test_telemetry_json.c b/app/test/test_telemetry_json.c index 184c3ba9f1..e81e3a8a98 100644 --- a/app/test/test_telemetry_json.c +++ b/app/test/test_telemetry_json.c @@ -37,9 +37,9 @@ test_basic_obj(void) char buf[1024]; int used = 0; - used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used, + used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, "weddings", 4); - used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used, + used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, "funerals", 1); printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected); @@ -80,8 +80,7 @@ test_overflow_obj(void) int i, used = 0; for (i = 0; i < (int)RTE_DIM(names); i++) - used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used, - names[i], vals[i]); + used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, names[i], vals[i]); printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected); if (buf[used - 1] != '}') @@ -117,7 +116,7 @@ test_large_obj_element(void) char buf[sizeof(str) - 5] = "XYZ"; int used = 0; - used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used, str, 0); + used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, str, 0); printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected); if (used != 0) return -1; diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 89bdde8422..655191bcf1 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -174,7 +174,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) used = rte_tel_json_empty_array(out_buf, buf_len, 0); if (d->type == TEL_ARRAY_UINT) for (i = 0; i < d->data_len; i++) - used = rte_tel_json_add_array_u64(out_buf, + used = rte_tel_json_add_array_uint(out_buf, buf_len, used, d->data.array[i].uval); if (d->type == TEL_ARRAY_INT) @@ -202,7 +202,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) v->name, v->value.ival); break; case RTE_TEL_UINT_VAL: - used = rte_tel_json_add_obj_u64(out_buf, + used = rte_tel_json_add_obj_uint(out_buf, buf_len, used, v->name, v->value.uval); break; @@ -269,7 +269,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) v->name, v->value.ival); break; case RTE_TEL_UINT_VAL: - used = rte_tel_json_add_obj_u64(cb_data_buf, + used = rte_tel_json_add_obj_uint(cb_data_buf, buf_len, used, v->name, v->value.uval); break; @@ -307,7 +307,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) buf_len, used, d->data.array[i].ival); else if (d->type == TEL_ARRAY_UINT) - used = rte_tel_json_add_array_u64(cb_data_buf, + used = rte_tel_json_add_array_uint(cb_data_buf, buf_len, used, d->data.array[i].uval); else if (d->type == TEL_ARRAY_CONTAINER) { diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h index e3fae7c30d..744bbfe053 100644 --- a/lib/telemetry/telemetry_json.h +++ b/lib/telemetry/telemetry_json.h @@ -136,19 +136,19 @@ rte_tel_json_add_array_string(char *buf, const int len, const int used, /* Appends an integer into the JSON array in the provided buffer. */ static inline int -rte_tel_json_add_array_int(char *buf, const int len, const int used, int val) +rte_tel_json_add_array_int(char *buf, const int len, const int used, int64_t val) { int ret, end = used - 1; /* strip off final delimiter */ if (used <= 2) /* assume empty, since minimum is '[]' */ - return __json_snprintf(buf, len, "[%d]", val); + return __json_snprintf(buf, len, "[%"PRId64"]", val); - ret = __json_snprintf(buf + end, len - end, ",%d]", val); + ret = __json_snprintf(buf + end, len - end, ",%"PRId64"]", val); return ret == 0 ? used : end + ret; } /* Appends a uint64_t into the JSON array in the provided buffer. */ static inline int -rte_tel_json_add_array_u64(char *buf, const int len, const int used, +rte_tel_json_add_array_uint(char *buf, const int len, const int used, uint64_t val) { int ret, end = used - 1; /* strip off final delimiter */ @@ -180,7 +180,7 @@ rte_tel_json_add_array_json(char *buf, const int len, const int used, * provided buffer. */ static inline int -rte_tel_json_add_obj_u64(char *buf, const int len, const int used, +rte_tel_json_add_obj_uint(char *buf, const int len, const int used, const char *name, uint64_t val) { int ret, end = used - 1; @@ -199,14 +199,14 @@ rte_tel_json_add_obj_u64(char *buf, const int len, const int used, */ static inline int rte_tel_json_add_obj_int(char *buf, const int len, const int used, - const char *name, int val) + const char *name, int64_t val) { int ret, end = used - 1; if (used <= 2) /* assume empty, since minimum is '{}' */ - return __json_snprintf(buf, len, "{\"%s\":%d}", name, + return __json_snprintf(buf, len, "{\"%s\":%"PRId64"}", name, val); - ret = __json_snprintf(buf + end, len - end, ",\"%s\":%d}", + ret = __json_snprintf(buf + end, len - end, ",\"%s\":%"PRId64"}", name, val); return ret == 0 ? used : end + ret; } -- 2.37.2