From: Kevin Traynor <ktraynor@redhat.com>
Date: Fri, 9 Jul 2021 15:19:36 +0000 (+0100)
Subject: bitrate: fix registration to match API description
X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=06ae9f0f92cf3bb85549f66dc3dfa11011d7db0f;p=dpdk.git

bitrate: fix registration to match API description

rte_stats_bitrate_reg() API states it returns 'Zero on success'.

However, the implementation directly returns the return of
rte_metrics_reg_names() which may be zero or positive on success,
with a positive value also indicating the index.

The user of rte_stats_bitrate_reg() should not care about the
index as it is stored in the opaque rte_stats_bitrates struct.

Change the implementation of rte_stats_bitrate_reg() to match
the API description by always returning zero on success.

Fixes: 2ad7ba9a6567 ("bitrate: add bitrate statistics library")

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
---

diff --git a/lib/bitratestats/rte_bitrate.c b/lib/bitratestats/rte_bitrate.c
index 8fd9f47288..e23e38bc94 100644
--- a/lib/bitratestats/rte_bitrate.c
+++ b/lib/bitratestats/rte_bitrate.c
@@ -55,8 +55,10 @@ rte_stats_bitrate_reg(struct rte_stats_bitrates *bitrate_data)
 		return -EINVAL;
 
 	return_value = rte_metrics_reg_names(&names[0], RTE_DIM(names));
-	if (return_value >= 0)
+	if (return_value >= 0) {
 		bitrate_data->id_stats_set = return_value;
+		return 0;
+	}
 	return return_value;
 }