Build: Major warnings cleanup
This is a major type-mismatch cleanup and warnings elimination.
The IAR toolchain runs with more warnings enabled than ARMCLANG or
GNUARM, which has resulted in this effort.
This should make it easier to enable "pedantic" mode also for GNUARM.
There are still a few warnings about jumping past variable
initialization and falling off the end of non-void functions, but there
are comments in some of these parts that implies that this is done to
catch programming errors, like having case labels for all possible enum
values.
Reordered initializer in tfm_attestation_req_mngr.c to eliminate CI
warning.
Disabled "Pe940" warnings in CommonConfig.cmake to suppress warnings
about inline assembly functions declared to return value that doesn't
declare a return value in the __ASM() statement.
Disabled "Pe546" warnings to supress warnings about jumping over
unused initializers.
Fixed what appears to be a copy/paste bug in tfm_ss_core_test.c.
Removed unused variable "ret" in Driver_PPC.c for AN519 and AN521, to
make it similar to AN524.
Signed-off-by: TTornblom <thomas.tornblom@iar.com>
Change-Id: I2b729c73e4b004cff6b0530cc1350fcf900e4272
diff --git a/secure_fw/services/crypto/crypto_init.c b/secure_fw/services/crypto/crypto_init.c
index b3acd55..743ce1d 100644
--- a/secure_fw/services/crypto/crypto_init.c
+++ b/secure_fw/services/crypto/crypto_init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -113,7 +113,7 @@
const uint32_t sfn_id)
{
psa_status_t status = PSA_SUCCESS;
- size_t in_len = PSA_MAX_IOVEC, out_len = PSA_MAX_IOVEC, i, read_size;
+ size_t in_len = PSA_MAX_IOVEC, out_len = PSA_MAX_IOVEC, i;
psa_invec in_vec[PSA_MAX_IOVEC] = { {0} };
psa_outvec out_vec[PSA_MAX_IOVEC] = { {0} };
void *alloc_buf_ptr = NULL;
@@ -140,7 +140,7 @@
return status;
}
/* Read from the IPC framework inputs into the scratch */
- read_size = psa_read(msg->handle, i, alloc_buf_ptr, msg->in_size[i]);
+ (void) psa_read(msg->handle, i, alloc_buf_ptr, msg->in_size[i]);
/* Populate the fields of the input to the secure function */
in_vec[i].base = alloc_buf_ptr;
in_vec[i].len = msg->in_size[i];
@@ -258,7 +258,7 @@
}
}
- /* This is unreachable */
+ /* NOTREACHED */
return;
}
#endif /* TFM_PSA_API */
diff --git a/secure_fw/services/crypto/crypto_key.c b/secure_fw/services/crypto/crypto_key.c
index e88040d..ef3b309 100644
--- a/secure_fw/services/crypto/crypto_key.c
+++ b/secure_fw/services/crypto/crypto_key.c
@@ -577,7 +577,6 @@
return status;
#endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
- return PSA_ERROR_NOT_SUPPORTED;
}
psa_status_t tfm_crypto_generate_key(psa_invec in_vec[],
diff --git a/secure_fw/services/initial_attestation/tfm_attestation_req_mngr.c b/secure_fw/services/initial_attestation/tfm_attestation_req_mngr.c
index 07d9a80..8366bfb 100644
--- a/secure_fw/services/initial_attestation/tfm_attestation_req_mngr.c
+++ b/secure_fw/services/initial_attestation/tfm_attestation_req_mngr.c
@@ -171,13 +171,10 @@
psa_status_t attest_partition_init(void)
{
- psa_status_t err = PSA_SUCCESS;
+ psa_status_t err = attest_init();
#ifdef TFM_PSA_API
psa_signal_t signals;
-#endif
- err = attest_init();
-#ifdef TFM_PSA_API
if (err != PSA_SUCCESS) {
tfm_abort();
}
@@ -197,6 +194,7 @@
tfm_abort();
}
}
-#endif
+#else
return err;
+#endif
}
diff --git a/secure_fw/services/internal_trusted_storage/tfm_its_req_mngr.c b/secure_fw/services/internal_trusted_storage/tfm_its_req_mngr.c
index 518f877..eb634b8 100644
--- a/secure_fw/services/internal_trusted_storage/tfm_its_req_mngr.c
+++ b/secure_fw/services/internal_trusted_storage/tfm_its_req_mngr.c
@@ -349,8 +349,8 @@
return PSA_ERROR_GENERIC_ERROR;
}
its_is_init = true;
-#endif
return PSA_SUCCESS;
+#endif
}
size_t its_req_mngr_read(uint8_t *buf, size_t num_bytes)
diff --git a/secure_fw/services/platform/platform_sp.c b/secure_fw/services/platform/platform_sp.c
index f5d0973..b17e62e 100644
--- a/secure_fw/services/platform/platform_sp.c
+++ b/secure_fw/services/platform/platform_sp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -102,16 +102,16 @@
num = psa_read(msg->handle, 0, &request, sizeof(request));
if (num != sizeof(request)) {
- return PSA_ERROR_PROGRAMMER_ERROR;
+ return (enum tfm_platform_err_t) PSA_ERROR_PROGRAMMER_ERROR;
}
if (in_len > 1) {
if (msg->in_size[1] > INPUT_BUFFER_SIZE) {
- return PSA_ERROR_PROGRAMMER_ERROR;
+ return (enum tfm_platform_err_t) PSA_ERROR_PROGRAMMER_ERROR;
}
num = psa_read(msg->handle, 1, &input_buffer, msg->in_size[1]);
if (num != msg->in_size[1]) {
- return PSA_ERROR_PROGRAMMER_ERROR;
+ return (enum tfm_platform_err_t) PSA_ERROR_PROGRAMMER_ERROR;
}
invec.base = input_buffer;
invec.len = msg->in_size[1];
@@ -120,7 +120,7 @@
if (out_len > 0) {
if (msg->out_size[0] > OUTPUT_BUFFER_SIZE) {
- return PSA_ERROR_PROGRAMMER_ERROR;
+ return (enum tfm_platform_err_t) PSA_ERROR_PROGRAMMER_ERROR;
}
outvec.base = output_buffer;
outvec.len = msg->out_size[0];
@@ -188,7 +188,7 @@
}
}
-#endif /* TFM_PSA_API */
-
+#else
return TFM_PLATFORM_ERR_SUCCESS;
+#endif /* TFM_PSA_API */
}
diff --git a/secure_fw/services/secure_storage/tfm_sst_req_mngr.c b/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
index ec9635d..94a0e78 100644
--- a/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
+++ b/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
@@ -418,12 +418,13 @@
tfm_abort();
}
}
-#endif
+#else
/* In library mode, initialisation is delayed until the first secure
* function call, as calls to the Crypto service are required for
* initialisation.
*/
return PSA_SUCCESS;
+#endif
}
psa_status_t sst_req_mngr_read_asset_data(uint8_t *out_data, uint32_t size)