app/testeventdev: fix divide by zero in stats

pkts == 0 will result in divide by zero case.
Added a check to fix it.

Coverity issue: 158652
Fixes: 9d3aeb185e ("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>
This commit is contained in:
Jerin Jacob 2017-07-31 15:34:52 +05:30 committed by Thomas Monjalon
parent 30005d0926
commit 04716352be

View 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);