[PATCH v2 3/3][MTD] P4080/mtd: Fix the freescale lbc issue with 36bit mode
Artem Bityutskiy
dedekind1 at gmail.com
Mon Sep 13 10:27:55 EDT 2010
On Mon, 2010-09-13 at 09:10 -0500, Timur Tabi wrote:
> On Mon, Sep 13, 2010 at 2:30 AM, Zang Roy-R61911 <r61911 at freescale.com> wrote:
>
> > What is the different for unsigned int and u32? I think they are same.
>
> Roy, please don't ever write code that assumes that sizeof(int) == 4.
> There's a reason why we have unsized integer types (like int, long,
> and short) and sized integer types (like u8, u16, u32). If you want
> an integer of a specific size, you should use a sized integer type.
Yes, sizeof(int) == 4 assumption is not good.
But sizeof(int) >= 4 is perfectly fine.
It is OK to rely on the fact that unsigned int is _at least_ 32-bit, not
less. And if you know 32 bits is enough, and you are fine with more, it
is _better_ to avoid u32. Simply because with unsigned int you do not
limit the compiler and CPU and let them use native integers, rather than
strictly 32-bit. This potentially gives the compiler and CPU more room
for optimization.
I see people use u32 and the friends too much. It is safe and better to
use native types, unless you really have to make the variable to be
strictly u32.
I did not follow this particular conversation and do not judge which
type is better in this case. I am talking in general. :-)
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
More information about the linux-mtd
mailing list