Thursday, December 24, 2015

PC-Lint: using -estring to suppress MISRA-C warnings in the global wrap-up

Neither the PC-Lint manual nor the Gimpel forum - at least at the time of writing - gives a good recommendation how to suppress MISRA-C warnings in the global wrap-up. This issue pertains for example to the message "Note 960: Violates MISRA 2004 Required Rule 8.9, undefined symbol", which is followed by the name of the undefined symbol. You might have defined this symbol in Assembler, therefore a suppression of this message for this specific symbol is adequate. However:
  • All suppressions that pertain to a specific location in the source code are useless, as this message is raised during global wrap-up, where none of these suppressions apply.
  • -estring(960, "symbol name") is not specific enough: it suppresses most MISRA-C warning about that symbol, not only the violation of rule 8.9. That's only because most MISRA-C warning have message code 960 or 961. Otherwise this is just the right option to suppress message in the global wrap-up.
  • -esym(960, 8.9) disables rules 8.9 for ALL symbols.
  • -estring(960, "undefined symbol*symbol name") doesn't work either: it seems like the whole message text is not matched against the expression, only all parts of the message.
Only through some experimentation I finally found the solution: -estring(960, "undefined symbol", "symbol name") Opposite to other options like -esym, the arguments of the -estring option seem to be AND-ed for the match, not OR-ed. Therefore the above -estring option suppresses the MISRA-C warning about undefined symbols just for "symbol name" and nothing else.

No comments:

Post a Comment