DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: dev@dpdk.org
Cc: mdr@ashroe.eu, Kevin Traynor <ktraynor@redhat.com>
Subject: [dpdk-dev] [PATCH 2/3] bitrate: change calc implementation to match API description
Date: Fri,  9 Jul 2021 16:19:37 +0100	[thread overview]
Message-ID: <20210709151938.701895-2-ktraynor@redhat.com> (raw)
In-Reply-To: <20210709151938.701895-1-ktraynor@redhat.com>

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 <ktraynor@redhat.com>
---
 lib/bitratestats/rte_bitrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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
@@ -81,5 +81,5 @@ 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];
-- 
2.31.1


  reply	other threads:[~2021-07-09 15:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 15:19 [dpdk-dev] [PATCH 1/3] bitrate: change reg " Kevin Traynor
2021-07-09 15:19 ` Kevin Traynor [this message]
2021-07-09 15:19 ` [dpdk-dev] [PATCH 3/3] bitrate: promote rte_stats_bitrate_free() to stable Kevin Traynor
2021-07-22 19:46 ` [dpdk-dev] [PATCH 1/3] bitrate: change reg implementation to match API description Thomas Monjalon
2021-07-22 20:24   ` Kevin Traynor
2021-10-01 13:32     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210709151938.701895-2-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=dev@dpdk.org \
    --cc=mdr@ashroe.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).