Re: [PATCH] x86: small unifications of address printing

Vegard Nossum
2008-07-01T19:12:36Z

On Tue, Jul 1, 2008 at 8:58 PM, Andi Kleen <andi@firstfloor.org> wrote:
>
>> Yes, it will, and correctly too:
>>
>> case 'p':
>> flags |= SMALL;
>> if (field_width == -1) {
>> field_width = 2*sizeof(void *);
>> flags |= ZEROPAD;
>> }
>>
>> Or did I read this code wrong? field_width is initialized to -1 by
>> default unless overridden. The SMALL flag means lowercase hexadecimal
>> digits.
>
> You're right. The kernel differs from user space/traditional behaviour
> in this regard.

...in this regard _too_ ;-)

I just ran a short test with glibc, and I'm surprised to see that this
implementation is not zero-padding the number.

The C99 standard has this to say:

"The argument shall be a pointer to void. The value of the pointer is
converted to a sequence of printing characters, in an implementation-defined
manner."

so I suppose it's quite alright after all.

Thanks for looking.

Vegard

--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036