else-branch with empty debug statement
I have a lot of debug message options in my code.
ifdef DO_DEBUG
define DBG_INFO(txt) WriteLn(txt)
endif
void foo(UInt16 a)
{
if (a != 0)
{
DoSomething();
}
else
{
DBG_INFO("a = 0");
}
}
With Lint 9.00L I get a note "960" Violates MISRA 2004Required Rule 14.10, else-branch must have a comment or action.
However, the else branch is not empty. It contains code that is just removed by the preprocessor.
I have seen some similar effects with asm statements where for lint I have done:
define asm(txt)
Only give a 960 note when the else branch is truly empty.
Hi Rene,
Simply adding a comment will resolve the issue here e.g. else { /* comment */ }.
-
Arpad Toth commented
A comment would suit you better.
-
Carl commented
Wouldn't adding a "-dDO_DEBUG" to your lint file resolve this issue? Then Lint should always see your else blocks as non-empty.