Search code examples
cmisra

MISRA C mapping to Klocwork violations


Is there a mapping between MISRA rules for example:

  • A function shall not be declared implicitly (MISRA C R.17.3), such as use "int f(int x);" and not " f(x);".

  • All exit paths from a function with non-void return type shall have an explicit return statement with an expression (MISRA C R.17.4).

into a Klocwork checker?

for example I was able to find: requierment: The operand of the sizeof operator shall not contain any expression that has potential side effects (MISRA C R.13.6).

klocwork: MISRA.SIZEOF.SIDE_EFFECT Operand of sizeof has side effects 5-3-4 Pre-2020.1

how do you handle these for MISRA C?


Solution

  • Typically, tool vendors have a many-to-many mapping between their own in-house mappings, and third-party rule-sets such as MISRA C or CERT C.

    Klocwork themselves provide the mappings in their product documentation:.

    https://help.klocwork.com/current/en-us/concepts/misrac2012_amd1nolinks.htm

    Note: Answer expanded by Andrew, to address review comment (which can, hopefully, now be deleted)