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!