The PKCS #11 library files conform to the MISRA C:2012 guidelines, with some noted exceptions. Compliance is checked with Coverity static analysis. The specific deviations, suppressed inline, are listed below.
Additionally, MISRA configuration file contains the project wide deviations.
To find the violation references in the source files run grep on the source code with ( Assuming rule 10.5 violation; with justification in point 1 ):
grep 'MISRA Ref 10.5.1' . -rI
Ref 10.5.1
- MISRA C-2012 Rule 10.5 The value of an expression should not be cast to an inappropriate essential type. The boolean type of the PKCS #11 standard is an unsigned char, which is an acceptable base type for a boolean type.
Ref 11.1.1
- MISRA C-2012 Rule 11.1 Doesn't allow conversions between function pointers and any other type However, since we're just using this to suppress the compiler warning, we're also fine with suppressing the MISRA violation related to this line as well.
Ref 12.1.1
- MISRA C-2012 Rule 12.1 Requires precedence of operators within an expression to be explicit. The third party macro being used here throws a violation when used. Adding additional parens to the call or to the decleration doesn't remove the violation, so we suppress it.
Ref 11.5.1
- MISRA C-2012 Rule 11.5 Allow casts from
void *
. Fields such as publish payloads are passed asvoid *
and must be cast to the correct data type before use.