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

Message ID 20200519105258.31426-1-hemant.agrawal@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v2,1/2] lib/metrics: fix to reset the init flag |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

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(-)
  

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.
  
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.
  

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