MISRA rules violations of Generated Code for Embedded Coder
13 次查看(过去 30 天)
显示 更早的评论
Hi,
I am using Embedded Coder to generate C source code from a Simulink model, selecting MISRA-C compliance objective, and when I run Polyspace analysis, I get lots of MISRA rules violations.
How can this be fixed?
Regards.
0 个评论
回答(3 个)
Anirban
2018-10-4
In addition to the previous answer, another possibility can be that you ran Polyspace for MISRA rules meant for handwritten code and not generated code. MISRA C:2012 (Appendix E) moves several rules from the Required category to the Advisory or Readability category if the code is generated from a model. If you ran Polyspace with the Required subset of MISRA C:2012 checkers for handwritten code, you might get more violations compared to the Required subset for generated code.
To run Polyspace with the MISRA C:2012 checker for generated code, use the Polyspace option Use generated code requirements ( -misra3-agc-mode). See documentation for the option . If you run Polyspace directly from Simulink, this option gets enabled automatically.
0 个评论
Prakhar Jain
2018-9-25
The rules of MISRA C:2012 often gets updated with newer releases and a variety of reasons can be responsible for the violation. Please find the below rules for violation scenarios which has been made for the later releases and may be causing violations.
1) If there are identifiers beginning with underscore
2) If a reserved identifier or macro name is declared
Note: The above possible workaround may/may not work for your case.
In case you only expect to remove the warnings, you can always uncheck rules in the Coding Rules & Code Metrics in the configuration pane. Follow the below steps:
1) Open configuration pane
2) Click on the edit button as seen in the screenshot in red
3) Go to let's say rule no 21.2 and uncheck it as shown in screenshot in red
The above remove warnings can also be unchecked for other rule violations if required.
0 个评论
Michael Burke
2019-12-2
Note: one thing that you should look at is the model configuration parameters. This link provides a good overview of what you should do to configure your model:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bug Finder Analysis in Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!