more pcf50606 patches

Andy Green andy at openmoko.com
Fri Jan 25 18:06:28 CET 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Somebody in the thread at some point said:

>> adc_adcin1 and adc_batvolt are both u_int16_t.  Multiplying them by a
>> large number before implicitly casting them to a u_int32_t is what
>> could cause the overflow.  That is why I made an explicit caste before
>> the multiply.  Again, I changed it to a signed type.
> 
> Wouldn't be the first time gcc surprised me but doesn't stuff get
> promoted to int before any arithmetic happens?

Yeah

#include <stdio.h>

int main(void)
{
        short s1 = 30000, s2 = 30000;
        int n = s1 * s2;

        printf("%d\n", n);
        return 0;
}
$ gcc test.c -o test
$ ./test
900000000

- -Andy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHmhcUOjLpvpq7dMoRAnBfAJwMJtaBIox8K27PTAV2XNO6nf/HXgCgk3H8
mTQbM17LTx1gerP3OXn4JcY=
=LX4p
-----END PGP SIGNATURE-----




More information about the openmoko-kernel mailing list