Cppcheck: Fix warnings with updated tf-m-ci-scripts
Several cppcheck warnings are fixed in the following modules:
- Interface
- Partitions: Crypto/ITS/PS/Platform
- SPRTL headers
- Various headers
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
Change-Id: I08c9fa10895c0b723a2d8b3cdcd386b1752facaa
diff --git a/interface/src/tfm_crypto_func_api.c b/interface/src/tfm_crypto_func_api.c
index 6e6c419..2cf3fde 100644
--- a/interface/src/tfm_crypto_func_api.c
+++ b/interface/src/tfm_crypto_func_api.c
@@ -772,7 +772,7 @@
.sfn_id = TFM_CRYPTO_AEAD_ENCRYPT_SID,
.key_id = key,
.alg = alg,
- .aead_in = {.nonce = {0}, .nonce_length = nonce_length}
+ .aead_in = {.nonce = {0}, .nonce_length = 0}
};
/* Sanitize the optional input */
@@ -780,9 +780,8 @@
return PSA_ERROR_INVALID_ARGUMENT;
}
- size_t idx = 0;
psa_invec in_vec[] = {
- {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
+ {.base = NULL, .len = 0},
{.base = plaintext, .len = plaintext_length},
{.base = additional_data, .len = additional_data_length},
};
@@ -795,11 +794,15 @@
}
if (nonce != NULL) {
- for (idx = 0; idx < nonce_length; idx++) {
+ for (size_t idx = 0; idx < nonce_length; idx++) {
iov.aead_in.nonce[idx] = nonce[idx];
}
+ iov.aead_in.nonce_length = nonce_length;
}
+ in_vec[0].base = &iov;
+ in_vec[0].len = sizeof(struct tfm_crypto_pack_iovec);
+
status = API_DISPATCH(tfm_crypto_aead_encrypt,
TFM_CRYPTO_AEAD_ENCRYPT);
@@ -825,7 +828,7 @@
.sfn_id = TFM_CRYPTO_AEAD_DECRYPT_SID,
.key_id = key,
.alg = alg,
- .aead_in = {.nonce = {0}, .nonce_length = nonce_length}
+ .aead_in = {.nonce = {0}, .nonce_length = 0}
};
/* Sanitize the optional input */
@@ -833,9 +836,8 @@
return PSA_ERROR_INVALID_ARGUMENT;
}
- size_t idx = 0;
psa_invec in_vec[] = {
- {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
+ {.base = NULL, .len = 0},
{.base = ciphertext, .len = ciphertext_length},
{.base = additional_data, .len = additional_data_length},
};
@@ -848,11 +850,15 @@
}
if (nonce != NULL) {
- for (idx = 0; idx < nonce_length; idx++) {
+ for (size_t idx = 0; idx < nonce_length; idx++) {
iov.aead_in.nonce[idx] = nonce[idx];
}
+ iov.aead_in.nonce_length = nonce_length;
}
+ in_vec[0].base = &iov;
+ in_vec[0].len = sizeof(struct tfm_crypto_pack_iovec);
+
status = API_DISPATCH(tfm_crypto_aead_decrypt,
TFM_CRYPTO_AEAD_DECRYPT);