First, determine if the code is incorrect or not. Sometimes the operator-precedence rules of ANSI-C do not quite give the results one would expect. Sometimes faulty code can appear to be correct. Consider the example in the following listing:
if (x & y != 0) ... evaluates as: if (x & (y != 0)) ... but not as: if ((x & y) != 0) ...
Another source of unexpected behavior can be found among the integral promotion rules of C. Characters are usually (sign-)extended to integers. This can sometimes have quite unexpected effects, e.g., the if condition in the following listing is FALSE:
unsigned char a, b; b = -8; a = ~b; if (a == ~b) ...
because extending a results in 0x0007, while extending b gives 0x00F8 and the ' ~' results in 0xFF07. If the code contains a bug, isolate the construct causing it and send a bug report to Freescale support.