Hi

Rather than adding an empty else (which seems quite artificial), wouldn't putting return "EL1";​ into an else be more in keeping with the structure of the code?

Thanks

Tom

From: Nithin G via TF-A <tf-a@lists.trustedfirmware.org>
Sent: 16 January 2024 09:17
To: tf-a@lists.trustedfirmware.org <tf-a@lists.trustedfirmware.org>
Subject: [TF-A] Re: All if...else if constructs shall be terminated with an else statement.
 
Hi,

Adding to the above misra_c_2012_rule_15_7_violation. getting same violation for this file /plat/common/aarch64/plat_common.c:

const char *get_el_str(unsigned int el)
         {
(1) Event misra_c_2012_rule_15_7_violation:     No non-empty terminating "else" statement.
                 if (el == MODE_EL3) {
                         return "EL3";
                 } else if (el == MODE_EL2) {
                         return "EL2";
                 }
                 return "EL1";
         }

Resolution: added empty else statement to resolve the issue.

const char *get_el_str(unsigned int el)
         {
                 if (el == MODE_EL3) {
                         return "EL3";
                 } else if (el == MODE_EL2) {
                         return "EL2";
                 } else {
}
                 return "EL1";
         }
--
TF-A mailing list -- tf-a@lists.trustedfirmware.org
To unsubscribe send an email to tf-a-leave@lists.trustedfirmware.org