[U-Boot-Users] printf question

Tolunay Orkun listmember at orkun.us
Thu Mar 25 22:05:33 CET 2004


> In message <54305.216.110.51.8.1080245554.squirrel at www.orkun.us> you
> wrote:
>
>> I agree, unsigned char should be promoted to unsigned int.
>
> Must, not should.

Agreed. Poor choice of words...

>> However, char can be unsigned or signed depending on the platform. On a
>
> But the variable in question  was  of  type  "unsigned  char",  which
> leaves no room for implementation-specific behaviour.

In that case, compiler is generating incorrect code. Sign extension should
not have been done.

>> with twos complement arithmetic. %02X can only suppress leaving zeros so
>> additional f's will be printed.
>
> Oops? %02X will _add_ leading zeroes if the result is too short,  but
> it will never supress anything.

My bad. The thing that I was trying to say was that since char is promoted
to int, 0's in the higher order 3 bytes will not be printed by %02X format
specification but if any one of those higher order bytes was non-zero (as
a result of sign extension) the output will overflow from the 2 character
field.

> [Maybe we should take this to c.l.c ;-)]

OK.

Best regards,
Tolunay




More information about the U-Boot mailing list