DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] test/graph: fix unused return value
@ 2023-07-21  2:13 Zhirun Yan
  2023-07-21 12:50 ` Jerin Jacob
  0 siblings, 1 reply; 4+ messages in thread
From: Zhirun Yan @ 2023-07-21  2:13 UTC (permalink / raw)
  To: dev, jerinj, kirankumark, ndabilpuram; +Cc: Zhirun Yan

Return value stored in "ret" but it may be overwritten before use.
Add goto to return when meet an error. Issue reported by coverity scan.

Coverity issue: 395532
Fixes: 15f483feec65 ("graph: fix model check in core binding")

Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
---
 app/test/test_graph.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/app/test/test_graph.c b/app/test/test_graph.c
index af90ac07ec..7995f67757 100644
--- a/app/test/test_graph.c
+++ b/app/test/test_graph.c
@@ -740,13 +740,13 @@ test_graph_model_mcore_dispatch_core_bind_unbind(void)
 	ret = rte_graph_worker_model_set(RTE_GRAPH_MODEL_MCORE_DISPATCH);
 	if (ret != 0) {
 		printf("Set graph mcore dispatch model failed\n");
-		ret = -1;
+		goto fail;
 	}
 
 	ret = rte_graph_model_mcore_dispatch_core_bind(cloned_graph_id, worker_lcore);
 	if (ret != 0) {
 		printf("bind graph %d to lcore %u failed\n", graph_id, worker_lcore);
-		ret = -1;
+		goto fail;
 	}
 
 	graph = rte_graph_lookup("worker0-cloned-test2");
@@ -755,6 +755,7 @@ test_graph_model_mcore_dispatch_core_bind_unbind(void)
 		printf("bind graph %s(id:%d) with lcore %u failed\n",
 		       graph->name, graph->id, worker_lcore);
 		ret = -1;
+		goto fail;
 	}
 
 	rte_graph_model_mcore_dispatch_core_unbind(cloned_graph_id);
@@ -764,6 +765,7 @@ test_graph_model_mcore_dispatch_core_bind_unbind(void)
 		ret = -1;
 	}
 
+fail:
 	rte_graph_destroy(cloned_graph_id);
 
 	return ret;
@@ -781,7 +783,7 @@ test_graph_worker_model_set_get(void)
 	ret = rte_graph_worker_model_set(RTE_GRAPH_MODEL_MCORE_DISPATCH);
 	if (ret != 0) {
 		printf("Set graph mcore dispatch model failed\n");
-		ret = -1;
+		goto fail;
 	}
 
 	graph = rte_graph_lookup("worker0-cloned-test3");
@@ -790,9 +792,10 @@ test_graph_worker_model_set_get(void)
 		ret = -1;
 	}
 
+fail:
 	rte_graph_destroy(cloned_graph_id);
 
-	return 0;
+	return ret;
 }
 
 static int
-- 
2.37.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] test/graph: fix unused return value
  2023-07-21  2:13 [PATCH v1] test/graph: fix unused return value Zhirun Yan
@ 2023-07-21 12:50 ` Jerin Jacob
  2023-09-27  0:48   ` Yan, Zhirun
  2023-10-17 12:01   ` Thomas Monjalon
  0 siblings, 2 replies; 4+ messages in thread
From: Jerin Jacob @ 2023-07-21 12:50 UTC (permalink / raw)
  To: Zhirun Yan; +Cc: dev, jerinj, kirankumark, ndabilpuram

On Fri, Jul 21, 2023 at 8:12 AM Zhirun Yan <zhirun.yan@intel.com> wrote:
>
> Return value stored in "ret" but it may be overwritten before use.
> Add goto to return when meet an error. Issue reported by coverity scan.
>
> Coverity issue: 395532
> Fixes: 15f483feec65 ("graph: fix model check in core binding")
>
> Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>


> ---
>  app/test/test_graph.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/app/test/test_graph.c b/app/test/test_graph.c
> index af90ac07ec..7995f67757 100644
> --- a/app/test/test_graph.c
> +++ b/app/test/test_graph.c
> @@ -740,13 +740,13 @@ test_graph_model_mcore_dispatch_core_bind_unbind(void)
>         ret = rte_graph_worker_model_set(RTE_GRAPH_MODEL_MCORE_DISPATCH);
>         if (ret != 0) {
>                 printf("Set graph mcore dispatch model failed\n");
> -               ret = -1;
> +               goto fail;
>         }
>
>         ret = rte_graph_model_mcore_dispatch_core_bind(cloned_graph_id, worker_lcore);
>         if (ret != 0) {
>                 printf("bind graph %d to lcore %u failed\n", graph_id, worker_lcore);
> -               ret = -1;
> +               goto fail;
>         }
>
>         graph = rte_graph_lookup("worker0-cloned-test2");
> @@ -755,6 +755,7 @@ test_graph_model_mcore_dispatch_core_bind_unbind(void)
>                 printf("bind graph %s(id:%d) with lcore %u failed\n",
>                        graph->name, graph->id, worker_lcore);
>                 ret = -1;
> +               goto fail;
>         }
>
>         rte_graph_model_mcore_dispatch_core_unbind(cloned_graph_id);
> @@ -764,6 +765,7 @@ test_graph_model_mcore_dispatch_core_bind_unbind(void)
>                 ret = -1;
>         }
>
> +fail:
>         rte_graph_destroy(cloned_graph_id);
>
>         return ret;
> @@ -781,7 +783,7 @@ test_graph_worker_model_set_get(void)
>         ret = rte_graph_worker_model_set(RTE_GRAPH_MODEL_MCORE_DISPATCH);
>         if (ret != 0) {
>                 printf("Set graph mcore dispatch model failed\n");
> -               ret = -1;
> +               goto fail;
>         }
>
>         graph = rte_graph_lookup("worker0-cloned-test3");
> @@ -790,9 +792,10 @@ test_graph_worker_model_set_get(void)
>                 ret = -1;
>         }
>
> +fail:
>         rte_graph_destroy(cloned_graph_id);
>
> -       return 0;
> +       return ret;
>  }
>
>  static int
> --
> 2.37.2
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v1] test/graph: fix unused return value
  2023-07-21 12:50 ` Jerin Jacob
@ 2023-09-27  0:48   ` Yan, Zhirun
  2023-10-17 12:01   ` Thomas Monjalon
  1 sibling, 0 replies; 4+ messages in thread
From: Yan, Zhirun @ 2023-09-27  0:48 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: dev, jerinj, kirankumark, ndabilpuram, David Marchand


> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Friday, July 21, 2023 8:51 PM
> To: Yan, Zhirun <zhirun.yan@intel.com>
> Cc: dev@dpdk.org; jerinj@marvell.com; kirankumark@marvell.com;
> ndabilpuram@marvell.com
> Subject: Re: [PATCH v1] test/graph: fix unused return value
> 
> On Fri, Jul 21, 2023 at 8:12 AM Zhirun Yan <zhirun.yan@intel.com> wrote:
> >
> > Return value stored in "ret" but it may be overwritten before use.
> > Add goto to return when meet an error. Issue reported by coverity scan.
> >
> > Coverity issue: 395532
> > Fixes: 15f483feec65 ("graph: fix model check in core binding")
> >
> > Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
> 
> Acked-by: Jerin Jacob <jerinj@marvell.com>

A gentle ping for merge.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] test/graph: fix unused return value
  2023-07-21 12:50 ` Jerin Jacob
  2023-09-27  0:48   ` Yan, Zhirun
@ 2023-10-17 12:01   ` Thomas Monjalon
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2023-10-17 12:01 UTC (permalink / raw)
  To: Zhirun Yan; +Cc: dev, jerinj, kirankumark, ndabilpuram, Jerin Jacob

21/07/2023 14:50, Jerin Jacob:
> On Fri, Jul 21, 2023 at 8:12 AM Zhirun Yan <zhirun.yan@intel.com> wrote:
> >
> > Return value stored in "ret" but it may be overwritten before use.
> > Add goto to return when meet an error. Issue reported by coverity scan.
> >
> > Coverity issue: 395532
> > Fixes: 15f483feec65 ("graph: fix model check in core binding")
> >
> > Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
> 
> Acked-by: Jerin Jacob <jerinj@marvell.com>

Applied, thanks.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-17 12:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21  2:13 [PATCH v1] test/graph: fix unused return value Zhirun Yan
2023-07-21 12:50 ` Jerin Jacob
2023-09-27  0:48   ` Yan, Zhirun
2023-10-17 12:01   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).