Re: [PATCH] net: skbuff: use _RET_IP_

Joe Perches
2013-05-31T16:54:58Z

On Fri, 2013-05-31 at 18:33 +0400, Sergei Shtylyov wrote:
> On 31-05-2013 9:20, Joe Perches wrote:
> > Don't use a standalone gcc compiled program to
> > determine what the kernel outputs.
[]
> > The kernel output is;
>
> > printk("0x%lx\n", 0x100ul) 0x100
> > printk("%p\n", (void *)0x100ul) 00000100
> > printk("%#p\n", (void *)0x100ul) 0x00000100
>
> > The last one isn't used at all in kernel source. (gcc complains)
> > It's always "0x%p"
>
> I was talking about using "%#lx", not "%#p". I don't see it in your
> example.

"0x%lx" and "%#lx" produce the same output in the kernel.

The latter isn't used very often though.
I expect most coders don't know it exists/works.

$ git grep -E "0x%l{0,2}x" | wc -l
12542
$ git grep -E "%#l{0,2}x" | wc -l
1737

(some false positives there of course)

Also, some might expect that "%#08lx", is 10 chars wide,
but it's only 8, so maybe "0x%08lx" is better used.

The "%#08lx" width defect seems pretty common:

$ git grep -E -i "%#0(8|16)l{0,2}x" | wc -l
253