diff mbox series

[07/10] examples/l3fwd: add function return value check

Message ID 1618839289-33224-8-git-send-email-humin29@huawei.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers show
Series fixes for clean code | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

humin (Q) April 19, 2021, 1:34 p.m. UTC
From: HongBo Zheng <zhenghongbo3@huawei.com>

Return value of a function 'rte_eth_macaddr_get' called at
l3fwd_eth_dev_port_setup is not checked, but it is usually
checked for this function.

This patch fix this problem.

Fixes: a65bf3d724df ("examples/l3fwd: add ethdev setup based on eventdev")
Cc: stable@dpdk.org

Signed-off-by: HongBo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 examples/l3fwd/l3fwd_event.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/examples/l3fwd/l3fwd_event.c b/examples/l3fwd/l3fwd_event.c
index 4d31593..7f704f9 100644
--- a/examples/l3fwd/l3fwd_event.c
+++ b/examples/l3fwd/l3fwd_event.c
@@ -105,7 +105,11 @@  l3fwd_eth_dev_port_setup(struct rte_eth_conf *port_conf)
 				 "Cannot adjust number of descriptors: err=%d, "
 				 "port=%d\n", ret, port_id);
 
-		rte_eth_macaddr_get(port_id, &ports_eth_addr[port_id]);
+		ret = rte_eth_macaddr_get(port_id, &ports_eth_addr[port_id]);
+		if (ret < 0)
+			rte_exit(EXIT_FAILURE,
+				 "Cannot get MAC address: err=%d, port=%d\n",
+				 ret, port_id);
 		print_ethaddr(" Address:", &ports_eth_addr[port_id]);
 		printf(", ");
 		print_ethaddr("Destination:",