다음을 통해 공유


PREfast Warning 285 (Windows CE 5.0)

Send Feedback

285 - (<non-zero constant> || <non-zero constant>) is always TRUE.
Question: Was the bitwise-or operator intended?

This warning indicates that two constant values, both greater than 1, were detected as arguments to a logical-OR operation that occurs in a test context. This expression is always TRUE.

Constant values greater than 1 suggest that the arguments to logical-or could be bit fields. Consider whether a bitwise operator, & or |, might be a more appropriate operator in this case.

Example

Defective Source

#define     TESTED_VALUE    0x37
#define     MASK            0xaa

if (TESTED_VALUE || MASK) {;}

Corrected Source

#define     TESTED_VALUE    0x37
#define     MASK            0xaa

if (TESTED_VALUE & MASK) {;}

// Or more rarely

if (TESTED_VALUE | MASK) {;}

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.