diff mbox series

[v2,1/2] lib/metrics: fix to reset the init flag

Message ID 20200519105258.31426-1-hemant.agrawal@nxp.com
State New
Headers show
Series [v2,1/2] lib/metrics: fix to reset the init flag | expand

Commit Message

Hemant Agrawal May 19, 2020, 10:52 a.m. UTC
metrics_initialized shall be reset in deinit function
This is currently causing issue in running
metrics_autotest mulutiple times

Fixes: 07c1b6925b65 ("telemetry: invert dependency on metrics library")

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

---
 lib/librte_metrics/rte_metrics.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

-- 
2.17.1

Comments

David Marchand May 19, 2020, 12:12 p.m. UTC | #1
On Tue, May 19, 2020 at 12:55 PM Hemant Agrawal <hemant.agrawal@nxp.com> wrote:
>

> metrics_initialized shall be reset in deinit function

> This is currently causing issue in running

> metrics_autotest mulutiple times

>

> Fixes: 07c1b6925b65 ("telemetry: invert dependency on metrics library")

>

> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>


For the series,
Acked-by: David Marchand <david.marchand@redhat.com>



Applied, thanks.

-- 
David Marchand
Stephen Hemminger May 19, 2020, 3:23 p.m. UTC | #2
On Tue, 19 May 2020 16:22:57 +0530
Hemant Agrawal <hemant.agrawal@nxp.com> wrote:

> diff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metrics.c

> index e07670219f..dba6409c27 100644

> --- a/lib/librte_metrics/rte_metrics.c

> +++ b/lib/librte_metrics/rte_metrics.c

> @@ -85,6 +85,7 @@ rte_metrics_deinit(void)

>  {

>  	struct rte_metrics_data_s *stats;

>  	const struct rte_memzone *memzone;

> +	int ret = 0;

>  


Why do gratuitous initialization? It blocks compiler from finding buggy
code.
diff mbox series

Patch

diff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metrics.c
index e07670219f..dba6409c27 100644
--- a/lib/librte_metrics/rte_metrics.c
+++ b/lib/librte_metrics/rte_metrics.c
@@ -85,6 +85,7 @@  rte_metrics_deinit(void)
 {
 	struct rte_metrics_data_s *stats;
 	const struct rte_memzone *memzone;
+	int ret = 0;
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return -EINVAL;
@@ -96,8 +97,10 @@  rte_metrics_deinit(void)
 	stats = memzone->addr;
 	memset(stats, 0, sizeof(struct rte_metrics_data_s));
 
-	return rte_memzone_free(memzone);
-
+	ret  = rte_memzone_free(memzone);
+	if (ret == 0)
+		metrics_initialized = 0;
+	return ret;
 }
 
 int