app/testeventdev: fix divide by zero in stats
authorJerin Jacob <jerin.jacob@caviumnetworks.com>
Mon, 31 Jul 2017 10:04:52 +0000 (15:34 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 31 Jul 2017 20:43:48 +0000 (22:43 +0200)
pkts == 0 will result in divide by zero case.
Added a check to fix it.

Coverity issue: 158652
Fixes: 9d3aeb185eb4 ("app/testeventdev: launch perf lcores")
Cc: stable@dpdk.org
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
app/test-eventdev/test_perf_common.c

index a5b768c..7b09299 100644 (file)
@@ -203,7 +203,7 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
                        perf_cycles = new_cycles;
                        total_mpps += mpps;
                        ++samples;
-                       if (opt->fwd_latency) {
+                       if (opt->fwd_latency && pkts > 0) {
                                printf(CLGRN"\r%.3f mpps avg %.3f mpps [avg fwd latency %.3f us] "CLNRM,
                                        mpps, total_mpps/samples,
                                        (float)(latency/pkts)/freq_mhz);