Skip to contentSkip to conversation

serial: 8250_gsc: fix printk format warning

PATCH In review Alexander Beregalov 3 participants 3 messages May 18, 2009 – May 29, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 serial: 8250_gsc: fix printk format warning

Fix this build warning:
drivers/serial/8250_gsc.c:44: warning: format '%lx' expects type 'long unsigned int', but argument 2 has type 'resource_size_t'

---
 drivers/serial/8250_gsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/serial/8250_gsc.c +1 -1
index 418b4fe..a7b02a5 100644
@@ -41,7 +41,7 @@ static int __init serial_init_chip(struct parisc_device *dev)
 			printk(KERN_INFO
 				"Serial: device 0x%lx not configured.\n"
 				"Enable support for Wax, Lasi, Asp or Dino.\n",
-				dev->hpa.start);
+				(unsigned long)dev->hpa.start);
 		return -ENODEV;
 	}
 
Signature · 1 line
1.6.2.5
#1 lore raw
Quoted 4 lines · On Mon, 18 May 2009 17:11:31 +0400 Alexander Beregalov <[email protected]>…

Fix this build warning:
drivers/serial/8250_gsc.c:44: warning: format '%lx' expects type 'long unsigned int', but argument 2 has type 'resource_size_t'

The patch does more than fix a "warning". It fixes an actual error. The caller will prepare a 64-bit argument and the callee will print only 32 bits of it.

Quoted 9 lines
---
 drivers/serial/8250_gsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/serial/8250_gsc.c +0 -0
index 418b4fe..a7b02a5 100644

drivers/serial/8250_gsc.c static int __init serial_init_chip(struct parisc_device *dev) · line 44

Quoted 5 lines
drivers/serial/8250_gsc.c +1 -1
@@ -41,7 +41,7 @@ static int __init serial_init_chip(struct parisc_device *dev)
 			printk(KERN_INFO
 				"Serial: device 0x%lx not configured.\n"
 				"Enable support for Wax, Lasi, Asp or Dino.\n",
-				dev->hpa.start);
+				(unsigned long)dev->hpa.start);

Nope. hpa.start can be u32 or u64. We need to cast that to the wider type so that it will correctly print in all circumstances.

So I changed both patches to print with %ll and to cast to unsigned long long.

#2 lore raw
Quoted 10 lines · Andrew Morton
Quoted 4 lines · On Mon, 18 May 2009 17:11:31 +0400 Alexander Beregalov <[email protected]>…

Fix this build warning:
drivers/serial/8250_gsc.c:44: warning: format '%lx' expects type 'long unsigned int', but argument 2 has type 'resource_size_t'

The patch does more than fix a "warning". It fixes an actual error. The caller will prepare a 64-bit argument and the callee will print only 32 bits of it.

On parisc, AFAIK, GSC devices are always at a 32-bit addresses. So whatever compiles clean is fine.

Please add "Reviewed by: Grant Grundler <[email protected]>"

thanks,
grant

Quoted 24 lines
Quoted 9 lines
---
 drivers/serial/8250_gsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/serial/8250_gsc.c +0 -0
index 418b4fe..a7b02a5 100644

drivers/serial/8250_gsc.c static int __init serial_init_chip(struct parisc_device *dev) · line 44

Quoted 5 lines
drivers/serial/8250_gsc.c +1 -1
@@ -41,7 +41,7 @@ static int __init serial_init_chip(struct parisc_device *dev)
 			printk(KERN_INFO
 				"Serial: device 0x%lx not configured.\n"
 				"Enable support for Wax, Lasi, Asp or Dino.\n",
-				dev->hpa.start);
+				(unsigned long)dev->hpa.start);

Nope. hpa.start can be u32 or u64. We need to cast that to the wider type so that it will correctly print in all circumstances.

So I changed both patches to print with %ll and to cast to unsigned long long.
--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html