RAS: MISRA fixes
These changes address most of the required MISRA rules. In the process,
some from generic code is also fixed.
No functional changes.
Change-Id: I76cacf6e1d73b09510561b5090c2bb66d81bec88
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
diff --git a/lib/extensions/ras/ras_common.c b/lib/extensions/ras/ras_common.c
index 5a2b43c..2e65eeb 100644
--- a/lib/extensions/ras/ras_common.c
+++ b/lib/extensions/ras/ras_common.c
@@ -11,6 +11,7 @@
#include <platform.h>
#include <ras.h>
#include <ras_arch.h>
+#include <stdbool.h>
#ifndef PLAT_RAS_PRI
# error Platform must define RAS priority value
@@ -20,15 +21,15 @@
int ras_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie,
void *handle, uint64_t flags)
{
- unsigned int i, n_handled = 0, ret;
- int probe_data;
+ unsigned int i, n_handled = 0;
+ int probe_data, ret;
struct err_record_info *info;
const struct err_handler_data err_data = {
.version = ERR_HANDLER_VERSION,
.ea_reason = ea_reason,
.interrupt = 0,
- .syndrome = syndrome,
+ .syndrome = (uint32_t) syndrome,
.flags = flags,
.cookie = cookie,
.handle = handle
@@ -39,7 +40,7 @@
assert(info->handler != NULL);
/* Continue probing until the record group signals no error */
- while (1) {
+ while (true) {
if (info->probe(info, &probe_data) == 0)
break;
@@ -52,20 +53,20 @@
}
}
- return (n_handled != 0);
+ return (n_handled != 0U) ? 1 : 0;
}
#if ENABLE_ASSERTIONS
static void assert_interrupts_sorted(void)
{
unsigned int i, last;
- struct ras_interrupt *start = ras_interrupt_mapping.intrs;
+ struct ras_interrupt *start = ras_interrupt_mappings.intrs;
- if (ras_interrupt_mapping.num_intrs == 0)
+ if (ras_interrupt_mappings.num_intrs == 0UL)
return;
last = start[0].intr_number;
- for (i = 1; i < ras_interrupt_mapping.num_intrs; i++) {
+ for (i = 1; i < ras_interrupt_mappings.num_intrs; i++) {
assert(start[i].intr_number > last);
last = start[i].intr_number;
}
@@ -79,7 +80,7 @@
static int ras_interrupt_handler(uint32_t intr_raw, uint32_t flags,
void *handle, void *cookie)
{
- struct ras_interrupt *ras_inrs = ras_interrupt_mapping.intrs;
+ struct ras_interrupt *ras_inrs = ras_interrupt_mappings.intrs;
struct ras_interrupt *selected = NULL;
int start, end, mid, probe_data, ret __unused;
@@ -91,10 +92,10 @@
.handle = handle
};
- assert(ras_interrupt_mapping.num_intrs > 0);
+ assert(ras_interrupt_mappings.num_intrs > 0UL);
start = 0;
- end = ras_interrupt_mapping.num_intrs;
+ end = (int) ras_interrupt_mappings.num_intrs;
while (start <= end) {
mid = ((end + start) / 2);
if (intr_raw == ras_inrs[mid].intr_number) {
@@ -114,14 +115,14 @@
panic();
}
- if (selected->err_record->probe) {
+ if (selected->err_record->probe != NULL) {
ret = selected->err_record->probe(selected->err_record, &probe_data);
assert(ret != 0);
}
/* Call error handler for the record group */
assert(selected->err_record->handler != NULL);
- selected->err_record->handler(selected->err_record, probe_data,
+ (void) selected->err_record->handler(selected->err_record, probe_data,
&err_data);
return 0;