DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app: add few sanity checks in test-sad app
@ 2019-11-01 11:38 Vladimir Medvedkin
  2019-11-05 22:51 ` Akhil Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Medvedkin @ 2019-11-01 11:38 UTC (permalink / raw)
  To: dev; +Cc: konstantin.ananyev, bernard.iremonger, akhil.goyal

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] app: add few sanity checks in test-sad app
  2019-11-01 11:38 [dpdk-dev] [PATCH] app: add few sanity checks in test-sad app Vladimir Medvedkin
@ 2019-11-05 22:51 ` Akhil Goyal
  0 siblings, 0 replies; 2+ messages in thread
From: Akhil Goyal @ 2019-11-05 22:51 UTC (permalink / raw)
  To: Vladimir Medvedkin, dev; +Cc: konstantin.ananyev, bernard.iremonger



> 
> 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>
> ---
Applied to dpdk-next-crypto

Thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-05 22:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01 11:38 [dpdk-dev] [PATCH] app: add few sanity checks in test-sad app Vladimir Medvedkin
2019-11-05 22:51 ` Akhil Goyal

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).