[dpdk-dev] app/test-crypto-perf: fix incorrect size of expression

Message ID 1486569881-16220-2-git-send-email-jacekx.piasecki@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: Pablo de Lara Guarch
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation fail Compilation issues

Commit Message

Jacek Piasecki Feb. 8, 2017, 4:04 p.m. UTC
  Fix problem of passing a pointer to sizeof() function. Now the size
of enabled_cdevs structure is passed by RTE_CRYPTO_MAX_DEVS.

Coverity issue: 141068
Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application")

Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
---
 app/test-crypto-perf/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
  

Comments

De Lara Guarch, Pablo Feb. 9, 2017, 11:53 p.m. UTC | #1
Hi Jacek,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jacek Piasecki
> Sent: Wednesday, February 08, 2017 4:05 PM
> To: Doherty, Declan
> Cc: dev@dpdk.org; Piasecki, JacekX
> Subject: [dpdk-dev] [PATCH] app/test-crypto-perf: fix incorrect size of
> expression
> 
> Fix problem of passing a pointer to sizeof() function. Now the size
> of enabled_cdevs structure is passed by RTE_CRYPTO_MAX_DEVS.
> 
> Coverity issue: 141068
> Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test
> application")
> 
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> ---
>  app/test-crypto-perf/main.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
> index 634ea5f..dff906e 100644
> --- a/app/test-crypto-perf/main.c
> +++ b/app/test-crypto-perf/main.c
> @@ -39,13 +39,14 @@
>  };
> 
>  static int
> -cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t
> *enabled_cdevs)
> +cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t
> *enabled_cdevs,
> +		uint8_t enabled_cdevs_dim)

I think this extra parameter in the function is unnecessary,
as it is always RTE_CRYPTO_MAX_DEVS.
Better to pass RTE_CRYPTO_MAX_DEVS to rte_cryptodev_devices_get() directly.

>  {
>  	uint8_t cdev_id, enabled_cdev_count = 0, nb_lcores;
>  	int ret;
> 
>  	enabled_cdev_count = rte_cryptodev_devices_get(opts-
> >device_type,
> -			enabled_cdevs, RTE_DIM(enabled_cdevs));
> +			enabled_cdevs, enabled_cdevs_dim);

Thanks,
Pablo
  

Patch

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 634ea5f..dff906e 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -39,13 +39,14 @@ 
 };
 
 static int
-cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
+cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
+		uint8_t enabled_cdevs_dim)
 {
 	uint8_t cdev_id, enabled_cdev_count = 0, nb_lcores;
 	int ret;
 
 	enabled_cdev_count = rte_cryptodev_devices_get(opts->device_type,
-			enabled_cdevs, RTE_DIM(enabled_cdevs));
+			enabled_cdevs, enabled_cdevs_dim);
 	if (enabled_cdev_count == 0) {
 		printf("No crypto devices type %s available\n",
 				opts->device_type);
@@ -296,7 +297,8 @@ 
 	if (!opts.silent)
 		cperf_options_dump(&opts);
 
-	nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs);
+	nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs,
+			RTE_CRYPTO_MAX_DEVS);
 	if (nb_cryptodevs < 1) {
 		RTE_LOG(ERR, USER1, "Failed to initialise requested crypto "
 				"device type\n");