[12/18] examples/ip_pipeline: check status of getting link info

Message ID 1568103959-25572-13-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series ethdev: change link status get functions return value to int |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Andrew Rybchenko Sept. 10, 2019, 8:25 a.m. UTC
  From: Igor Romanov <igor.romanov@oktetlabs.ru>

The return value of rte_eth_link_get() and rte_eth_link_get_nowait()
was changed from void to int. Update the usage of the functions
according to the new return type.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 examples/ip_pipeline/cli.c  | 9 ++++++++-
 examples/ip_pipeline/link.c | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)
  

Patch

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index c6cf4204e..4930310cc 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -248,12 +248,19 @@  print_link_info(struct link *link, char *out, size_t out_size)
 	struct rte_ether_addr mac_addr;
 	struct rte_eth_link eth_link;
 	uint16_t mtu;
+	int ret;
 
 	memset(&stats, 0, sizeof(stats));
 	rte_eth_stats_get(link->port_id, &stats);
 
 	rte_eth_macaddr_get(link->port_id, &mac_addr);
-	rte_eth_link_get(link->port_id, &eth_link);
+	ret = rte_eth_link_get(link->port_id, &eth_link);
+	if (ret < 0) {
+		snprintf(out, out_size, "\n%s: link get failed: %s",
+			 link->name, rte_strerror(-ret));
+		return;
+	}
+
 	rte_eth_dev_get_mtu(link->port_id, &mtu);
 
 	snprintf(out, out_size,
diff --git a/examples/ip_pipeline/link.c b/examples/ip_pipeline/link.c
index 744abf394..16bcffe35 100644
--- a/examples/ip_pipeline/link.c
+++ b/examples/ip_pipeline/link.c
@@ -264,7 +264,8 @@  link_is_up(const char *name)
 		return 0;
 
 	/* Resource */
-	rte_eth_link_get(link->port_id, &link_params);
+	if (rte_eth_link_get(link->port_id, &link_params) < 0)
+		return 0;
 
 	return (link_params.link_status == ETH_LINK_DOWN) ? 0 : 1;
 }