Attest: Improve code quality
This patch fixes the following things:
* avoid implicit casting by using matching types or casting
* be explicit about return values of functions not checked
* fix indentation of code
* remove whitespaces
Change-Id: I8264b177d483d9f9f5f9e43e83f2268d0182d396
Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
diff --git a/secure_fw/services/initial_attestation/tfm_attestation.c b/secure_fw/services/initial_attestation/tfm_attestation.c
index 94b6caa..f4b1acd 100644
--- a/secure_fw/services/initial_attestation/tfm_attestation.c
+++ b/secure_fw/services/initial_attestation/tfm_attestation.c
@@ -22,15 +22,15 @@
{
enum psa_attest_err_t attest_res = PSA_ATTEST_ERR_SUCCESS;
#ifndef TFM_PSA_API
- enum tfm_status_e tfm_res;
+ int32_t tfm_res;
- tfm_res = tfm_core_memory_permission_check(addr, size, access);
+ tfm_res = tfm_core_memory_permission_check(addr, size, (int32_t)access);
if (tfm_res) {
- attest_res = PSA_ATTEST_ERR_INVALID_INPUT;
- }
+ attest_res = PSA_ATTEST_ERR_INVALID_INPUT;
+ }
#endif
- return attest_res;
+ return attest_res;
}
enum psa_attest_err_t
@@ -38,12 +38,12 @@
{
enum psa_attest_err_t attest_res = PSA_ATTEST_ERR_SUCCESS;
#ifndef TFM_PSA_API
- enum tfm_status_e tfm_res;
+ int32_t tfm_res;
- tfm_res = tfm_core_get_caller_client_id(caller_id);
+ tfm_res = tfm_core_get_caller_client_id(caller_id);
if (tfm_res) {
- attest_res = PSA_ATTEST_ERR_CLAIM_UNAVAILABLE;
- }
+ attest_res = PSA_ATTEST_ERR_CLAIM_UNAVAILABLE;
+ }
#else
*caller_id = g_attest_caller_id;
#endif
@@ -66,10 +66,10 @@
boot_data->header.tlv_magic = SHARED_DATA_TLV_INFO_MAGIC;
boot_data->header.tlv_tot_len = SHARED_DATA_HEADER_SIZE;
#else
- enum tfm_status_e tfm_res;
+ int32_t tfm_res;
tfm_res = tfm_core_get_boot_data(major_type, boot_data, len);
- if (tfm_res != TFM_SUCCESS) {
+ if (tfm_res != (int32_t)TFM_SUCCESS) {
attest_res = PSA_ATTEST_ERR_INIT_FAILED;
}
#endif /* BL2 */