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 026C2423B5; Thu, 12 Jan 2023 12:00:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D082842D57; Thu, 12 Jan 2023 11:59:42 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id B8B2442D30 for ; Thu, 12 Jan 2023 11:59:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673521181; x=1705057181; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NzMmEw5aBR90292DDv4v5ZgjVaQFtB7RarGz+7QorAo=; b=hLT509mjROJLsOCXWLJPtdSwHsPoSRLsUbQhFZfMR2vSbjkAmto9flps 5hT7HOYBM7udF50ICqJg79p7jNPGndmBkZlVBzwrkzxfwrVPUh93HmD6A FgQ9jGbDO+qcI4qvSTEgFDgChMnGIPgBeUOdmlKZzsT8mkT8o3dYFgGoD vKKKzXIpEvJosAg8oB0OZmZ3DLGEfG5BsHjpz97xa26pRLCQoOsdTp54l aZeaIYF/MkiJvWdiB8KHF+338z9AbBN7C7lJcEDH2O84KY+wyhS0Fx4cz kWde8Ef3vE/irZVdbYLrSIvZZ+CWOTMltBxk1BLnO2yfeD6CC9sKKvCoA Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="321365719" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="321365719" 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:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="781746903" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="781746903" Received: from silpixa00401385.ir.intel.com ([10.237.214.166]) by orsmga004.jf.intel.com with ESMTP; 12 Jan 2023 02:59:38 -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 7/9] telemetry: update json functions to use int/uint in names Date: Thu, 12 Jan 2023 10:59:01 +0000 Message-Id: <20230112105903.46341-8-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 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