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_ipc_api.c b/interface/src/tfm_crypto_ipc_api.c
index 9dfa473..c11fba0 100644
--- a/interface/src/tfm_crypto_ipc_api.c
+++ b/interface/src/tfm_crypto_ipc_api.c
@@ -782,7 +782,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 */
@@ -790,9 +790,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},
};
@@ -805,11 +804,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);
+
size_t in_len = IOVEC_LEN(in_vec);
if (additional_data == NULL) {
in_len--;
@@ -839,7 +842,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 */
@@ -847,9 +850,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},
};
@@ -862,11 +864,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);
+
size_t in_len = IOVEC_LEN(in_vec);
if (additional_data == NULL) {
in_len--;