[PATCH v3 04/14] test: cryptodev use rte_pktmbuf_mtod_offset
Stephen Hemminger
stephen at networkplumber.org
Thu Jul 6 19:59:28 CEST 2023
Based off patch generated by cocci/mtod-offset.cocci.
With some cleanup to shorten lines by using conditional
with omitted operand.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 30 deletions(-)
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index fb2af40b99ee..5072b3b6ece5 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -3153,8 +3153,9 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
ut_params->op);
ut_params->obuf = ut_params->op->sym->m_src;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + plaintext_pad_len;
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ plaintext_pad_len);
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3247,8 +3248,9 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
ut_params->op);
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src;
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + plaintext_pad_len;
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ plaintext_pad_len);
/* Validate obuf */
if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -3337,8 +3339,9 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
ut_params->obuf = ut_params->op->sym->m_src;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + plaintext_pad_len;
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ plaintext_pad_len);
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3425,8 +3428,9 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
ut_params->op);
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src;
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + plaintext_pad_len;
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ plaintext_pad_len);
/* Validate obuf */
if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -4879,8 +4883,9 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata)
tdata->validDataLenInBits.len,
"ZUC Ciphertext data not as expected");
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + plaintext_pad_len;
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ plaintext_pad_len);
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -4994,8 +4999,9 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
tdata->validDataLenInBits.len,
"SNOW 3G Ciphertext data not as expected");
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + plaintext_pad_len;
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ plaintext_pad_len);
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -5163,9 +5169,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
debug_hexdump(stdout, "ciphertext expected:",
tdata->ciphertext.data, tdata->ciphertext.len >> 3);
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + (tdata->digest.offset_bytes == 0 ?
- plaintext_pad_len : tdata->digest.offset_bytes);
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ tdata->digest.offset_bytes ? : plaintext_pad_len);
debug_hexdump(stdout, "digest:", ut_params->digest,
tdata->digest.len);
@@ -5577,10 +5583,9 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
debug_hexdump(stdout, "ciphertext expected:",
tdata->ciphertext.data, tdata->ciphertext.len >> 3);
- ut_params->digest = rte_pktmbuf_mtod(
- ut_params->obuf, uint8_t *) +
- (tdata->digest.offset_bytes == 0 ?
- plaintext_pad_len : tdata->digest.offset_bytes);
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ tdata->digest.offset_bytes ? : plaintext_pad_len);
debug_hexdump(stdout, "digest:", ut_params->digest,
tdata->digest.len);
@@ -5924,8 +5929,9 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
tdata->validCipherOffsetInBits.len >> 3);
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + plaintext_pad_len;
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ plaintext_pad_len);
const uint8_t *reference_ciphertext = tdata->ciphertext.data +
(tdata->validCipherOffsetInBits.len >> 3);
@@ -6344,8 +6350,9 @@ test_zuc_authentication(const struct wireless_test_data *tdata,
ut_params->op);
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src;
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + plaintext_pad_len;
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ plaintext_pad_len);
if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
/* Validate obuf */
@@ -6531,10 +6538,9 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
debug_hexdump(stdout, "ciphertext expected:",
tdata->ciphertext.data, tdata->ciphertext.len >> 3);
- ut_params->digest = rte_pktmbuf_mtod(
- ut_params->obuf, uint8_t *) +
- (tdata->digest.offset_bytes == 0 ?
- plaintext_pad_len : tdata->digest.offset_bytes);
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ tdata->digest.offset_bytes ? : plaintext_pad_len);
debug_hexdump(stdout, "digest:", ut_params->digest,
tdata->digest.len);
@@ -7959,9 +7965,9 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
tdata->ciphertext.data,
tdata->ciphertext.len_bits >> 3);
- ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
- + (tdata->digest_enc.offset == 0 ?
- plaintext_pad_len : tdata->digest_enc.offset);
+ ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+ uint8_t *,
+ tdata->digest_enc.offset ? : plaintext_pad_len);
debug_hexdump(stdout, "digest:", ut_params->digest,
tdata->digest_enc.len);
--
2.39.2
More information about the dev
mailing list