HP Code Advisor Diagnostics

C allows conversion between pointers to interchangeable types, but this can be unsafe. Mismatch
between character pointer types is diagnosed with a unique message so it can be suppressed if
desired.
Example:
int foo(char *x, unsigned char *y) {
x = y; // warning 4212 here
}
Action:
If this conversion is safe for your code, then suppress this warning by providing an explicit cast.
Reference:
C99 6.3.2.3
4225 suggest parentheses around comparison in operand of %sq
Cause:
The bitwise operator | has lower precedence than the comparison operator, possibly changing
the semantics of the expression. This can be caused by other combinations of comparison and
bitwise operators as well.
Example:
bool check(unsigned p1, unsigned p2, unsigned mask) {
return ( p1 == p2 | mask );
}
Action:
Disambiguate the expression by using explicit parenthesis around the bitwise operator, thus
return ( p1 == (p2 | mask) );
Reference:
4227 padding struct with %s1 bytes to align member %sq2
Cause:
The compiler has added s1 bytes before a member so that it will be aligned and hence accessed
efficiently.
Example:
typedef struct {
int field1;
double field2;
} str;
Action:
Insertion of padding bytes themselves is not a problem but you need to ensure that you do not
use hard coded offsets for accessing fields of the struct through pointers, use offset of macro
instead. In some cases the number of padding bytes being inserted can be reduced by reordering
the fields.
Reference:
4228 64 bit migration: conversion from %t1 to a more strictly aligned type
%t2 may cause misaligned access
Cause:
56 Diagnostics Details