diff mbox series

virt: vbox: use %pR format for printing resource_size_t

Message ID 20171221145956.675556-1-arnd@arndb.de
State Superseded
Headers show
Series virt: vbox: use %pR format for printing resource_size_t | expand

Commit Message

Arnd Bergmann Dec. 21, 2017, 2:59 p.m. UTC
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 %pR 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>

---
 drivers/virt/vboxguest/vboxguest_linux.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

-- 
2.9.0

Comments

Joe Perches Dec. 21, 2017, 3:42 p.m. UTC | #1
On Thu, 2017-12-21 at 15:59 +0100, Arnd Bergmann wrote:
> resource_size_t may be larger than pointers depending on configuration,

> so we can run into this build warning:


nak.

struct resource is different than resource_size_t

> 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 %pR 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>

> ---

>  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..1074ff59721e 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=%pR size=%pR\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 %pR (size %pR)\n",

>  		 gdev->misc_device.minor, pci->irq, gdev->io_port,

> -		 (void *)mmio, (int)mmio_len);

> +		 &mmio, &mmio_len);

>  

>  	return 0;

>
Arnd Bergmann Dec. 21, 2017, 3:46 p.m. UTC | #2
On Thu, Dec 21, 2017 at 4:42 PM, Joe Perches <joe@perches.com> wrote:
> On Thu, 2017-12-21 at 15:59 +0100, Arnd Bergmann wrote:

>> resource_size_t may be larger than pointers depending on configuration,

>> so we can run into this build warning:

>

> nak.

>

> struct resource is different than resource_size_t


Ouch, thanks for catching this!

It should have been %pap of course.

     Arnd
diff mbox series

Patch

diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
index d045aa51ce03..1074ff59721e 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=%pR size=%pR\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 %pR (size %pR)\n",
 		 gdev->misc_device.minor, pci->irq, gdev->io_port,
-		 (void *)mmio, (int)mmio_len);
+		 &mmio, &mmio_len);
 
 	return 0;