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

From: Vegard Nossum
Date: Tue Jul 01 2008 - 15:12:39 EST


On Tue, Jul 1, 2008 at 8:58 PM, Andi Kleen <andi@xxxxxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/