DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] app/test-crypto-perf: fix invalid memcmp results
@ 2024-01-03  3:56 Suanming Mou
  2024-01-03  3:56 ` [PATCH 2/2] app/test-crypto-perf: fix encrypt operation verify Suanming Mou
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Suanming Mou @ 2024-01-03  3:56 UTC (permalink / raw)
  To: Ciara Power; +Cc: dev

The function memcmp() returns an integer less than, equal to,
or greater than zero. In current code, if the first memcmp()
returns less than zero and the second memcmp() returns greater
than zero, the sum of results may still be 0 and indicates
verify succussed.

This commit converts the return value to be zero or greater
than zero. That will make sure the sum of results be correct.

Fixes: df52cb3b6e13 ("app/crypto-perf: move verify as single test type")

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
 app/test-crypto-perf/cperf_test_verify.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index a6c0ffe813..8aa714b969 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -186,18 +186,18 @@ cperf_verify_op(struct rte_crypto_op *op,
 
 	if (cipher == 1) {
 		if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
-			res += memcmp(data + cipher_offset,
+			res += !!memcmp(data + cipher_offset,
 					vector->ciphertext.data,
 					options->test_buffer_size);
 		else
-			res += memcmp(data + cipher_offset,
+			res += !!memcmp(data + cipher_offset,
 					vector->plaintext.data,
 					options->test_buffer_size);
 	}
 
 	if (auth == 1) {
 		if (options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE)
-			res += memcmp(data + auth_offset,
+			res += !!memcmp(data + auth_offset,
 					vector->digest.data,
 					options->digest_sz);
 	}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-02-01  8:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-03  3:56 [PATCH 1/2] app/test-crypto-perf: fix invalid memcmp results Suanming Mou
2024-01-03  3:56 ` [PATCH 2/2] app/test-crypto-perf: fix encrypt operation verify Suanming Mou
2024-01-04  5:13   ` [EXT] " Anoob Joseph
2024-01-04  8:56     ` Suanming Mou
2024-01-03 11:33 ` [EXT] [PATCH 1/2] app/test-crypto-perf: fix invalid memcmp results Anoob Joseph
2024-01-05  0:03 ` [PATCH v2 " Suanming Mou
2024-01-05  0:03   ` [PATCH v2 2/2] app/test-crypto-perf: fix encrypt operation verify Suanming Mou
2024-01-05  4:44     ` [EXT] " Anoob Joseph
2024-01-12 16:21   ` [PATCH v2 1/2] app/test-crypto-perf: fix invalid memcmp results Power, Ciara
2024-02-01  8:47   ` [EXT] " Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).