Skip to contentSkip to conversation

sysfs: fix compile warning in i386

PATCH In review Zhang Yanfei 2 participants 2 messages Apr 3, 2013 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysfs: fix compile warning in i386

This patch fixes compile warning in i386:

drivers/base/cpu.c: In function 'show_crash_notes_size':
drivers/base/cpu.c:142:2: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]

---
 drivers/base/cpu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/base/cpu.c +3 -1
index a55b590..ee38cc2 100644
@@ -138,8 +138,10 @@ static ssize_t show_crash_notes_size(struct device *dev,
 				     char *buf)
 {
 	ssize_t rc;
+	unsigned long size;
 
-	rc = sprintf(buf, "%lu\n", sizeof(note_buf_t));
+	size = sizeof(note_buf_t);
+	rc = sprintf(buf, "%lu\n", size);
 	return rc;
 }
 static DEVICE_ATTR(crash_notes_size, 0400, show_crash_notes_size, NULL);
Signature · 1 line
1.7.1
maintainer
#1 lore raw
Quoted 16 lines · Zhang Yanfei

This patch fixes compile warning in i386:

drivers/base/cpu.c: In function 'show_crash_notes_size':
drivers/base/cpu.c:142:2: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]

---
 drivers/base/cpu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/base/cpu.c +0 -0
index a55b590..ee38cc2 100644

drivers/base/cpu.c static ssize_t show_crash_notes_size(struct device *dev, · line 144

Quoted 8 lines
drivers/base/cpu.c +3 -1
@@ -138,8 +138,10 @@ static ssize_t show_crash_notes_size(struct device *dev,
 				     char *buf)
 {
 	ssize_t rc;
+	unsigned long size;
 
-	rc = sprintf(buf, "%lu\n", sizeof(note_buf_t));
+	size = sizeof(note_buf_t);
+	rc = sprintf(buf, "%lu\n", size);

No, use %z, like Arnd did in his patch, that makes it correct for all arches. I'll take his patch instead.

thanks,

greg k-h