* [dpdk-dev] [PATCH v1] lib/metrics: fix silent fail when uninitialised
@ 2018-07-02 14:55 Remy Horton
2018-07-26 18:29 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: Remy Horton @ 2018-07-02 14:55 UTC (permalink / raw)
To: dev; +Cc: Reshma Pattan
If rte_metrics_init() had not been called and hence the internal
metric storage is not allocated, rte_metrics_get_values() and
rte_metrics_get_name() would silently fail by returning zero
(i.e. no metrics registered). This patch changes the result of
this scenario to an explicit fail by returning -EIO.
Fixes: 349950ddb9c5 ("metrics: add information metrics library")
Signed-off-by: Remy Horton <remy.horton@intel.com>
---
lib/librte_metrics/rte_metrics.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metrics.c
index 258f058..fed0a33 100644
--- a/lib/librte_metrics/rte_metrics.c
+++ b/lib/librte_metrics/rte_metrics.c
@@ -200,9 +200,8 @@ rte_metrics_get_names(struct rte_metric_name *names,
int return_value;
memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
- /* If not allocated, fail silently */
if (memzone == NULL)
- return 0;
+ return -EIO;
stats = memzone->addr;
rte_spinlock_lock(&stats->lock);
@@ -238,9 +237,9 @@ rte_metrics_get_values(int port_id,
return -EINVAL;
memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
- /* If not allocated, fail silently */
if (memzone == NULL)
- return 0;
+ return -EIO;
+
stats = memzone->addr;
rte_spinlock_lock(&stats->lock);
--
2.9.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH v1] lib/metrics: fix silent fail when uninitialised
2018-07-02 14:55 [dpdk-dev] [PATCH v1] lib/metrics: fix silent fail when uninitialised Remy Horton
@ 2018-07-26 18:29 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2018-07-26 18:29 UTC (permalink / raw)
To: Remy Horton; +Cc: dev, Reshma Pattan
02/07/2018 16:55, Remy Horton:
> If rte_metrics_init() had not been called and hence the internal
> metric storage is not allocated, rte_metrics_get_values() and
> rte_metrics_get_name() would silently fail by returning zero
> (i.e. no metrics registered). This patch changes the result of
> this scenario to an explicit fail by returning -EIO.
>
> Fixes: 349950ddb9c5 ("metrics: add information metrics library")
>
> Signed-off-by: Remy Horton <remy.horton@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-26 18:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-02 14:55 [dpdk-dev] [PATCH v1] lib/metrics: fix silent fail when uninitialised Remy Horton
2018-07-26 18:29 ` 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).