* [PATCH v2] virt: vbox: use %pap format for printing resource_size_t
@ 2017-12-21 16:15 Arnd Bergmann
2017-12-21 17:02 ` David Laight
2017-12-22 12:03 ` Hans de Goede
0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-12-21 16:15 UTC (permalink / raw)
To: Hans de Goede, Arnd Bergmann, Greg Kroah-Hartman
Cc: Joe Perches, Larry Finger, linux-kernel
resource_size_t may be larger than pointers depending on configuration,
so we can run into this build warning:
drivers/virt/vboxguest/vboxguest_linux.c: In function 'vbg_pci_probe':
drivers/virt/vboxguest/vboxguest_linux.c:295:4: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
drivers/virt/vboxguest/vboxguest_linux.c:367:4: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
This uses the special %pap to print the address by reference.
Fixes: 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: Use %pap instead of the %rR that was just as incorrect, as
pointed out by Joe Perches.
---
drivers/virt/vboxguest/vboxguest_linux.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
index d045aa51ce03..82e280d38cc2 100644
--- a/drivers/virt/vboxguest/vboxguest_linux.c
+++ b/drivers/virt/vboxguest/vboxguest_linux.c
@@ -291,8 +291,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
vmmdev = devm_ioremap(dev, mmio, mmio_len);
if (!vmmdev) {
- vbg_err("vboxguest: Error ioremap failed; MMIO addr=%p size=%d\n",
- (void *)mmio, (int)mmio_len);
+ vbg_err("vboxguest: Error ioremap failed; MMIO addr=%pap size=%pap\n",
+ &mmio, &mmio_len);
goto err_disable_pcidev;
}
@@ -362,9 +362,9 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
device_create_file(dev, &dev_attr_host_version);
device_create_file(dev, &dev_attr_host_features);
- vbg_info("vboxguest: misc device minor %d, IRQ %d, I/O port %x, MMIO at %p (size %d)\n",
+ vbg_info("vboxguest: misc device minor %d, IRQ %d, I/O port %x, MMIO at %pap (size %pap)\n",
gdev->misc_device.minor, pci->irq, gdev->io_port,
- (void *)mmio, (int)mmio_len);
+ &mmio, &mmio_len);
return 0;
--
2.9.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH v2] virt: vbox: use %pap format for printing resource_size_t
2017-12-21 16:15 [PATCH v2] virt: vbox: use %pap format for printing resource_size_t Arnd Bergmann
@ 2017-12-21 17:02 ` David Laight
2017-12-21 17:15 ` Arnd Bergmann
2017-12-22 12:03 ` Hans de Goede
1 sibling, 1 reply; 4+ messages in thread
From: David Laight @ 2017-12-21 17:02 UTC (permalink / raw)
To: 'Arnd Bergmann', Hans de Goede, Greg Kroah-Hartman
Cc: Joe Perches, Larry Finger, linux-kernel
From: Arnd Bergmann
> Sent: 21 December 2017 16:15
>
> resource_size_t may be larger than pointers depending on configuration,
> so we can run into this build warning:
>
> drivers/virt/vboxguest/vboxguest_linux.c: In function 'vbg_pci_probe':
> drivers/virt/vboxguest/vboxguest_linux.c:295:4: error: cast to pointer from integer of different size
> [-Werror=int-to-pointer-cast]
> drivers/virt/vboxguest/vboxguest_linux.c:367:4: error: cast to pointer from integer of different size
> [-Werror=int-to-pointer-cast]
>
> This uses the special %pap to print the address by reference.
>
> Fixes: 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: Use %pap instead of the %rR that was just as incorrect, as
> pointed out by Joe Perches.
> ---
> drivers/virt/vboxguest/vboxguest_linux.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
> index d045aa51ce03..82e280d38cc2 100644
> --- a/drivers/virt/vboxguest/vboxguest_linux.c
> +++ b/drivers/virt/vboxguest/vboxguest_linux.c
> @@ -291,8 +291,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
>
> vmmdev = devm_ioremap(dev, mmio, mmio_len);
> if (!vmmdev) {
> - vbg_err("vboxguest: Error ioremap failed; MMIO addr=%p size=%d\n",
> - (void *)mmio, (int)mmio_len);
> + vbg_err("vboxguest: Error ioremap failed; MMIO addr=%pap size=%pap\n",
> + &mmio, &mmio_len);
Are you sure about the type of mmio_len?
While the argument to devm_ioremap() is of type resource_size_t it seems
extremely unlikely that the actual value will exceed 2^32.
Using a 64bit type for the length on 32bit systems will generate horrid code.
I can't see the code in my tree to check.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] virt: vbox: use %pap format for printing resource_size_t
2017-12-21 17:02 ` David Laight
@ 2017-12-21 17:15 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-12-21 17:15 UTC (permalink / raw)
To: David Laight
Cc: Hans de Goede, Greg Kroah-Hartman, Joe Perches, Larry Finger,
linux-kernel
On Thu, Dec 21, 2017 at 6:02 PM, David Laight <David.Laight@aculab.com> wrote:
> From: Arnd Bergmann
>> Sent: 21 December 2017 16:15
>>
>> resource_size_t may be larger than pointers depending on configuration,
>> so we can run into this build warning:
>>
>> drivers/virt/vboxguest/vboxguest_linux.c: In function 'vbg_pci_probe':
>> drivers/virt/vboxguest/vboxguest_linux.c:295:4: error: cast to pointer from integer of different size
>> [-Werror=int-to-pointer-cast]
>> drivers/virt/vboxguest/vboxguest_linux.c:367:4: error: cast to pointer from integer of different size
>> [-Werror=int-to-pointer-cast]
>>
>> This uses the special %pap to print the address by reference.
>>
>> Fixes: 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>> v2: Use %pap instead of the %rR that was just as incorrect, as
>> pointed out by Joe Perches.
>> ---
>> drivers/virt/vboxguest/vboxguest_linux.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
>> index d045aa51ce03..82e280d38cc2 100644
>> --- a/drivers/virt/vboxguest/vboxguest_linux.c
>> +++ b/drivers/virt/vboxguest/vboxguest_linux.c
>> @@ -291,8 +291,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
>>
>> vmmdev = devm_ioremap(dev, mmio, mmio_len);
>> if (!vmmdev) {
>> - vbg_err("vboxguest: Error ioremap failed; MMIO addr=%p size=%d\n",
>> - (void *)mmio, (int)mmio_len);
>> + vbg_err("vboxguest: Error ioremap failed; MMIO addr=%pap size=%pap\n",
>> + &mmio, &mmio_len);
>
> Are you sure about the type of mmio_len?
> While the argument to devm_ioremap() is of type resource_size_t it seems
> extremely unlikely that the actual value will exceed 2^32.
> Using a 64bit type for the length on 32bit systems will generate horrid code.
>
> I can't see the code in my tree to check.
I made sure the type matches. I thought about changing it to size_t
and using %zd, but decided that it didn't matter.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] virt: vbox: use %pap format for printing resource_size_t
2017-12-21 16:15 [PATCH v2] virt: vbox: use %pap format for printing resource_size_t Arnd Bergmann
2017-12-21 17:02 ` David Laight
@ 2017-12-22 12:03 ` Hans de Goede
1 sibling, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2017-12-22 12:03 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman; +Cc: Joe Perches, Larry Finger, linux-kernel
Hi,
On 21-12-17 17:15, Arnd Bergmann wrote:
> resource_size_t may be larger than pointers depending on configuration,
> so we can run into this build warning:
>
> drivers/virt/vboxguest/vboxguest_linux.c: In function 'vbg_pci_probe':
> drivers/virt/vboxguest/vboxguest_linux.c:295:4: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> drivers/virt/vboxguest/vboxguest_linux.c:367:4: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>
> This uses the special %pap to print the address by reference.
>
> Fixes: 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: Use %pap instead of the %rR that was just as incorrect, as
> pointed out by Joe Perches.
Thank you for fixing this, the fix looks good to me:
Acked-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> drivers/virt/vboxguest/vboxguest_linux.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
> index d045aa51ce03..82e280d38cc2 100644
> --- a/drivers/virt/vboxguest/vboxguest_linux.c
> +++ b/drivers/virt/vboxguest/vboxguest_linux.c
> @@ -291,8 +291,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
>
> vmmdev = devm_ioremap(dev, mmio, mmio_len);
> if (!vmmdev) {
> - vbg_err("vboxguest: Error ioremap failed; MMIO addr=%p size=%d\n",
> - (void *)mmio, (int)mmio_len);
> + vbg_err("vboxguest: Error ioremap failed; MMIO addr=%pap size=%pap\n",
> + &mmio, &mmio_len);
> goto err_disable_pcidev;
> }
>
> @@ -362,9 +362,9 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
> device_create_file(dev, &dev_attr_host_version);
> device_create_file(dev, &dev_attr_host_features);
>
> - vbg_info("vboxguest: misc device minor %d, IRQ %d, I/O port %x, MMIO at %p (size %d)\n",
> + vbg_info("vboxguest: misc device minor %d, IRQ %d, I/O port %x, MMIO at %pap (size %pap)\n",
> gdev->misc_device.minor, pci->irq, gdev->io_port,
> - (void *)mmio, (int)mmio_len);
> + &mmio, &mmio_len);
>
> return 0;
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-22 12:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21 16:15 [PATCH v2] virt: vbox: use %pap format for printing resource_size_t Arnd Bergmann
2017-12-21 17:02 ` David Laight
2017-12-21 17:15 ` Arnd Bergmann
2017-12-22 12:03 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).