[Top] [All Lists]

RE: [PATCH 2/6] setup.c: move initrd code inside dedicated functions

To: Kaz Kylheku <>
Subject: RE: [PATCH 2/6] setup.c: move initrd code inside dedicated functions
From: Geert Uytterhoeven <>
Date: Sun, 13 Aug 2006 19:07:43 +0200 (CEST)
Cc: Linux/MIPS Development <>
In-reply-to: <66910A579C9312469A7DF9ADB54A8B7D33AF4A@exchange.ZeugmaSystems.local>
Original-recipient: rfc822;
References: <66910A579C9312469A7DF9ADB54A8B7D33AF4A@exchange.ZeugmaSystems.local>
On Fri, 11 Aug 2006, Kaz Kylheku wrote:
> Franck Bui-Huu wrote:
> > Atsushi Nemoto wrote:
> > >> +        printk(KERN_INFO "Initial ramdisk at: 0x%p (%lu bytes)\n",
> > >> +               (void *)initrd_start, initrd_size);
> > > 
> > > You can use "0x%lx" for initrd_start and remove the cast.  
> > I know this
> > > fragment are copied from corrent code as is, but it would be a good
> > > chance to clean it up.
> > > 
> > 
> > You're right.
> Actually the cast that is there is only pedantic. ANSI C says that
> %p must be met with a void *, which might be important on some
> exotic machine where pointers have a different representation
> based on their type. Elsewhere, it would be very surprising
> if omitting the (void *) caused a problem with %p.

Except that initrd_start is not a pointer, but an unsigned long...

> And you have to cast to an integer that is wide enough for the
> pointer.  If you are compiling for 64 bit, that means
> "unsigned long long", unless you are sure that the upper
> 32 bits are all zero. 

unsigned long is 64-bit on LP64 systems, i.e. on all 64-bit Linux systems.
That excludes (why am I not surprised) Win64, which is P64.

> Ideally, you should just be able to use %p to print pointers,
> and I'd love to recommend that. It should be smart enough to
> know that they are 64 bits wide. I'm looking at the vsprintf
> in 2.6.17 and see that, sadly, it converts the void * pulled
> from the va_arg to "unsigned long".

%p works fine for pointers, on both 32-bit and 64-bit Linux.



Geert Uytterhoeven -- There's lots of Linux beyond ia32 --

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                                            -- Linus Torvalds

<Prev in Thread] Current Thread [Next in Thread>