[PATCH 07/10] examples/pipeline: check return value of ethdev functions

Stephen Hemminger stephen at networkplumber.org
Fri Oct 4 18:21:54 CEST 2024


The rte_eth_dev_info_get and rte_eth_link_get functions may return
an error, and in that case the information structure is undefined.
The port is valid check is not needed, that can be handled by
rte_eth_dev_info_get checks.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 examples/pipeline/cli.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index 015717cb39..215b4061d5 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -390,14 +390,15 @@ ethdev_show(uint16_t port_id, char **out, size_t *out_size)
 	uint32_t length;
 	uint16_t mtu = 0;
 
-	if (!rte_eth_dev_is_valid_port(port_id))
+	if (rte_eth_dev_info_get(port_id, &info) != 0)
+		return;
+
+	if (rte_eth_link_get(port_id, &link) != 0)
 		return;
 
 	rte_eth_dev_get_name_by_port(port_id, name);
-	rte_eth_dev_info_get(port_id, &info);
 	rte_eth_stats_get(port_id, &stats);
 	rte_eth_macaddr_get(port_id, &addr);
-	rte_eth_link_get(port_id, &link);
 	rte_eth_dev_get_mtu(port_id, &mtu);
 
 	snprintf(*out, *out_size,
-- 
2.45.2



More information about the dev mailing list