Home > User Support > CoverageMaster winAMS FAQ

CoverageMaster winAMS FAQ

MISRA-C Checker

D01_02: The MISRA-C rule checker reports a shift operation violation (not checked) even though the shift value was checked. Why?

Question:

The MISRA-C rule checker reports a shift operation violation (not checked) even though the shift value was checked. Why?

Answer:

This may occur if the shift variable is a structure member.

Example

if ( pStrPtr->shiftBit >= 0 && pStrPtr->shiftBit < 32 ) // check shift variable
{
    data >> pStrPtr->shiftBit; // shift operation
}

Regarding the example above, the shift value is checked before the shift operation, however CasePlayer2's MISRA-C rule checker reports rule errors such as #[12.8] for MISRA-C 2004 or #[38] for MISRA-C 1998. This is due to a CasePlayer2 analysis engine limitation.

CasePlayer2 has the option to change the analysis mode if the error is reported or not. The option "Identify possible problems in program execution" can be changed from:

CasePlayer2 - Settings - MISRA-C Checker.

If the option is enabled, CasePlayer2's code analysis engine reports the maximum possibility of code errors. But if disabled, the error will not be reported. The option is enabled by default.

As for the recommended usage, the option should be enabled and the user should check the source code when the error would be reported.


<Reference from CasePlayer2 help manual>

Identify possible problems in program execution

Indicate whether to display messages pointing out that may cause problems in program execution in relation to the rules below.
This indication can only control the pointing out of problems in program execution caused by one rule, and rules that are clearly problematic (or clearly violated).

<<Rules for which this option is applied in MISRA-C:1998>>

Rule 4
Rule 30
Rule 38
Rule 114

<<Rules for which this option is applied in MISRA-C:2004>>

Rule 9.1
Rule 12.8
Rule 17.1
Rule 17.2
Rule 17.3
Rule 17.4
Rule 20.1
Rule 21.1


Related Technical Tips Search

Other technical tips in GAIO's web site can be searched for using the links below.

Search key word link: MISRA-C | Shift operation
Technical Tips Google Search



Information Links