Hi Nithin,
Both rules 15.1 and 15.5 are advisories only and TF-A project made no commitment to comply with them [1]. Therefore, I'd rather keep the code as it is (I personally think such changes would hurt code readability).
Best regards, Sandrine
[1] See the usual spreadsheet attached to this page: https://developer.trustedfirmware.org/w/tf_a/tf-a-misra-analysis/
On 12/14/23 14:37, Nithin G via TF-A wrote:
- misra_c_2012_rule_15_1_violation: Using "goto" statement.
In the file common/bl_common.c and other related files, getting misra_c_2012_rule_15_1_violation: Using "goto" statement. during the Coverity MISRA-C analysis. if (...) { goto exit; }
exit: some operation
Resolution: goto statement is replaced with exit_func() and new variable is introduced to store the return value of exit_func(). exit_func() some operation
int ret; if (...) { ret = return value of exit func() }
return ret;
Is it possible to fix MISRA 15.1 like this in open source? Please suggest.
- misra_c_2012_rule_15_5_violation: This return statement is not the final statement in the compound statement that forms the body of the function.
In the file common/bl_common.c, lib/xlat_tables/aarch64/xlat_tables.c and other related files, getting misra_c_2012_rule_15_5_violation: This return statement is not the final statement in the compound statement that forms the body of the function. during the Coverity MISRA-C analysis. if (...) { return <something> } if (...) { return <something> } return; Resolution: Taken new variable and assign the return result to new variable and calling only one return statement in end of the function. int result; if (...) { result = <something> } else { if (...) { result = <something> } } return result;
Is it possible to fix MISRA 15.5 like this in open source? Please suggest.
Thanks & Regards, Nithin G