app/bbdev: fix division by zero in latency measure
authorAmr Mokhtar <amr.mokhtar@intel.com>
Wed, 31 Jan 2018 12:56:21 +0000 (12:56 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 31 Jan 2018 17:42:38 +0000 (18:42 +0100)
check that iter > 0 before division

Coverity issue: 257027, 257038, 257014
Fixes: f714a18885a6 ("app/testbbdev: add test application for bbdev")

Signed-off-by: Amr Mokhtar <amr.mokhtar@intel.com>
app/test-bbdev/test_bbdev_perf.c

index f7b51ca..8f6896c 100644 (file)
@@ -1805,7 +1805,7 @@ operation_latency_test(struct active_device *ad,
                                op_params->ref_enc_op, ad->dev_id, queue_id,
                                num_to_process, burst_sz, &total_time);
 
-       if (iter < 0)
+       if (iter <= 0)
                return TEST_FAILED;
 
        printf("\toperation avg. latency: %lg cycles, %lg us\n",
@@ -1955,7 +1955,7 @@ offload_latency_test(struct active_device *ad,
                                num_to_process, burst_sz, &enq_total_time,
                                &deq_total_time);
 
-       if (iter < 0)
+       if (iter <= 0)
                return TEST_FAILED;
 
        printf("\tenq offload avg. latency: %lg cycles, %lg us\n",
@@ -2047,7 +2047,7 @@ offload_latency_empty_q_test(struct active_device *ad,
                iter = offload_latency_empty_q_test_enc(ad->dev_id, queue_id,
                                num_to_process, burst_sz, &deq_total_time);
 
-       if (iter < 0)
+       if (iter <= 0)
                return TEST_FAILED;
 
        printf("\tempty deq offload avg. latency: %lg cycles, %lg us\n",