[PATCH v2 3/3][MTD] P4080/mtd: Fix the freescale lbc issue with 36bit mode

Artem Bityutskiy dedekind1 at gmail.com
Tue Sep 14 02:45:20 EST 2010


On Mon, 2010-09-13 at 09:35 -0500, Timur Tabi wrote:
> On Mon, Sep 13, 2010 at 9:27 AM, Artem Bityutskiy <dedekind1 at gmail.com> wrote:
> 
> > Yes, sizeof(int) == 4 assumption is not good.
> >
> > But sizeof(int) >= 4 is perfectly fine.
> 
> I have to disagree.   I don't see how you can say that == is not okay,
> but >= is okay.

If I assume that int == 4, which is true for all platform ATM, and will
most probably stay true for very long time, I still make an unnecessary
assumption which C99 does not guarantee. This is just not very clean. So
for things which require exactly 32 bits, u32 or C99 uint32_t should be
used.

On the other hand, if a have a local variable "var" which needs to store
values which I know will always fit 32 bits, and I do not use it in
operations (I/O, etc) which require exactly 32 bits, it is better to use
unsigned int for it. Unsigned int is reliably >= 4 in Linux.

This is wat I meant that sizeof(int) >= 4 is perfectly fine. One
everywhere, of course, but in many cases.

To put it differently, if there is no special reason to limit the
variable by exactly 32 bits, it is better to use int.

-- 
Best Regards,
Artem Bityutskiy (Битюцкий Артём)



More information about the Linuxppc-dev mailing list