metrics: do not fail silently when uninitialised
authorRemy Horton <remy.horton@intel.com>
Mon, 2 Jul 2018 14:55:47 +0000 (15:55 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 26 Jul 2018 18:28:02 +0000 (20:28 +0200)
commita84bdf6a101f2ab3c3859a40f366962d78c12868
tree51301db8b88323a4971504eaaaf07beb18fafcf4
parent50d2459fdde1916c2ebce1a3751ab2fa59c0766f
metrics: do not fail silently when uninitialised

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")
Cc: stable@dpdk.org
Signed-off-by: Remy Horton <remy.horton@intel.com>
lib/librte_metrics/rte_metrics.c