Lord_Gestalter
Lord_Gestalter

Reputation: 550

Inhibit lint message 9007

According to MISRA rule 13.5 the right hand operand of a logical && or || operator shall not contain persistent side effects. Our code is checked with PC-Lint, message 9007 (http://gimpel-online.com/MsgRef.html#9007).

We have code of the form

if((GET_SIGNAL1() < CONST_1) || (GET_SIGNAL2() == CONST_2) ) { dostuff(); }

GET_x are macros, well, getting signal x with some error handling, the later causing intended side effects. A rule deviation to MISRA 13.5 is given, now the question is how to suppress the respective messages.

Efforts so far: Since this is auto generated code I can't put in lint comments directly, putting the comments in through the generator is though and, primarily, hardly traceable.

--e{(9007))} in the macro definition would work, but we also have code like foo = GET_SIGNAL1(); which would cause a function wide deactivation.

Thought about -ecall, too, but it just checks the call itself, not the context of the macro (as I hoped).

edit:

I can't affect neither model nor tool chain. Only parts I can affect are the lint configuration or "glue code" like the macro definitions

Upvotes: 1

Views: 832

Answers (2)

Lord_Gestalter
Lord_Gestalter

Reputation: 550

We intend to solve the proble above with two Lint runs:

  • 1st run with productive code and globally deactivated message 9007
  • 2nd run with stubbed macro without the intended side-effect, but nothing but message 9007 activated

Upvotes: 0

snowcrash09
snowcrash09

Reputation: 4804

Can you modify the generator to output a new macro like this:

#define TEST_SIGNALS(a,b,c,d)   ((a<b) || (c<d))

if (TEST_SIGNALS(GET_SIGNAL1(), CONST_1, GET_SIGNAL2(), CONST_2))
{
   dostuff()
}

And disable the warning like this:

//lint -emacro(9007, TEST_SIGNALS)

Upvotes: 1

Related Questions