Main Content

Import Justifications from Older Standard to Newer Standard

When you migrate from using an older standard to a newer version of the standard, Polyspace® automatically imports the review information from the older standard. Importing justification from older standards to newer standard is supported for these standards:

  • Importing comments and annotations from MISRA C™:2004 to MISRA C:2012.

  • Importing comments and annotations from MISRA C:2004 and MISRA C:2012 to MISRA C:2023.

  • Importing comments and annotations from MISRA™ C++:2008 and AUTOSAR C++14 to MISRA C++:2023. Polyspace automatically imports the annotations from MISRA C++2008 rules and AUTOAR C++14 rules to the equivalent MISRA C++:2023 rules.

Polyspace automatically imports these review information from the older standard:

  • Status, Severity, and Comment values added through the user interface.

  • Justifications added using code annotations.

For general rules on importing comments, see Import Review Information from Previous Polyspace Analysis.

Suppose your project has this source code and you run a MISRA C:2012 analysis.

#include <stdint.h>
#include <complex.h>
void foo() {
	uint16_t u16x = 0, u16y = 0;
	uint32_t u32x = 0, u32y = 0;
	u32x * (u16x + u16y);         
	u32x = (u16x + u16y) + u32x; 
	u32x += (u32y + u16y);

}

void bar() {
	_Complex float cx;
	_Complex double dx;
	float f;
	double d;

	cx + f;         
	cx + d;         
}
Polyspace finds 16 violations of MISRA C:2012 rules and directives. Suppose you justify the violations of Directive 4.6.

Results list for MISRA C:2012 showing justifications for violations of Directive 4.6

If you migrate to checking violations of MISRA C:2023 coding rules in the same project, Polyspace automatically imports the justifications you provided for MISRA C:2012 results.

Results list for MISRA C:2023 showing imported justifications for violations of Directive 4.6

Polyspace imports justifications and annotations when migrating from an older MISRA C standard to a newer MISRA C standard. If your current analysis checks for violations of both older and newer MISRA C standards, then the justifications and annotations are imported to the older MISRA C violations.

Mapping Multiple MISRA C:2004 Annotations to the Same Newer MISRA C Result

When you justify violations of MISRA C: 2004 rules and directives by using code block syntax or multiple-line annotation syntax, and multiple violations map to the same MISRA C: 2012 or MISRA C:2023 rule, Polyspace does not import each justification. Instead, Polyspace imports only one set of Status, Severity, and Comment values and applies these values to all instances of that particular MISRA C: 2012 or MISRA C:2023 rule violation.

For example, suppose that you analyze your code and find violations of MISRA C: 2004 Rules 16.3 and 16.5. You can justify these results by using the annotation syntax where you enter a different status and explanatory comment for each rule.


//polyspace-begin misra2004:16.3 [Status 1] "Explanatory comment 1"
//polyspace-begin misra2004:16.5 [Status 2] "Explanatory comment 2"

/*code block start;*/
/* This block of code contains violations of
MISRA C:2004 rules 16.3 and 16.5 */
/*code block end;*/

//polyspace-end misra2004:16.3 
//polyspace-end misra2004:16.5 
 

These violations map to MISRA C: 2012 Rule 8.2. When you check your annotated code against the MISRA C: 2012 standard, Polyspace imports only the first line of annotations (for MISRA C:2004 Rule 16.3) and applies it to all results for MISRA C:2012 Rule 8.2. The second line of annotations (for MISRA C:2004 Rule 16.5) is ignored. In the Results List pane, all violations of MISRA C: 2012 Rule 8.2 have the Status column set to Status 1 and the Comment column set to "Explanatory comment 1".

Note

The Output Summary pane displays a warning message for every result where the imported annotation conflicts with the original annotation. After you import your MISRA C:2004 annotations, check that a justified status has not been assigned to results you intend to investigate or fix.

See Also

| |

Related Topics