I suggest you ...

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.

1 vote
Vote
Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
You have left! (?) (thinking…)
rene.denooijer shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

1 comment

Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
Submitting...
  • Carl commented  ·   ·  Flag as inappropriate

    Wouldn't adding a "-dDO_DEBUG" to your lint file resolve this issue? Then Lint should always see your else blocks as non-empty.

Feedback and Knowledge Base