Skip to contentSkip to conversation

test-bbdev coverity fixes

PATCH Applied Hernan Vargas 2 participants 6 messages Mar 9, 2023 – Mar 16, 2023

lore
Share & tools
lore
#0 lore raw

cover test-bbdev coverity fixes

Fixes for coverity issues 383647, 383155.

Hernan Vargas (2):
test/bbdev: fix possible div by zero issue
test/bbdev: fix unchecked ret value issue

 app/test-bbdev/test_bbdev_perf.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.37.1
#1 lore raw

PATCH 1/2 test/bbdev: fix possible div by zero issue

Add extra check at function level to ensure num_ops cannot be 0.

Coverity issue: 383647

Fixes f0d288bca467 ("test/bbdev: add support for BLER for 4G")
---
 app/test-bbdev/test_bbdev_perf.c | 2 ++
 1 file changed, 2 insertions(+)
app/test-bbdev/test_bbdev_perf.c +2 -0
index e56d314e93b5..15ebcdfc1556 100644
@@ -3722,6 +3722,7 @@ bler_pmd_lcore_ldpc_dec(void *arg)
 
 	TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
 			"BURST_SIZE should be <= %u", MAX_BURST);
+	TEST_ASSERT_SUCCESS((num_ops == 0), "NUM_OPS must be greater than 0");
 
 	rte_bbdev_info_get(tp->dev_id, &info);
 
@@ -3856,6 +3857,7 @@ bler_pmd_lcore_turbo_dec(void *arg)
 
 	TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
 			"BURST_SIZE should be <= %u", MAX_BURST);
+	TEST_ASSERT_SUCCESS((num_ops == 0), "NUM_OPS must be greater than 0");
 
 	rte_bbdev_info_get(tp->dev_id, &info);
 
Signature · 1 line
2.37.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] test/bbdev: fix possible div by zero issue

Quoted 24 lines · Hernan Vargas

Add extra check at function level to ensure num_ops cannot be 0.

Coverity issue: 383647

Fixes f0d288bca467 ("test/bbdev: add support for BLER for 4G")
---
  app/test-bbdev/test_bbdev_perf.c | 2 ++
  1 file changed, 2 insertions(+)
app/test-bbdev/test_bbdev_perf.c +1 -0
index e56d314e93b5..15ebcdfc1556 100644
@@ -3722,6 +3722,7 @@ bler_pmd_lcore_ldpc_dec(void *arg)
 
  	TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
  			"BURST_SIZE should be <= %u", MAX_BURST);
+	TEST_ASSERT_SUCCESS((num_ops == 0), "NUM_OPS must be greater than 0");
 
  	rte_bbdev_info_get(tp->dev_id, &info);
 

app/test-bbdev/test_bbdev_perf.c bler_pmd_lcore_turbo_dec(void *arg) · line 3863

Quoted 7 lines
app/test-bbdev/test_bbdev_perf.c +1 -0
@@ -3856,6 +3857,7 @@ bler_pmd_lcore_turbo_dec(void *arg)
 
  	TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
  			"BURST_SIZE should be <= %u", MAX_BURST);
+	TEST_ASSERT_SUCCESS((num_ops == 0), "NUM_OPS must be greater than 0");
 
  	rte_bbdev_info_get(tp->dev_id, &info);
 

Thanks,
Maxime

#3 lore raw

PATCH 2/2 test/bbdev: fix unchecked ret value issue

In reply to Hernan Vargas

Add check for return value from get_bbdev_queue_stats.

Coverity issue: 383155

Fixes c25604355a15 ("app/bbdev: add explicit check for counters")
---
 app/test-bbdev/test_bbdev_perf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
app/test-bbdev/test_bbdev_perf.c +5 -2
index 15ebcdfc1556..276bbf0a2e6d 100644
@@ -5679,7 +5679,7 @@ static int
 offload_cost_test(struct active_device *ad,
 		struct test_op_params *op_params)
 {
-	int iter;
+	int iter, ret;
 	uint16_t burst_sz = op_params->burst_sz;
 	const uint16_t num_to_process = op_params->num_to_process;
 	const enum rte_bbdev_op_type op_type = test_vector.op_type;
@@ -5774,7 +5774,10 @@ offload_cost_test(struct active_device *ad,
 			rte_get_tsc_hz());
 
 	struct rte_bbdev_stats stats = {0};
-	get_bbdev_queue_stats(ad->dev_id, queue_id, &stats);
+	ret = get_bbdev_queue_stats(ad->dev_id, queue_id, &stats);
+	TEST_ASSERT_SUCCESS(ret,
+			"Failed to get stats for queue (%u) of device (%u)",
+			queue_id, ad->dev_id);
 	if (stats.enqueue_warn_count > 0)
 		printf("Warning reported on the queue : %10"PRIu64"\n",
 			stats.enqueue_warn_count);
Signature · 1 line
2.37.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH v1 2/2] test/bbdev: fix unchecked ret value issue

Quoted 26 lines · Hernan Vargas

Add check for return value from get_bbdev_queue_stats.

Coverity issue: 383155

Fixes c25604355a15 ("app/bbdev: add explicit check for counters")
---
  app/test-bbdev/test_bbdev_perf.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
app/test-bbdev/test_bbdev_perf.c +1 -1
index 15ebcdfc1556..276bbf0a2e6d 100644
@@ -5679,7 +5679,7 @@ static int
  offload_cost_test(struct active_device *ad,
  		struct test_op_params *op_params)
  {
-	int iter;
+	int iter, ret;
  	uint16_t burst_sz = op_params->burst_sz;
  	const uint16_t num_to_process = op_params->num_to_process;
  	const enum rte_bbdev_op_type op_type = test_vector.op_type;
@@ -5774,7 +5774,10 @@ offload_cost_test(struct active_device *ad,
  			rte_get_tsc_hz());

app/test-bbdev/test_bbdev_perf.c offload_cost_test(struct active_device *ad, · line 5783

Quoted 10 lines
app/test-bbdev/test_bbdev_perf.c +4 -1
 
  	struct rte_bbdev_stats stats = {0};
-	get_bbdev_queue_stats(ad->dev_id, queue_id, &stats);
+	ret = get_bbdev_queue_stats(ad->dev_id, queue_id, &stats);
+	TEST_ASSERT_SUCCESS(ret,
+			"Failed to get stats for queue (%u) of device (%u)",
+			queue_id, ad->dev_id);
  	if (stats.enqueue_warn_count > 0)
  		printf("Warning reported on the queue : %10"PRIu64"\n",
  			stats.enqueue_warn_count);

Thanks,
Maxime

#5 lore raw
In reply to Hernan Vargas
Quoted 9 lines · Hernan Vargas

Fixes for coverity issues 383647, 383155.

Hernan Vargas (2):
test/bbdev: fix possible div by zero issue
test/bbdev: fix unchecked ret value issue

  app/test-bbdev/test_bbdev_perf.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)

Applied to dpdk-next-baseband/for-main.

Thanks,
Maxime