HP-UX Cadvise Diagnostics Reference Guide (5900-1865, August 2012)

Table Of Contents
int main() {
int i;
time_t t1 = 1024;
scanf("%d", );
if (t1+=i, t1 < 10) {
t1 *= i;
}
return 0;
}
The expressions t1 += i, and t1 *= i can cause overflow and needs to be explicitly checked.
Action:
If there is no explicit check for overflow after arithmetic expressions on time_t/clock_t values, add
a check.
Reference:
4373 non arithmetic integer conversion resulted in a change of sign
Cause:
When assigning hexadecimal or octal values to an integer type, if the data causes a change in
the sign of the type, this warning is displayed.
Example:
int main()
{
short i = 0xFFFF;
short j = 0x10000;
return 0;
}
Action:
Check for hexadecimal or octal constant, which though fitting in the integral type mentioned, causes
a sign change.
Reference:
4377 endian porting: sending data may be endian dependent if not
preceded by conversion
Cause:
While sending data over the network to a remote socket, it should be converted from host to network
byte order to ensure correctness of the data.
This diagnostic occurs when the data,
1. sent from host to network is not converted using pre-defined conversion calls such as htons/htonl
or
2. modified before sending but after conversion
int main()
{
int sock, data;
send(sock, data);
return 0;
}
Following is the cadvise warning for above scenario of send without conversion:
"endian_1.c", line 8: warning #4377-D: endian porting: sending data may be endian dependent if not preceeded
by conversion
send(sock, data);
Action:
Convert data to network byte order before sending to remote socket.
70 Diagnostics Details