> -----Original Message-----
> From: Jonathan Erb <[email protected]>
> Sent: Thursday, January 18, 2024 5:26 PM
> To: Power, Ciara <[email protected]>
> Cc: [email protected]; Richardson, Bruce <[email protected]>;
> Jonathan Erb <[email protected]>
> Subject: [PATCH] telemetry: correct json empty dictionaries
>
> Fix to allow telemetry to handle empty dictionaries correctly.
>
> This patch resolves an issue where empty dictionaries are reported by
> telemetry as '[]' rather than '{}'. Initializing the output buffer based on
> the
> container type resolves the issue.
>
> Signed-off-by: Jonathan Erb <[email protected]>
> ---
> .mailmap | 2 +-
> lib/telemetry/telemetry.c | 6 +++++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/.mailmap b/.mailmap
> index ab0742a382..a6b66ab3ad 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -675,7 +675,7 @@ John Ousterhout <[email protected]> John
> Romein <[email protected]> John W. Linville <[email protected]> Jonas
> Pfefferle <[email protected]> <[email protected]> -Jonathan Erb
> <[email protected]> <[email protected]>
> +Jonathan Erb <[email protected]>
> +<[email protected]> <[email protected]>
> Jonathan Tsai <[email protected]> Jon DeVree <[email protected]>
> Jon Loeliger <[email protected]> diff --git a/lib/telemetry/telemetry.c
> b/lib/telemetry/telemetry.c index 92982842a8..eef4ac7bb7 100644
> --- a/lib/telemetry/telemetry.c
> +++ b/lib/telemetry/telemetry.c
> @@ -169,7 +169,11 @@ container_to_json(const struct rte_tel_data *d, char
> *out_buf, size_t buf_len)
> d->type != TEL_ARRAY_INT && d->type !=
> TEL_ARRAY_STRING)
> return snprintf(out_buf, buf_len, "null");
>
> - used = rte_tel_json_empty_array(out_buf, buf_len, 0);
> + if (d->type == TEL_DICT)
> + used = rte_tel_json_empty_obj(out_buf, buf_len, 0);
> + else
> + 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_uint(out_buf,
> --
> 2.34.1
Acked-by: Ciara Power <[email protected]>