Skip to contentSkip to conversation

%pa format specifier issues

DISCUSSION Dave Hansen 2 participants 3 messages Mar 6, 2013

lore
Share & tools
lore
#0 lore raw

I went to go use the shiny new %pa specifier:

void test_printk_pa(void)

{
        phys_addr_t p = 0x1234;
        printk("p: %pa\n", p);
}

but gcc is spewing out warnings at me:

Quoted 2 lines

arch/x86/mm/physaddr.c: In function ‘test_printk_pa’:
arch/x86/mm/physaddr.c:95:2: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘phys_addr_t’ [-Wformat]

I assume that's because gcc doesn't know about '%pa', and just assumes it's a plain '%p'. Should we be turning these warnings off somehow?

Plus when I actually go to run it, vsnprintf() crashes the kernel, which usually happens if printk()'s format doesn't match the size of its arguments.

Am I doing something really stupid here?

This is using a 32-bit i386 kernel.

#1 lore raw
Quoted 19 lines · Dave Hansen

I went to go use the shiny new %pa specifier:

void test_printk_pa(void)

{
        phys_addr_t p = 0x1234;
        printk("p: %pa\n", p);
}

but gcc is spewing out warnings at me:

Quoted 2 lines

arch/x86/mm/physaddr.c: In function ‘test_printk_pa’:
arch/x86/mm/physaddr.c:95:2: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘phys_addr_t’ [-Wformat]

I assume that's because gcc doesn't know about '%pa', and just assumes it's a plain '%p'. Should we be turning these warnings off somehow?

Plus when I actually go to run it, vsnprintf() crashes the kernel, which usually happens if printk()'s format doesn't match the size of its arguments.

Quoted 6 lines

Am I doing something really stupid here?

This is using a 32-bit i386 kernel.

From reading the patch I thought you had to pass the address via

reference. Otherwise you get the warning like you mention here, and then probably an oops when the kernel tries to dereference 0x1234.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#2 lore raw
Quoted 8 lines · Stephen Boyd
Quoted 6 lines
Quoted 5 lines

Am I doing something really stupid here?

This is using a 32-bit i386 kernel.

From reading the patch I thought you had to pass the address via

reference. Otherwise you get the warning like you mention here, and then probably an oops when the kernel tries to dereference 0x1234.

Heh, that would qualify as "really stupid". Thanks :)