1. 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.
2. 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
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
Hi Sandrine Bailleux,
Thanks for responding.
Similar to this we understand that HIS_METRICS violations would also not require to address in the code. However, we didn't see any mention of HIS_METRICS compliance for TFA. Please confirm.
Regards, Nithin G
Hello Nithin,
I had to google "HIS metrics" as I was not familiar with them. I found the following page:
Is that what you are referring to here?
IIUC, these are a set of metrics to measure good coding practices. As such, are they not a different set of coding guidelines, distinct from MISRA? I am sure we can match some of the HIS metrics to some of the MISRA rules since they fulfill the same high-level goal but I don't think the HIS metrics are actually part of the MISRA standard, are they?
I don't think the TF-A project has ever committed to enforce HIS metrics.
Best regards, Sandrine
On 12/21/23 15:13, Nithin G via TF-A wrote:
Hi Sandrine Bailleux,
Thanks for responding.
Similar to this we understand that HIS_METRICS violations would also not require to address in the code. However, we didn't see any mention of HIS_METRICS compliance for TFA. Please confirm.
Regards, Nithin G
tf-a@lists.trustedfirmware.org