more pcf50606 patches

Andrew Paulsen andrew.paulsen at
Fri Jan 25 20:07:52 CET 2008

On Jan 25, 2008 11:52 AM, Andy Green <andy at> wrote:
> Hash: SHA1
> Somebody in the thread at some point said:
> >> While compilers sometimes automatically promote data types, you really
> >> should not count on it.  Try this:
> You're right, but C specifically talks about *promoting* to *int*.  In
> this last example you are already at int (you can't 'promote' to it
> then) and trying to blow out the arithmetic to __int64 size, it's a
> different case.
> The bottom line is the overflow situation you are patching against
> cannot happen, you can drop that stanza of the patch.

In this case, we aren't even talking about ints, we are talking about
int_16 and int_32 types.  When doing math operations that depend on
correct data types, one should not leave it up to the compiler to
guess what you want to do.  In this case, it appears to promote
u_int16_t to 32-bit integers before doing the math, then casting to
u_int_32_t.  I agree that it seems to work the way it is, but the
existing line is wrong and it is very easy to fix.  I am not going to
change my patch to make it less clear what is going on.  I'm not sure
why you're fighting this, the patched version is more clear, is
correct, and has absolutely no penalty.

> - -Andy
> Version: GnuPG v1.4.7 (GNU/Linux)
> Comment: Using GnuPG with Fedora -
> iD8DBQFHmiHmOjLpvpq7dMoRAuNzAJ9bZVbXIfTysvbs94KZlR61fM3wPACeOjm7
> PKZbkox2JvHwp6kj7RffS5k=
> =k+15

More information about the openmoko-kernel mailing list