[V2,05/11] mempool: fix possible data truncation and conversion error

Message ID 20221209110450.62456-6-lihuisong@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series telemetry: add u32 value type and hex integer string API |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

lihuisong (C) Dec. 9, 2022, 11:04 a.m. UTC
  The 'u32' and 'u64' data can not assigned to 'int' type variable. The 'u32'
data need to use the 'u32' telemetry API to add, and the 'u64' data need to
use the 'u64' telemetry API to add.

Fixes: 2f5c4025abb3 ("mempool: add telemetry endpoint")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 lib/mempool/rte_mempool.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
  

Patch

diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index f33f455790..c665fa5e14 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -1500,27 +1500,27 @@  mempool_info_cb(struct rte_mempool *mp, void *arg)
 		return;
 
 	rte_tel_data_add_dict_string(info->d, "name", mp->name);
-	rte_tel_data_add_dict_int(info->d, "pool_id", mp->pool_id);
-	rte_tel_data_add_dict_int(info->d, "flags", mp->flags);
+	rte_tel_data_add_dict_u64(info->d, "pool_id", mp->pool_id);
+	rte_tel_data_add_dict_u32(info->d, "flags", mp->flags);
 	rte_tel_data_add_dict_int(info->d, "socket_id", mp->socket_id);
-	rte_tel_data_add_dict_int(info->d, "size", mp->size);
-	rte_tel_data_add_dict_int(info->d, "cache_size", mp->cache_size);
-	rte_tel_data_add_dict_int(info->d, "elt_size", mp->elt_size);
-	rte_tel_data_add_dict_int(info->d, "header_size", mp->header_size);
-	rte_tel_data_add_dict_int(info->d, "trailer_size", mp->trailer_size);
-	rte_tel_data_add_dict_int(info->d, "private_data_size",
+	rte_tel_data_add_dict_u32(info->d, "size", mp->size);
+	rte_tel_data_add_dict_u32(info->d, "cache_size", mp->cache_size);
+	rte_tel_data_add_dict_u32(info->d, "elt_size", mp->elt_size);
+	rte_tel_data_add_dict_u32(info->d, "header_size", mp->header_size);
+	rte_tel_data_add_dict_u32(info->d, "trailer_size", mp->trailer_size);
+	rte_tel_data_add_dict_u32(info->d, "private_data_size",
 				  mp->private_data_size);
 	rte_tel_data_add_dict_int(info->d, "ops_index", mp->ops_index);
-	rte_tel_data_add_dict_int(info->d, "populated_size",
+	rte_tel_data_add_dict_u32(info->d, "populated_size",
 				  mp->populated_size);
 
 	mz = mp->mz;
 	rte_tel_data_add_dict_string(info->d, "mz_name", mz->name);
-	rte_tel_data_add_dict_int(info->d, "mz_len", mz->len);
-	rte_tel_data_add_dict_int(info->d, "mz_hugepage_sz",
+	rte_tel_data_add_dict_u64(info->d, "mz_len", mz->len);
+	rte_tel_data_add_dict_u64(info->d, "mz_hugepage_sz",
 				  mz->hugepage_sz);
 	rte_tel_data_add_dict_int(info->d, "mz_socket_id", mz->socket_id);
-	rte_tel_data_add_dict_int(info->d, "mz_flags", mz->flags);
+	rte_tel_data_add_dict_u32(info->d, "mz_flags", mz->flags);
 }
 
 static int