From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
To: dev@dpdk.org
Cc: konstantin.ananyev@intel.com, bernard.iremonger@intel.com,
akhil.goyal@nxp.com
Subject: [dpdk-dev] [PATCH] app: add few sanity checks in test-sad app
Date: Fri, 1 Nov 2019 11:38:34 +0000 [thread overview]
Message-ID: <b7d06f79141305aa570cbeb2042761b55af8a197.1572608255.git.vladimir.medvedkin@intel.com> (raw)
Coverity reported about two division by zero:
*** CID 350344: Incorrect expression (DIVIDE_BY_ZERO)
Although in fact these dividers will never be equal to 0,
adding explicit checks in lookup() to make coverity happy
will not affect the execution speed.
Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
app/test-sad/main.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/test-sad/main.c b/app/test-sad/main.c
index bd05638..e61e33f 100644
--- a/app/test-sad/main.c
+++ b/app/test-sad/main.c
@@ -519,6 +519,9 @@ lookup(void *arg)
uint32_t burst_sz;
struct rte_ipsec_sad *sad = arg;
+ if (config.nb_tuples == 0)
+ return 0;
+
burst_sz = RTE_MIN(config.burst_sz, config.nb_tuples);
for (i = 0; i < config.nb_tuples; i += burst_sz) {
for (j = 0; j < burst_sz; j++)
@@ -534,6 +537,7 @@ lookup(void *arg)
print_result(keys[j], vals[j]);
}
}
+ acc = (acc == 0) ? UINT64_MAX : acc;
printf("Average lookup cycles %.2Lf, lookups/sec: %.2Lf\n",
(long double)acc / config.nb_tuples,
(long double)config.nb_tuples * rte_get_tsc_hz() / acc);
--
2.7.4
next reply other threads:[~2019-11-01 11:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-01 11:38 Vladimir Medvedkin [this message]
2019-11-05 22:51 ` Akhil Goyal
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=b7d06f79141305aa570cbeb2042761b55af8a197.1572608255.git.vladimir.medvedkin@intel.com \
--to=vladimir.medvedkin@intel.com \
--cc=akhil.goyal@nxp.com \
--cc=bernard.iremonger@intel.com \
--cc=dev@dpdk.org \
--cc=konstantin.ananyev@intel.com \
/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).