[U-Boot] [PATCH] omap3evm: Clean-up EVM detection code.

Albert ARIBAUD albert.aribaud at free.fr
Thu Dec 2 17:23:16 CET 2010


Le 02/12/2010 14:58, Wolfgang Denk a écrit :
> Dear Albert ARIBAUD,
>
> In message<4CF7922B.3020504 at free.fr>  you wrote:
>>
>> Now, on an unrelated note, omap3_emv's code arbitrarily uses an u8 where
>> an int (or enum) would be more appropriate, and this should be changed
>> not because it removes a linker warning, but because the u8 choice is
>> arbitrary and at best as effective as using an int, at worst suboptimal
>> to that.
>
> Well, an u8 is as good a data type as any other. The available range
> of 0...255 seems more than sufficient to store the needed
> information, so why should I waste 4 bytes of storage when a single
> byte is sufficient as well?

You don't necessarily use only one byte when declaring an u8 instead of 
an int, because the next declaration may have alignment requirements 
that will cause the compiler to skip bytes after the u8. Besides, u8 is 
not "as good a data type" as any other, it is a specific data type 
whereas 'int' is the native data type of the platform, supposed to be 
the most natural to deal with for the cpu -- 32-bit for an ARM.

u8 are perfect and normal, for instance, as fields of a structure which 
represents byte registers, or to perform 8-bit arithmetic. Here, 
however, there is indeed no reason to use any specific type, so we 
should use the cpu's native type.

> Best regards,
>
> Wolfgang Denk

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list