HP Code Advisor Diagnostics

Action:
Ensure that the types of the argument passed matches with the types of formal parameters of
the function.
Reference:
2181 argument is incompatible with corresponding format string conversion
Cause:
The compiler has detected a format specifier whose data type does not match its corresponding
argument.
Example: printf("%d", 2.0);
Action:
Modify either the argument or the conversion specifier so that they match.
Reference:C99 6.2.2.7
2186 pointless comparison of unsigned integer with zero
Cause:
An unsigned expression is being tested to see if it is greater than zero. An ordered comparison
between an unsigned value and a constant that is zero may indicate a programming error.
Example:
size_t i = 10;
if(i >= 0)
printf("true");
Action:
Cast (or otherwise rewrite) one of the operands of the compare to match the signedness of the
other operand, or compare for equality with zero.
Reference:
2187 use of "=" where "==" may have been intended
Cause:
The assignment expression is used as the controlling expression of an if, while or for statement.A
common user mistake is to accidentally use assignment operator "="instead of the equality
operator "==" in an expression that controls a transfer. For example saying if (a = b) instead of if
(a == b).While using the assignment operator is valid, it is often not what is intended. When this
message is enabled, the compiler will detect these cases at compile-time. This can often avoid
long debugging sessions needed to find the bug in the user's program.
Example:
void check_ten(int arg) {
if(arg = 10)
printf("true");
}
Action:
Make sure that the assignment operator is what is expected.
Reference:
2188 enumerated type mixed with another type
Cause:
2181 argument is incompatible with corresponding format string conversion 35