[PROBLEM linux-next] ./include/linux/kern_levels.h:5:25: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
Mirsad Todorovac
mtodorovac69 at gmail.com
Wed Jul 10 10:28:59 PDT 2024
Hi all,
On the linux-next vanilla next-20240709 tree, I have attempted the seed KCONFIG_SEED=0xEE7AB52F
which was known from before to trigger various errors in compile and build process.
Though this might seem as contributing to channel noise, Linux refuses to build this config,
treating warnings as errors, using this build line:
$ time nice make W=1 -k -j 36 |& tee ../err-next-20230709-01a.log; date
As I know that the Chief Penguin doesn't like warnings, but I am also aware that there are plenty
left, there seems to be more tedious work ahead to make the compilers happy.
The compiler output is:
./include/linux/kern_levels.h:5:25: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~
./include/linux/printk.h:462:25: note: in definition of macro ‘printk_index_wrap’
462 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~
drivers/mtd/devices/slram.c:52:25: note: in expansion of macro ‘printk’
52 | #define T(fmt, args...) printk(KERN_DEBUG fmt, ## args)
| ^~~~~~
./include/linux/kern_levels.h:15:25: note: in expansion of macro ‘KERN_SOH’
15 | #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
| ^~~~~~~~
drivers/mtd/devices/slram.c:52:32: note: in expansion of macro ‘KERN_DEBUG’
52 | #define T(fmt, args...) printk(KERN_DEBUG fmt, ## args)
| ^~~~~~~~~~
drivers/mtd/devices/slram.c:304:17: note: in expansion of macro ‘T’
304 | T("slram: devlength = %s\n", devlength);
| ^
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
make[5]: *** [scripts/Makefile.build:244: drivers/mtd/devices/slram.o] Error 1
make[5]: Target 'drivers/mtd/devices/' not remade because of errors.
cc1: all warnings being treated as errors
The problem seems to originate from pre-git era < 2005-04-16 ^1da177e4c3f4 ("Linux-2.6.12-rc2").
----------------------------------------
drivers/mtd/devices/slram.c
----------------------------------------
277 static int __init init_slram(void)
278 {
279 char *devname;
280
281 #ifndef MODULE
282 char *devstart;
283 char *devlength;
284
285 if (!map) {
286 E("slram: not enough parameters.\n");
287 return(-EINVAL);
288 }
289 while (map) {
290 devname = devstart = devlength = NULL;
291
292 if (!(devname = strsep(&map, ","))) {
293 E("slram: No devicename specified.\n");
294 break;
295 }
296 T("slram: devname = %s\n", devname);
297 if ((!map) || (!(devstart = strsep(&map, ",")))) {
298 E("slram: No devicestart specified.\n");
299 }
300 T("slram: devstart = %s\n", devstart);
→ 301 if ((!map) || (!(devlength = strsep(&map, ",")))) {
302 E("slram: No devicelength / -end specified.\n");
303 }
→ 304 T("slram: devlength = %s\n", devlength);
305 if (parse_cmdline(devname, devstart, devlength) != 0) {
306 return(-EINVAL);
307 }
308 }
309 #else
310 int count;
311 int i;
312
313 for (count = 0; count < SLRAM_MAX_DEVICES_PARAMS && map[count];
314 count++) {
315 }
316
317 if ((count % 3 != 0) || (count == 0)) {
318 E("slram: not enough parameters.\n");
319 return(-EINVAL);
320 }
321 for (i = 0; i < (count / 3); i++) {
322 devname = map[i * 3];
323
324 if (parse_cmdline(devname, map[i * 3 + 1], map[i * 3 + 2])!=0) {
325 return(-EINVAL);
326 }
327
328 }
329 #endif /* !MODULE */
330
331 return(0);
332 }
----------------------------------------
NOTE, in line 301, in case of lazy evaluation, if (map == NULL, then (!(devlength = strsep(&map, ",")))
will not be evaluated, and devlength will not be assigned.
As a diff speaks more than a thousand words, here is the proposed fix:
----------------------------------><-----------------------------------------------
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 28131a127d06..8297b366a066 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -296,10 +296,12 @@ static int __init init_slram(void)
T("slram: devname = %s\n", devname);
if ((!map) || (!(devstart = strsep(&map, ",")))) {
E("slram: No devicestart specified.\n");
+ break;
}
T("slram: devstart = %s\n", devstart);
if ((!map) || (!(devlength = strsep(&map, ",")))) {
E("slram: No devicelength / -end specified.\n");
+ break;
}
T("slram: devlength = %s\n", devlength);
if (parse_cmdline(devname, devstart, devlength) != 0) {
--
Hope this helps.
Best regards,
Mirsad Todorovac
More information about the linux-mtd
mailing list