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 <m...@smartsharesystems.com>
Signed-off-by: Bruce Richardson <bruce.richard...@intel.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.34.1

Reply via email to