[dpdk-dev] app/test-crypto-perf: fix big paremeter passed by value

Message ID 1486569881-16220-1-git-send-email-jacekx.piasecki@intel.com (mailing list archive)
State Accepted, 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
  Structure opts and structure test_vec are now passed by  pointer to
the cperf_check_test_vector.

Coverity issue: 141072

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

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

Comments

De Lara Guarch, Pablo Feb. 9, 2017, 11:41 p.m. UTC | #1
> -----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 big paremeter passed
> by value
> 
> Structure opts and structure test_vec are now passed by  pointer to
> the cperf_check_test_vector.
> 
> Coverity issue: 141072
> 
> Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test
> application")
> 
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
  
De Lara Guarch, Pablo Feb. 9, 2017, 11:48 p.m. UTC | #2
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of De Lara Guarch,
> Pablo
> Sent: Thursday, February 09, 2017 11:42 PM
> To: Piasecki, JacekX; Doherty, Declan
> Cc: dev@dpdk.org; Piasecki, JacekX
> Subject: Re: [dpdk-dev] [PATCH] app/test-crypto-perf: fix big paremeter
> passed by value
> 
> 
> 
> > -----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 big paremeter
> passed
> > by value
> >
> > Structure opts and structure test_vec are now passed by  pointer to
> > the cperf_check_test_vector.
> >
> > Coverity issue: 141072
> >
> > Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test
> > application")
> >
> > Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> 
> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied to dpdk-next-crypto.
Thanks,

Pablo
  

Patch

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 6c128d8..634ea5f 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -162,94 +162,94 @@ 
 }
 
 static int
-cperf_check_test_vector(struct cperf_options opts,
-		struct cperf_test_vector test_vec)
+cperf_check_test_vector(struct cperf_options *opts,
+		struct cperf_test_vector *test_vec)
 {
-	if (opts.op_type == CPERF_CIPHER_ONLY) {
-		if (opts.cipher_algo == RTE_CRYPTO_CIPHER_NULL) {
-			if (test_vec.plaintext.data == NULL)
+	if (opts->op_type == CPERF_CIPHER_ONLY) {
+		if (opts->cipher_algo == RTE_CRYPTO_CIPHER_NULL) {
+			if (test_vec->plaintext.data == NULL)
 				return -1;
-		} else if (opts.cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
-			if (test_vec.plaintext.data == NULL)
+		} else if (opts->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
+			if (test_vec->plaintext.data == NULL)
 				return -1;
-			if (test_vec.plaintext.length != opts.buffer_sz)
+			if (test_vec->plaintext.length != opts->buffer_sz)
 				return -1;
-			if (test_vec.ciphertext.data == NULL)
+			if (test_vec->ciphertext.data == NULL)
 				return -1;
-			if (test_vec.ciphertext.length != opts.buffer_sz)
+			if (test_vec->ciphertext.length != opts->buffer_sz)
 				return -1;
-			if (test_vec.iv.data == NULL)
+			if (test_vec->iv.data == NULL)
 				return -1;
-			if (test_vec.iv.length != opts.cipher_iv_sz)
+			if (test_vec->iv.length != opts->cipher_iv_sz)
 				return -1;
-			if (test_vec.cipher_key.data == NULL)
+			if (test_vec->cipher_key.data == NULL)
 				return -1;
-			if (test_vec.cipher_key.length != opts.cipher_key_sz)
+			if (test_vec->cipher_key.length != opts->cipher_key_sz)
 				return -1;
 		}
-	} else if (opts.op_type == CPERF_AUTH_ONLY) {
-		if (opts.auth_algo != RTE_CRYPTO_AUTH_NULL) {
-			if (test_vec.plaintext.data == NULL)
+	} else if (opts->op_type == CPERF_AUTH_ONLY) {
+		if (opts->auth_algo != RTE_CRYPTO_AUTH_NULL) {
+			if (test_vec->plaintext.data == NULL)
 				return -1;
-			if (test_vec.plaintext.length != opts.buffer_sz)
+			if (test_vec->plaintext.length != opts->buffer_sz)
 				return -1;
-			if (test_vec.auth_key.data == NULL)
+			if (test_vec->auth_key.data == NULL)
 				return -1;
-			if (test_vec.auth_key.length != opts.auth_key_sz)
+			if (test_vec->auth_key.length != opts->auth_key_sz)
 				return -1;
-			if (test_vec.digest.data == NULL)
+			if (test_vec->digest.data == NULL)
 				return -1;
-			if (test_vec.digest.length != opts.auth_digest_sz)
+			if (test_vec->digest.length != opts->auth_digest_sz)
 				return -1;
 		}
 
-	} else if (opts.op_type == CPERF_CIPHER_THEN_AUTH ||
-			opts.op_type == CPERF_AUTH_THEN_CIPHER) {
-		if (opts.cipher_algo == RTE_CRYPTO_CIPHER_NULL) {
-			if (test_vec.plaintext.data == NULL)
+	} else if (opts->op_type == CPERF_CIPHER_THEN_AUTH ||
+			opts->op_type == CPERF_AUTH_THEN_CIPHER) {
+		if (opts->cipher_algo == RTE_CRYPTO_CIPHER_NULL) {
+			if (test_vec->plaintext.data == NULL)
 				return -1;
-			if (test_vec.plaintext.length != opts.buffer_sz)
+			if (test_vec->plaintext.length != opts->buffer_sz)
 				return -1;
-		} else if (opts.cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
-			if (test_vec.plaintext.data == NULL)
+		} else if (opts->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
+			if (test_vec->plaintext.data == NULL)
 				return -1;
-			if (test_vec.plaintext.length != opts.buffer_sz)
+			if (test_vec->plaintext.length != opts->buffer_sz)
 				return -1;
-			if (test_vec.ciphertext.data == NULL)
+			if (test_vec->ciphertext.data == NULL)
 				return -1;
-			if (test_vec.ciphertext.length != opts.buffer_sz)
+			if (test_vec->ciphertext.length != opts->buffer_sz)
 				return -1;
-			if (test_vec.iv.data == NULL)
+			if (test_vec->iv.data == NULL)
 				return -1;
-			if (test_vec.iv.length != opts.cipher_iv_sz)
+			if (test_vec->iv.length != opts->cipher_iv_sz)
 				return -1;
-			if (test_vec.cipher_key.data == NULL)
+			if (test_vec->cipher_key.data == NULL)
 				return -1;
-			if (test_vec.cipher_key.length != opts.cipher_key_sz)
+			if (test_vec->cipher_key.length != opts->cipher_key_sz)
 				return -1;
 		}
-		if (opts.auth_algo != RTE_CRYPTO_AUTH_NULL) {
-			if (test_vec.auth_key.data == NULL)
+		if (opts->auth_algo != RTE_CRYPTO_AUTH_NULL) {
+			if (test_vec->auth_key.data == NULL)
 				return -1;
-			if (test_vec.auth_key.length != opts.auth_key_sz)
+			if (test_vec->auth_key.length != opts->auth_key_sz)
 				return -1;
-			if (test_vec.digest.data == NULL)
+			if (test_vec->digest.data == NULL)
 				return -1;
-			if (test_vec.digest.length != opts.auth_digest_sz)
+			if (test_vec->digest.length != opts->auth_digest_sz)
 				return -1;
 		}
-	} else if (opts.op_type == CPERF_AEAD) {
-		if (test_vec.plaintext.data == NULL)
+	} else if (opts->op_type == CPERF_AEAD) {
+		if (test_vec->plaintext.data == NULL)
 			return -1;
-		if (test_vec.plaintext.length != opts.buffer_sz)
+		if (test_vec->plaintext.length != opts->buffer_sz)
 			return -1;
-		if (test_vec.aad.data == NULL)
+		if (test_vec->aad.data == NULL)
 			return -1;
-		if (test_vec.aad.length != opts.auth_aad_sz)
+		if (test_vec->aad.length != opts->auth_aad_sz)
 			return -1;
-		if (test_vec.digest.data == NULL)
+		if (test_vec->digest.data == NULL)
 			return -1;
-		if (test_vec.digest.length != opts.auth_digest_sz)
+		if (test_vec->digest.length != opts->auth_digest_sz)
 			return -1;
 	}
 	return 0;
@@ -320,7 +320,7 @@ 
 			goto err;
 		}
 
-		if (cperf_check_test_vector(opts, *t_vec)) {
+		if (cperf_check_test_vector(&opts, t_vec)) {
 			RTE_LOG(ERR, USER1, "Incomplete necessary test vectors"
 					"\n");
 			goto err;