uint8 config;
#define ELEM1 1U
void test1(void)
{
/*Check Bit 0 of Configuration*/
if((config) == 2 && (config) == 4)
{
arr[ELEM1].status[0] = 0x00;
}
}
do I need to try with
1)
if(((config) == 2) && ((config) == 4))
if((Boolean)((config) == 2) && ((config) == 4))
after above change, I am observing error now:
Conditional expression should have essentially Boolean type [MISRA 2012 Rule 14.4, required]
First of all,
config
can't realistically have the value2
and4
at once, now can it? So you probably meant to use||
. Or bitwise&
perhaps?As for the warning, if you mix several operators in the same expression, MISRA-C requires that you add parenthesis around sub expressions. The MISRA compliant code would be:
The result of
&& ||
etc operators is essentially boolean, so there is no need to cast.