mercredi 21 juillet 2021

"Expression Used in the condition always yields the same result" warning in C

I want to know what exactly the meaning of Expression Used in the condition always yields the same result Misra warning. Here is the piece of code i am using.

#define bool_new_timer_val    (Time_cnt < 4sec)

if( (bool_new_timer_val == True) ||
    (mystruct.bool_u8_status1 != 0x0) ||
    ((mystruct.bool_u8_status1 == 0x0) && (bool_old_timer == True)) ||
    (mystruct.bool_u8_status2 == True) ||
    (mystruct.bool_u8_status3 == True))
{
   // update the logic
}

While running Misra, i am getting the warning as Expression 'mystruct.bool_u8_status1' used in the condition always yields the same result. The issue is pointing to the line ((mystruct.bool_u8_status1 == 0x0) && (bool_old_timer == True))

I would like to know what is this warning means. My guess is that the value mystruct.bool_u8_status1 always set as 0x0. Is this correct understanding ? Any suggestions ?

Aucun commentaire:

Enregistrer un commentaire