app: add few sanity checks in test-sad app
Checks
Commit Message
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(+)
Comments
>
> 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.
@@ -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);