linux-mips
[Top] [All Lists]

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

To: <linux-mips@linux-mips.org>
Subject: RE: [PATCH 2/6] setup.c: move initrd code inside dedicated functions
From: "Kaz Kylheku" <kaz@zeugmasystems.com>
Date: Fri, 11 Aug 2006 10:24:27 -0700
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
Thread-index: Aca9WNdqUWhur2ahRHanse+Kx+d32AADm0Xg
Thread-topic: [PATCH 2/6] setup.c: move initrd code inside dedicated functions
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.

You definitely do need a cast if you are printing a pointer
as an integer though.

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. 

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".

Oopsies!

One last note: if you are printing hex, and want that
0x prefix, you can use the # flag, e.g.

  printk(KERN_INFO "%#lx\n", 0xdeadbeefUL);

Cheers ...






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