fix(rmm-eac5): fix MISRA C defects
Fixes MISRA C 2012 Rule 2.3, 12.1 and 18.4 violations.
Change-Id: I7b96776da05c636fde89d915b0aae5a7134baab4
Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
diff --git a/runtime/rmi/rec.c b/runtime/rmi/rec.c
index 7537fb7..5cf2220 100644
--- a/runtime/rmi/rec.c
+++ b/runtime/rmi/rec.c
@@ -196,11 +196,11 @@
aux_data = &r->aux_data;
aux_data->attest_heap_buf = (uint8_t *)rec_aux;
aux_data->pmu = (struct pmu_state *)
- (aux_data->attest_heap_buf + REC_HEAP_SIZE);
+ ((uintptr_t)aux_data->attest_heap_buf + REC_HEAP_SIZE);
aux_data->simd_ctx = (struct simd_context *)
- ((uint8_t *)aux_data->pmu + REC_PMU_SIZE);
+ ((uintptr_t)aux_data->pmu + REC_PMU_SIZE);
aux_data->attest_data = (struct rec_attest_data *)
- ((uint8_t *)aux_data->simd_ctx + REC_SIMD_SIZE);
+ ((uintptr_t)aux_data->simd_ctx + REC_SIMD_SIZE);
aux_data->cca_token_buf = (uintptr_t)aux_data->attest_data +
REC_ATTEST_SIZE;
diff --git a/runtime/rmi/rtt.c b/runtime/rmi/rtt.c
index 3a51387..129b583 100644
--- a/runtime/rmi/rtt.c
+++ b/runtime/rmi/rtt.c
@@ -125,7 +125,7 @@
rtt_walk_lock_unlock(g_table_root, sl, ipa_bits,
map_addr, level - 1L, &wi);
- if (wi.last_level != level - 1L) {
+ if (wi.last_level != (level - 1L)) {
ret = pack_return_code(RMI_ERROR_RTT,
(unsigned int)wi.last_level);
goto out_unlock_llt;
@@ -319,7 +319,7 @@
rtt_walk_lock_unlock(g_table_root, sl, ipa_bits,
map_addr, level - 1L, &wi);
- if (wi.last_level != level - 1L) {
+ if (wi.last_level != (level - 1L)) {
ret = pack_return_code(RMI_ERROR_RTT,
(unsigned int)wi.last_level);
goto out_unlock_parent_table;
@@ -516,7 +516,7 @@
parent_s2tte = s2tte_read(&parent_s2tt[wi.index]);
- if ((wi.last_level != level - 1L) ||
+ if ((wi.last_level != (level - 1L)) ||
!s2tte_is_table(parent_s2tte, level - 1L)) {
ret = pack_return_code(RMI_ERROR_RTT,
(unsigned int)wi.last_level);
diff --git a/runtime/rsi/host_call.c b/runtime/rsi/host_call.c
index a35eac1..8ebf8d9 100644
--- a/runtime/rsi/host_call.c
+++ b/runtime/rsi/host_call.c
@@ -35,7 +35,7 @@
unsigned long ipa = rec->regs[1];
unsigned long page_ipa;
struct granule *gr;
- unsigned char *data;
+ uintptr_t data;
struct rsi_host_call *host_call;
unsigned int i;
@@ -59,16 +59,17 @@
}
return;
case WALK_INVALID_PARAMS:
+ default:
assert(false);
break;
}
/* Map Realm data granule to RMM address space */
gr = find_granule(walk_result.pa);
- data = (unsigned char *)granule_map(gr, SLOT_RSI_CALL);
- assert(data != NULL);
+ data = (uintptr_t)granule_map(gr, SLOT_RSI_CALL);
+ assert(data != 0UL);
- host_call = (struct rsi_host_call *)(data + (ipa - page_ipa));
+ host_call = (struct rsi_host_call *)(data + ipa - page_ipa);
if (rec_exit != NULL) {
/* Copy host call arguments to REC exit data structure */
@@ -97,7 +98,7 @@
}
/* Unmap Realm data granule */
- buffer_unmap(data);
+ buffer_unmap((void *)data);
/* Unlock last level RTT */
granule_unlock(walk_result.llt);