MISRA Compliance

February 24, 2026 ยท View on GitHub

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.

Suppressed with Coverity Comments

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

Rule 10.5

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.

Rule 11.1

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.

Rule 12.1

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.

Rule 11.5

Ref 11.5.1

  • MISRA C-2012 Rule 11.5 Allow casts from void *. Fields such as publish payloads are passed as void * and must be cast to the correct data type before use.

Rule 21.3

Ref 21.3.1

  • MISRA C:2012 Rule 21.3: MISRA warns against the use of dynamic memory allocation as it might lead to undefined behavior if not used properly. Proper care is taken in the code to not use free'd pointers and to check the validity of malloc'd memory before it is dereferenced or used.