[4/8] ethdev: fix possible data truncation and conversion error

Message ID 20221208080540.62913-5-lihuisong@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series fix possible data truncation and conversion error |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

lihuisong (C) Dec. 8, 2022, 8:05 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: 58b43c1ddfd1 ("ethdev: add telemetry endpoint for device info")
Cc: stable@dpdk.org

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

Patch

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 5d5e18db1e..dfb269970e 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6037,9 +6037,9 @@  eth_dev_handle_port_info(const char *cmd __rte_unused,
 			eth_dev->data->nb_tx_queues);
 	rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id);
 	rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu);
-	rte_tel_data_add_dict_int(d, "rx_mbuf_size_min",
+	rte_tel_data_add_dict_u32(d, "rx_mbuf_size_min",
 			eth_dev->data->min_rx_buf_size);
-	rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail",
+	rte_tel_data_add_dict_u64(d, "rx_mbuf_alloc_fail",
 			eth_dev->data->rx_mbuf_alloc_failed);
 	rte_ether_format_addr(mac_addr, sizeof(mac_addr),
 			eth_dev->data->mac_addrs);
@@ -6068,12 +6068,12 @@  eth_dev_handle_port_info(const char *cmd __rte_unused,
 	rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0);
 	rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0);
 	rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
-	rte_tel_data_add_dict_int(d, "dev_flags", eth_dev->data->dev_flags);
-	rte_tel_data_add_dict_int(d, "rx_offloads",
+	rte_tel_data_add_dict_u32(d, "dev_flags", eth_dev->data->dev_flags);
+	rte_tel_data_add_dict_u64(d, "rx_offloads",
 			eth_dev->data->dev_conf.rxmode.offloads);
-	rte_tel_data_add_dict_int(d, "tx_offloads",
+	rte_tel_data_add_dict_u64(d, "tx_offloads",
 			eth_dev->data->dev_conf.txmode.offloads);
-	rte_tel_data_add_dict_int(d, "ethdev_rss_hf",
+	rte_tel_data_add_dict_u64(d, "ethdev_rss_hf",
 			eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
 
 	return 0;