Re: drivers/pci/probe.c compile warnings on -tip

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mikael Pettersson
Date: Wednesday, October 1, 2008 - 3:47 am

Steven Noonan writes:
 > I was hunting down some warnings I got when compiling -tip, and with
 > one of them, I'm not sure what would be a proper way to handle it.
 > 
 > If CONFIG_PHYS_ADDR_T_64BIT is not enabled, these warnings show up:
 > 
 > drivers/pci/probe.c: In function '__pci_read_base':
 > drivers/pci/probe.c:308: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 4 has type 'resource_size_t'
 > drivers/pci/probe.c:308: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 5 has type 'resource_size_t'
 > drivers/pci/probe.c:320: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 5 has type 'resource_size_t'
 > drivers/pci/probe.c:320: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 6 has type 'resource_size_t'
 > drivers/pci/probe.c: In function 'pci_read_bridge_bases':
 > drivers/pci/probe.c:392: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 3 has type 'resource_size_t'
 > drivers/pci/probe.c:392: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 4 has type 'resource_size_t'
 > drivers/pci/probe.c:405: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 3 has type 'resource_size_t'
 > drivers/pci/probe.c:405: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 4 has type 'resource_size_t'
 > drivers/pci/probe.c:443: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 4 has type 'resource_size_t'
 > drivers/pci/probe.c:443: warning: format '%llx' expects type 'long
 > long unsigned int', but argument 5 has type 'resource_size_t'
 > 
 > 
 > Each of the lines is something like this:
 > 
 > printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
 > pci_name(dev), pos, res->start, res->end);
 > 
 > res->start and res->end are resource_size_t (which is phys_addr_t),
 > and are sized either 32-bit or 64-bit, based on whether
 > CONFIG_PHYS_ADDR_T_64BIT is set.

Oh not those again. Similar warnings in 27-rc's drivers/pci
were fixed recently, but apparently someone out there likes
to create new ones.

The fix is to cast the resource_size_t arguments to unsigned long long.
With "%llx" that's the /only/ valid argument type.

Also note that these warnings aren't harmless. On 32-bit machines
with parameters passed on the stack the mismatch in size between
32-bit resource_size_t and the 64-bit %llx causes undefined
behaviour as printk mis-enumerates its parameters.

/Mikael
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
drivers/pci/probe.c compile warnings on -tip, Steven Noonan, (Wed Oct 1, 1:02 am)
Re: drivers/pci/probe.c compile warnings on -tip, Mikael Pettersson, (Wed Oct 1, 3:47 am)
Re: drivers/pci/probe.c compile warnings on -tip, Jesse Barnes, (Wed Oct 1, 8:51 am)
Re: drivers/pci/probe.c compile warnings on -tip, Steven Noonan, (Sat Oct 4, 8:55 pm)
Re: drivers/pci/probe.c compile warnings on -tip, Ingo Molnar, (Sun Oct 5, 3:18 am)
Re: drivers/pci/probe.c compile warnings on -tip, Yinghai Lu, (Sun Oct 5, 11:06 am)
Re: drivers/pci/probe.c compile warnings on -tip, Ingo Molnar, (Sun Oct 5, 11:21 pm)