From c42d0d8754ae8818a7e7a63e873ca7699a7f102b Mon Sep 17 00:00:00 2001 From: Arvind Ram Prakash Date: Mon, 4 Mar 2024 16:33:27 -0600 Subject: [PATCH] fix(misra): fix MISRA defects This patch resolves the MISRA issues reported in mailing list. It addresses the following MISRA Rules violations - Rule 15.7 and Rule 2.4. * As per Rule 15.7, All if.. else if constructs should be terminated with an else statement and hence the conditional block has been changed to switch..case. Updated get_el_str() to include all EL cases. * As per Rule 2.4, A project should not contain unused tag declarations, hence intr_type_desc tag is removed. * bl31_lib_init is only used in translation unit and hence it's declaration is removed from bl31.h and the definition is made static to maintain visibility. Signed-off-by: Arvind Ram Prakash Change-Id: Ica1d3041566baf51befcad5fd3714189117ba193 --- bl31/bl31_main.c | 2 +- bl31/interrupt_mgmt.c | 2 +- include/bl31/bl31.h | 1 - plat/common/aarch64/plat_common.c | 13 ++++++++++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c index c8cc2c719..98078171d 100644 --- a/bl31/bl31_main.c +++ b/bl31/bl31_main.c @@ -83,7 +83,7 @@ uintptr_t get_arm_std_svc_args(unsigned int svc_mask) /******************************************************************************* * Simple function to initialise all BL31 helper libraries. ******************************************************************************/ -void __init bl31_lib_init(void) +static void __init bl31_lib_init(void) { cm_init(); } diff --git a/bl31/interrupt_mgmt.c b/bl31/interrupt_mgmt.c index 68c7f10ad..a2b2c0685 100644 --- a/bl31/interrupt_mgmt.c +++ b/bl31/interrupt_mgmt.c @@ -34,7 +34,7 @@ * * All other bits are reserved and SBZ. ******************************************************************************/ -typedef struct intr_type_desc { +typedef struct { interrupt_type_handler_t handler; u_register_t scr_el3[2]; uint32_t flags; diff --git a/include/bl31/bl31.h b/include/bl31/bl31.h index 1d58ef968..ed5374e04 100644 --- a/include/bl31/bl31.h +++ b/include/bl31/bl31.h @@ -22,6 +22,5 @@ void bl31_register_bl32_init(int32_t (*func)(void)); void bl31_register_rmm_init(int32_t (*func)(void)); void bl31_warm_entrypoint(void); void bl31_main(void); -void bl31_lib_init(void); #endif /* BL31_H */ diff --git a/plat/common/aarch64/plat_common.c b/plat/common/aarch64/plat_common.c index 4d6346cf0..19c4e48eb 100644 --- a/plat/common/aarch64/plat_common.c +++ b/plat/common/aarch64/plat_common.c @@ -72,12 +72,19 @@ int plat_sdei_validate_entry_point(uintptr_t ep, unsigned int client_mode) const char *get_el_str(unsigned int el) { - if (el == MODE_EL3) { + switch (el) { + case MODE_EL3: return "EL3"; - } else if (el == MODE_EL2) { + case MODE_EL2: return "EL2"; + case MODE_EL1: + return "EL1"; + case MODE_EL0: + return "EL0"; + default: + assert(false); + return NULL; } - return "EL1"; } #if FFH_SUPPORT