Reputation: 550
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
Reputation: 550
We intend to solve the proble above with two Lint runs:
Upvotes: 0
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