Skip to content

Commit

Permalink
bitrate: fix calculation to match API description
Browse files Browse the repository at this point in the history
[ upstream commit bdd478e ]

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: 2ad7ba9 ("bitrate: add bitrate statistics library")

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
  • Loading branch information
kevintraynor authored and cpaelzer committed Nov 30, 2021
1 parent 88d1593 commit 6cd9c88
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/librte_bitratestats/rte_bitrate.c
Expand Up @@ -74,7 +74,7 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,

ret_code = rte_eth_stats_get(port_id, &eth_stats);
if (ret_code != 0)
return ret_code;
return ret_code < 0 ? ret_code : -ret_code;

port_data = &bitrate_data->port_stats[port_id];

Expand Down

0 comments on commit 6cd9c88

Please sign in to comment.