DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrius Sirvys <andrius.sirvys@intel.com>
To: dev@dpdk.org
Cc: stable@dpdk.org, Andrius Sirvys <andrius.sirvys@intel.com>,
	remy.horton@intel.com
Subject: [dpdk-dev] [PATCH v2] lib/bitratestats: fix unchecked return value
Date: Thu, 18 Apr 2019 09:52:06 +0100	[thread overview]
Message-ID: <20190418085206.86048-1-andrius.sirvys@intel.com> (raw)
Message-ID: <20190418085206.jJgal8iwZutBbp748xh2gy_EQoW1uTJINLO8bi3NnlY@z> (raw)

Checking the return value of rte_metrics_update_values, if failed
returning that value.
Coverity had picked up that that the return value wasn't being checked.

Coverity issue: 336863
Fixes: 2ad7ba9a6567 ("bitrate: add bitrate statistics library")
Cc: remy.horton@intel.com

Signed-off-by: Andrius Sirvys <andrius.sirvys@intel.com>
Acked-by: Rami Rosen <ramirose@gmail.com>
---
v2: Fixed checkpatch warnings and build failures
---
 lib/librte_bitratestats/rte_bitrate.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_bitratestats/rte_bitrate.c b/lib/librte_bitratestats/rte_bitrate.c
index c4b28f624..639e47547 100644
--- a/lib/librte_bitratestats/rte_bitrate.c
+++ b/lib/librte_bitratestats/rte_bitrate.c
@@ -67,6 +67,7 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
 	int64_t delta;
 	const int64_t alpha_percent = 20;
 	uint64_t values[6];
+	int ret;
 
 	if (bitrate_data == NULL)
 		return -EINVAL;
@@ -124,7 +125,10 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
 	values[3] = port_data->mean_obits;
 	values[4] = port_data->peak_ibits;
 	values[5] = port_data->peak_obits;
-	rte_metrics_update_values(port_id, bitrate_data->id_stats_set,
+	ret = rte_metrics_update_values(port_id, bitrate_data->id_stats_set,
 		values, ARRAY_SIZE(values));
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
-- 
2.17.1


             reply	other threads:[~2019-04-18  8:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-18  8:52 Andrius Sirvys [this message]
2019-04-18  8:52 ` Andrius Sirvys
2019-04-18  9:21 ` [dpdk-dev] [dpdk-stable] " Mcnamara, John
2019-04-18  9:21   ` Mcnamara, John
2019-04-22 22:20   ` Thomas Monjalon
2019-04-22 22:20     ` 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=20190418085206.86048-1-andrius.sirvys@intel.com \
    --to=andrius.sirvys@intel.com \
    --cc=dev@dpdk.org \
    --cc=remy.horton@intel.com \
    --cc=stable@dpdk.org \
    /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).