lint flags a miscellany of legal constructs that may not represent what the programmer intended. Examples:
An unsigned variable always has a nonnegative value. So the test:
unsigned x; if (x < 0) ...
unsigned x; if (x > 0) ...
if (x != 0) ...
This may not be the intended action. lint flags questionable comparisons of unsigned variables with negative constants or 0. To compare an unsigned variable to the bit pattern of a negative number, cast it to unsigned:
if (u == (unsigned) -1) ...
if (u == -1U) ...
lint flags expressions without side effects that are used in a context where side effects are expected--that is, where the expression may not represent what the programmer intends. It issues an additional warning whenever the equality operator is found where the assignment operator is expected--that is, where a side effect is expected:
int fun() { int a, b, x, y; (a = x) && (b == y); }
lint cautions you to parenthesize expressions that mix both the logical and bitwise operators (specifically, &, |, ^, <<, >>), where misunderstanding of operator precedence may lead to incorrect results. Because the precedence of bitwise &, for example, falls below logical ==, the expression:
if (x & a == 0) ...
if (x & (a == 0)) ...
which is most likely not what you intended. Invoking lint with -h disables the diagnostic.