The return value of the get link function call was not checked, and
could return a negative value indicating a failure. This meant the
link_status of the link being checked is invalid, because the link was
not filled with data. The return value is now checked, and if the return
value is not 0 for success, the loop continues with the next port.
To avoid confusion between variable names, the existing retval variable
is renamed to link_status, to better represent its use.
Coverity issue: 350348
Fixes:
c8e6ceecebc1 ("examples/ioat: add new sample app for ioat driver")
Cc: stable@dpdk.org
Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
{
uint16_t portid;
struct rte_eth_link link;
- int retval = 0;
+ int ret, link_status = 0;
printf("\nChecking link status\n");
RTE_ETH_FOREACH_DEV(portid) {
continue;
memset(&link, 0, sizeof(link));
- rte_eth_link_get(portid, &link);
+ ret = rte_eth_link_get(portid, &link);
+ if (ret < 0) {
+ printf("Port %u link get failed: err=%d\n",
+ portid, ret);
+ continue;
+ }
/* Print link status */
if (link.link_status) {
portid, link.link_speed,
(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex\n"));
- retval = 1;
+ link_status = 1;
} else
printf("Port %d Link Down\n", portid);
}
- return retval;
+ return link_status;
}
static void