Skip to contentSkip to conversation

format string mismatch in arch/sparc/kernel/sysfs.c

DISCUSSION Toralf Förster 2 participants 3 messages May 18, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

I'm just wondering if the format mismatch error is intentionally left in the code or not :

[arch/sparc/kernel/sysfs.c:154]: (warning) %ld in format string (no. 1) requires 'long *' but the argument type is 'unsigned long *'.

8a25a2fd arch/sparc/kernel/sysfs.c   (Kay Sievers      2011-12-21 14:29:42 -0800 149) static ssize_t store_mmustat_enable(struct device *s,
8a25a2fd arch/sparc/kernel/sysfs.c   (Kay Sievers      2011-12-21 14:29:42 -0800 150)                   struct device_attribute *attr, const char *buf,
4a0b2b4d arch/sparc64/kernel/sysfs.c (Andi Kleen       2008-07-01 18:48:41 +0200 151)                   size_t count)
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 152) {
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 153)   unsigned long val, err;
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 154)   int ret = sscanf(buf, "%ld", &val);               <--------------
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 155)
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 156)   if (ret != 1)
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 157)           return -EINVAL;
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 158)
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 159)   err = run_on_cpu(s->id, write_mmustat_enable, val);
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 160)   if (err)
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 161)           return -EIO;
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 162)
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 163)   return count;
d887ab3a arch/sparc64/kernel/sysfs.c (David Miller     2007-06-03 23:38:09 -0700 164) }
Signature · 1 line
Toralf
#1 lore raw

Hi Torlaf.

Quoted 3 lines

I'm just wondering if the format mismatch error is intentionally left in the code or not :

[arch/sparc/kernel/sysfs.c:154]: (warning) %ld in format string (no. 1) requires 'long *' but the argument type is 'unsigned long *'.

This is something we should fix.
My gcc does not give this warning - how did you produce the warning above? Also we use -Werror on purpose to catch warnings so they get fixed - so your build should have errored out.

Do you care to send a patch so you get proper attribution.

Sam

#2 lore raw
In reply to Toralf Förster
Quoted 7 lines · Sam Ravnborg

Hi Torlaf.

Quoted 3 lines

I'm just wondering if the format mismatch error is intentionally left in the code or not :

[arch/sparc/kernel/sysfs.c:154]: (warning) %ld in format string (no. 1) requires 'long *' but the argument type is 'unsigned long *'.

This is something we should fix.

patch will be send out soon.

Quoted 1 line

My gcc does not give this warning - how did you produce the warning above?

Well, I got it with cppcheck - a nifty tool for static code checkin. I stumbled over it a while ago - it still under development ofc.

Quoted 3 lines

Also we use -Werror on purpose to catch warnings so they get fixed - so your build should have errored out.

great

Quoted 5 lines

Do you care to send a patch so you get proper attribution.

Sam

Signature · 1 line
Toralf