public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mirsad Todorovac <mtodorovac69@gmail.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-mtd@lists.infradead.org
Subject: [PROBLEM linux-next] ./include/linux/kern_levels.h:5:25: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
Date: Wed, 10 Jul 2024 19:28:59 +0200	[thread overview]
Message-ID: <e3cdee98-e2a0-4991-ae6c-4d8ee687a284@gmail.com> (raw)

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


                 reply	other threads:[~2024-07-10 17:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3cdee98-e2a0-4991-ae6c-4d8ee687a284@gmail.com \
    --to=mtodorovac69@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox