From: Kevin Traynor Date: Fri, 9 Jul 2021 15:19:37 +0000 (+0100) Subject: bitrate: fix calculation to match API description X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=bdd478eede455611245593edd43dc49a1d821449;p=dpdk.git bitrate: fix calculation to match API description rte_stats_bitrate_calc() API states it returns 'Negative value on error'. However, the implementation will return the error code from rte_eth_stats_get() which may be non-zero on error. Change the implementation of rte_stats_bitrate_calc() to match the API description by always returning a negative value on error. Fixes: 2ad7ba9a6567 ("bitrate: add bitrate statistics library") Signed-off-by: Kevin Traynor --- diff --git a/lib/bitratestats/rte_bitrate.c b/lib/bitratestats/rte_bitrate.c index e23e38bc94..1664e4863b 100644 --- a/lib/bitratestats/rte_bitrate.c +++ b/lib/bitratestats/rte_bitrate.c @@ -80,7 +80,7 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data, ret_code = rte_eth_stats_get(port_id, ð_stats); if (ret_code != 0) - return ret_code; + return ret_code < 0 ? ret_code : -ret_code; port_data = &bitrate_data->port_stats[port_id];