From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: "Bruce Richardson" <bruce.richardson@intel.com>,
"Morten Brørup" <mb@smartsharesystems.com>,
"Tyler Retzlaff" <roretzla@linux.microsoft.com>,
"Ciara Power" <ciara.power@intel.com>
Subject: [PATCH v2 7/9] telemetry: update json functions to use int/uint in names
Date: Thu, 12 Jan 2023 10:59:01 +0000 [thread overview]
Message-ID: <20230112105903.46341-8-bruce.richardson@intel.com> (raw)
In-Reply-To: <20230112105903.46341-1-bruce.richardson@intel.com>
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 <mb@smartsharesystems.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
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
next prev parent reply other threads:[~2023-01-12 11:00 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-13 18:27 [RFC PATCH 0/7] Standardize telemetry int types Bruce Richardson
2022-12-13 18:27 ` [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint Bruce Richardson
2022-12-14 17:30 ` Tyler Retzlaff
2022-12-15 9:41 ` Bruce Richardson
2022-12-15 17:53 ` Tyler Retzlaff
2022-12-13 18:27 ` [RFC PATCH 2/7] telemetry: add uint type as alias for u64 Bruce Richardson
2022-12-14 17:38 ` Tyler Retzlaff
2022-12-15 9:44 ` Bruce Richardson
2022-12-15 13:36 ` Thomas Monjalon
2022-12-15 13:58 ` Bruce Richardson
2022-12-19 10:37 ` Thomas Monjalon
2022-12-19 13:22 ` Bruce Richardson
2022-12-15 17:58 ` Tyler Retzlaff
2022-12-15 1:49 ` lihuisong (C)
2022-12-15 9:42 ` Bruce Richardson
2022-12-15 18:02 ` Tyler Retzlaff
2022-12-13 18:27 ` [RFC PATCH 3/7] telemetry: remove RTE prefix from internal enum values Bruce Richardson
2022-12-13 18:27 ` [RFC PATCH 4/7] telemetry: make array initialization more robust Bruce Richardson
2022-12-14 17:50 ` Tyler Retzlaff
2023-01-09 12:16 ` Bruce Richardson
2023-01-09 17:49 ` Tyler Retzlaff
2023-01-10 9:11 ` Ferruh Yigit
2022-12-13 18:27 ` [RFC PATCH 5/7] telemetry: update json functions to use int/uint in names Bruce Richardson
2022-12-13 18:27 ` [RFC PATCH 6/7] telemetry: make internal int representation 64-bits Bruce Richardson
2022-12-13 18:27 ` [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values Bruce Richardson
2022-12-13 20:19 ` Morten Brørup
2022-12-14 17:53 ` Tyler Retzlaff
2022-12-15 2:39 ` lihuisong (C)
2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson
2023-01-12 10:58 ` [PATCH v2 1/9] telemetry: remove RTE prefix from internal enum values Bruce Richardson
2023-01-12 10:58 ` [PATCH v2 2/9] telemetry: make array initialization more robust Bruce Richardson
2023-01-12 10:58 ` [PATCH v2 3/9] telemetry: rename unsigned 64-bit enum value to uint Bruce Richardson
2023-01-12 10:58 ` [PATCH v2 4/9] telemetry: add uint type as alias for u64 Bruce Richardson
2023-01-12 10:58 ` [PATCH v2 5/9] global: rename telemetry functions to newer versions Bruce Richardson
2023-01-12 10:59 ` [PATCH v2 6/9] telemetry: mark old names of renamed fns as deprecated Bruce Richardson
2023-01-12 10:59 ` Bruce Richardson [this message]
2023-01-12 10:59 ` [PATCH v2 8/9] telemetry: make internal int representation 64-bits Bruce Richardson
2023-01-12 10:59 ` [PATCH v2 9/9] telemetry: change public API to use 64-bit signed values Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 1/9] telemetry: remove RTE prefix from internal enum values Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 2/9] telemetry: make array initialization more robust Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 3/9] telemetry: rename unsigned 64-bit enum value to uint Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 4/9] telemetry: add uint type as alias for u64 Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 5/9] global: rename telemetry functions to newer versions Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 6/9] telemetry: mark old names of renamed fns as deprecated Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 7/9] telemetry: update json functions to use int/uint in names Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 8/9] telemetry: make internal int representation 64-bits Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 9/9] telemetry: change public API to use 64-bit signed values Bruce Richardson
2023-02-05 22:55 ` Thomas Monjalon
2023-01-13 16:39 ` [PATCH v3 0/9] Standardize telemetry int types Power, Ciara
2023-02-05 23:15 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230112105903.46341-8-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=ciara.power@intel.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=roretzla@linux.microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).