Can I exclude utility functions generated by rtw coder 2015b from static analysis?

3 views (last 30 days)
Can I exclude utility functions such as asr_s32(), multiword_s32(), etc generated by rtw coder 2015b from polyspace code prover static analysis? Or do we have to consider MISRA-C and RTE violations present due to the utility functions mentioned above also as a part of total count?

Answers (1)

Anirban
Anirban on 21 Nov 2019
Edited: Anirban on 21 Nov 2019
If your Polyspace version is later than R2016a, you can use this option to exclude specific files or folders:
A more limited version of this option also exists in R2015b: Files and folders to ignore. See here: https://www.mathworks.com/help/releases/R2015b/codeprover/ug/exclude-from-rules-checking.html
But even this limited version of the option should work for your use-case.
  2 Comments
Imran Ahmed
Imran Ahmed on 24 Nov 2019
Thanks for the reply Anirban. Yes, I know there is an option to exclude files from analysis in code prover 2016b. But my question is, as the utility functions, which were mentioned in the question are supporting functions generated by rtw coder. Can the violations present in this functions be justified or ignored?
Anirban
Anirban on 26 Nov 2019
Just to understand your requirement better, you want these violations to not show up at all (or somehow be auto-justified) and you do not want to have to perform any setup since the files came from rtw coder.
There are several points to this answer:
1. As far as I understand, code analysis with Polyspace is designed to work independently from the code generation tool. In other words, Polyspace should not justify a violation because it has prior knowledge of the code generation tool. This allows you to use Polyspace as the tool that reports all violations on the final code that will be deployed in production. After all, the final code to be deployed involves the utility functions, too. At the same time, you have the option to exclude those files if you want. That is what the option here does: https://www.mathworks.com/help/codeprover/ref/donotgenerateresultsfordonotgenerateresultsfor.html
If you generate a report later, the report will also show the files there were excluded. That way, the onus is on you to exclude those files and the tool can be trusted to report all violations.
Note: The way the option works, the files are analyzed but the results are suppressed. This means that if a linking error involves two files, one excluded and the other not, the error still shows.
2. The run-time error checks are a different issue. They rely on data flow through your entire program. So a run-time error might occur in a utility function because of data passed from code generated from the model.
So, it does not make sense to suppress run-time error checks from utility files and the option does not work for this type of results. For these results, it is expected that you review the result and manually justify them. If you justify them once, you can pass along your justifications to the next runs.
3. Depending on the specific rule violations, there might be ways to generate more MISRA-compliant code in the first place.
If you contact MathWorks Technical Support with this question, they might be able to help you and suggest a smoother process. Contact support here: https://www.mathworks.com/support.html

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!