From 50029b9ac3c60371f8606fb874df9038fb6839d0 Mon Sep 17 00:00:00 2001 From: Maheedhar Bollapalli Date: Thu, 25 Apr 2024 14:46:28 +0530 Subject: [PATCH] fix(platforms): modify function to have single return This corrects the MISRA violation C2012-15.5: A function should have a single point of exit at the end. Introduced a temporary variable to store the return value to ensure single return for the function. Change-Id: I9c2ca05b506a6ac35b24966fc5fdd5e88e65770d Signed-off-by: Nithin G Signed-off-by: Maheedhar Bollapalli --- plat/common/aarch64/plat_common.c | 18 +++++++++++++----- plat/common/plat_gicv2.c | 22 ++++++++++++++-------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/plat/common/aarch64/plat_common.c b/plat/common/aarch64/plat_common.c index 7a228b976..ba47b30a0 100644 --- a/plat/common/aarch64/plat_common.c +++ b/plat/common/aarch64/plat_common.c @@ -78,19 +78,27 @@ int plat_sdei_validate_entry_point(uintptr_t ep, unsigned int client_mode) const char *get_el_str(unsigned int el) { + const char *mode = NULL; + switch (el) { case MODE_EL3: - return "EL3"; + mode = "EL3"; + break; case MODE_EL2: - return "EL2"; + mode = "EL2"; + break; case MODE_EL1: - return "EL1"; + mode = "EL1"; + break; case MODE_EL0: - return "EL0"; + mode = "EL0"; + break; default: assert(false); - return NULL; + break; } + + return mode; } #if FFH_SUPPORT diff --git a/plat/common/plat_gicv2.c b/plat/common/plat_gicv2.c index 05df97add..6a2d09032 100644 --- a/plat/common/plat_gicv2.c +++ b/plat/common/plat_gicv2.c @@ -48,8 +48,9 @@ uint32_t plat_ic_get_pending_interrupt_id(void) unsigned int id; id = gicv2_get_pending_interrupt_id(); - if (id == GIC_SPURIOUS_INTERRUPT) - return INTR_ID_UNAVAILABLE; + if (id == GIC_SPURIOUS_INTERRUPT) { + id = INTR_ID_UNAVAILABLE; + } return id; } @@ -68,22 +69,27 @@ uint32_t plat_ic_get_pending_interrupt_id(void) uint32_t plat_ic_get_pending_interrupt_type(void) { unsigned int id; + uint32_t interrupt_type; id = gicv2_get_pending_interrupt_type(); /* Assume that all secure interrupts are S-EL1 interrupts */ if (id < PENDING_G1_INTID) { #if GICV2_G0_FOR_EL3 - return INTR_TYPE_EL3; + interrupt_type = INTR_TYPE_EL3; #else - return INTR_TYPE_S_EL1; + interrupt_type = INTR_TYPE_S_EL1; #endif + } else { + + if (id == GIC_SPURIOUS_INTERRUPT) { + interrupt_type = INTR_TYPE_INVAL; + } else { + interrupt_type = INTR_TYPE_NS; + } } - if (id == GIC_SPURIOUS_INTERRUPT) { - return INTR_TYPE_INVAL; - } - return INTR_TYPE_NS; + return interrupt_type; } /*