examples/l3fwd-graph: fix unchecked function return values
diff mbox series

Message ID 20200513202218.6045-1-pbhagavatula@marvell.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • examples/l3fwd-graph: fix unchecked function return values
Related show

Checks

Context Check Description
ci/iol-testing fail Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Pavan Nikhilesh Bhagavatula May 13, 2020, 8:22 p.m. UTC
From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Fix unchecked return values reported by coverity.

Coverity issue: 350601
Fixes: ef853f1fd979 ("examples/l3fwd-graph: add ethdev configuration changes")

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 examples/l3fwd-graph/main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Nithin Dabilpuram May 14, 2020, 10:39 a.m. UTC | #1
On Thu, May 14, 2020 at 01:52:17AM +0530, pbhagavatula@marvell.com wrote:
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Fix unchecked return values reported by coverity.
> 
> Coverity issue: 350601
> Fixes: ef853f1fd979 ("examples/l3fwd-graph: add ethdev configuration changes")
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>

Acked-by: Nithin Dabilpuram <ndabilpuram@marvell.com>

> ---
>  examples/l3fwd-graph/main.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/examples/l3fwd-graph/main.c b/examples/l3fwd-graph/main.c
> index 40108a0d3..c70270c4d 100644
> --- a/examples/l3fwd-graph/main.c
> +++ b/examples/l3fwd-graph/main.c
> @@ -598,6 +598,7 @@ check_all_ports_link_status(uint32_t port_mask)
>  	uint8_t count, all_ports_up, print_flag = 0;
>  	struct rte_eth_link link;
>  	uint16_t portid;
> +	int ret;
>  
>  	printf("\nChecking link status");
>  	fflush(stdout);
> @@ -612,7 +613,14 @@ check_all_ports_link_status(uint32_t port_mask)
>  			if ((port_mask & (1 << portid)) == 0)
>  				continue;
>  			memset(&link, 0, sizeof(link));
> -			rte_eth_link_get_nowait(portid, &link);
> +			ret = rte_eth_link_get_nowait(portid, &link);
> +			if (ret < 0) {
> +				all_ports_up = 0;
> +				if (print_flag == 1)
> +					printf("Port %u link get failed: %s\n",
> +						portid, rte_strerror(-ret));
> +				continue;
> +			}
>  			/* Print link status if flag set */
>  			if (print_flag == 1) {
>  				if (link.link_status)
> -- 
> 2.17.1
>
Thomas Monjalon May 19, 2020, 5:14 p.m. UTC | #2
14/05/2020 12:39, Nithin Dabilpuram:
> On Thu, May 14, 2020 at 01:52:17AM +0530, pbhagavatula@marvell.com wrote:
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > 
> > Fix unchecked return values reported by coverity.
> > 
> > Coverity issue: 350601
> > Fixes: ef853f1fd979 ("examples/l3fwd-graph: add ethdev configuration changes")
> > 
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Acked-by: Nithin Dabilpuram <ndabilpuram@marvell.com>

Applied with a more precise title:
examples/l3fwd-graph: check link query failure

Patch
diff mbox series

diff --git a/examples/l3fwd-graph/main.c b/examples/l3fwd-graph/main.c
index 40108a0d3..c70270c4d 100644
--- a/examples/l3fwd-graph/main.c
+++ b/examples/l3fwd-graph/main.c
@@ -598,6 +598,7 @@  check_all_ports_link_status(uint32_t port_mask)
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
 	uint16_t portid;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -612,7 +613,14 @@  check_all_ports_link_status(uint32_t port_mask)
 			if ((port_mask & (1 << portid)) == 0)
 				continue;
 			memset(&link, 0, sizeof(link));
-			rte_eth_link_get_nowait(portid, &link);
+			ret = rte_eth_link_get_nowait(portid, &link);
+			if (ret < 0) {
+				all_ports_up = 0;
+				if (print_flag == 1)
+					printf("Port %u link get failed: %s\n",
+						portid, rte_strerror(-ret));
+				continue;
+			}
 			/* Print link status if flag set */
 			if (print_flag == 1) {
 				if (link.link_status)