public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* include/linux/printk.h:434:44: warning: '%s' directive argument is null
@ 2024-01-11 12:29 kernel test robot
  2024-01-11 16:27 ` Petr Mladek
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2024-01-11 12:29 UTC (permalink / raw)
  To: Chris Down; +Cc: oe-kbuild-all, linux-kernel, Petr Mladek

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   de927f6c0b07d9e698416c5b287c521b07694cac
commit: 337015573718b161891a3473d25f59273f2e626b printk: Userspace format indexing support
date:   2 years, 6 months ago
config: x86_64-randconfig-002-20240105 (https://download.01.org/0day-ci/archive/20240111/202401112002.AOjwMNM0-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240111/202401112002.AOjwMNM0-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401112002.AOjwMNM0-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:19,
                    from arch/x86/include/asm/percpu.h:27,
                    from arch/x86/include/asm/current.h:6,
                    from include/linux/sched.h:12,
                    from include/linux/blkdev.h:5,
                    from drivers/scsi/scsi_devinfo.c:3:
   drivers/scsi/scsi_devinfo.c: In function 'scsi_dev_info_list_add_str':
>> include/linux/printk.h:434:44: warning: '%s' directive argument is null [-Wformat-overflow=]
     434 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
         |                                            ^
   include/linux/printk.h:430:3: note: in definition of macro 'printk_index_wrap'
     430 |   _p_func(_fmt, ##__VA_ARGS__);    \
         |   ^~~~~~~
   drivers/scsi/scsi_devinfo.c:551:4: note: in expansion of macro 'printk'
     551 |    printk(KERN_ERR "%s: bad dev info string '%s' '%s'"
         |    ^~~~~~
   drivers/scsi/scsi_devinfo.c:552:14: note: format string is defined here
     552 |           " '%s'\n", __func__, vendor, model,
         |              ^~


vim +434 include/linux/printk.h

   406	
   407	/*
   408	 * Some subsystems have their own custom printk that applies a va_format to a
   409	 * generic format, for example, to include a device number or other metadata
   410	 * alongside the format supplied by the caller.
   411	 *
   412	 * In order to store these in the way they would be emitted by the printk
   413	 * infrastructure, the subsystem provides us with the start, fixed string, and
   414	 * any subsequent text in the format string.
   415	 *
   416	 * We take a variable argument list as pr_fmt/dev_fmt/etc are sometimes passed
   417	 * as multiple arguments (eg: `"%s: ", "blah"`), and we must only take the
   418	 * first one.
   419	 *
   420	 * subsys_fmt_prefix must be known at compile time, or compilation will fail
   421	 * (since this is a mistake). If fmt or level is not known at compile time, no
   422	 * index entry will be made (since this can legitimately happen).
   423	 */
   424	#define printk_index_subsys_emit(subsys_fmt_prefix, level, fmt, ...) \
   425		__printk_index_emit(fmt, level, subsys_fmt_prefix)
   426	
   427	#define printk_index_wrap(_p_func, _fmt, ...)				\
   428		({								\
   429			__printk_index_emit(_fmt, NULL, NULL);			\
   430			_p_func(_fmt, ##__VA_ARGS__);				\
   431		})
   432	
   433	
 > 434	#define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
   435	#define printk_deferred(fmt, ...)					\
   436		printk_index_wrap(_printk_deferred, fmt, ##__VA_ARGS__)
   437	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: include/linux/printk.h:434:44: warning: '%s' directive argument is null
  2024-01-11 12:29 include/linux/printk.h:434:44: warning: '%s' directive argument is null kernel test robot
@ 2024-01-11 16:27 ` Petr Mladek
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Mladek @ 2024-01-11 16:27 UTC (permalink / raw)
  To: kernel test robot; +Cc: Chris Down, oe-kbuild-all, linux-kernel

On Thu 2024-01-11 20:29:05, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   de927f6c0b07d9e698416c5b287c521b07694cac
> commit: 337015573718b161891a3473d25f59273f2e626b printk: Userspace format indexing support
> date:   2 years, 6 months ago
> config: x86_64-randconfig-002-20240105 (https://download.01.org/0day-ci/archive/20240111/202401112002.AOjwMNM0-lkp@intel.com/config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240111/202401112002.AOjwMNM0-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202401112002.AOjwMNM0-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/kernel.h:19,
>                     from arch/x86/include/asm/percpu.h:27,
>                     from arch/x86/include/asm/current.h:6,
>                     from include/linux/sched.h:12,
>                     from include/linux/blkdev.h:5,
>                     from drivers/scsi/scsi_devinfo.c:3:
>    drivers/scsi/scsi_devinfo.c: In function 'scsi_dev_info_list_add_str':
> >> include/linux/printk.h:434:44: warning: '%s' directive argument is null [-Wformat-overflow=]
>      434 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
>          |                                            ^
>    include/linux/printk.h:430:3: note: in definition of macro 'printk_index_wrap'
>      430 |   _p_func(_fmt, ##__VA_ARGS__);    \
>          |   ^~~~~~~
>    drivers/scsi/scsi_devinfo.c:551:4: note: in expansion of macro 'printk'
>      551 |    printk(KERN_ERR "%s: bad dev info string '%s' '%s'"
>          |    ^~~~~~
>    drivers/scsi/scsi_devinfo.c:552:14: note: format string is defined here
>      552 |           " '%s'\n", __func__, vendor, model,
>          |              ^~

This should get fixed by
https://lore.kernel.org/all/20240111162419.12406-1-pmladek@suse.com/

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-11 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-11 12:29 include/linux/printk.h:434:44: warning: '%s' directive argument is null kernel test robot
2024-01-11 16:27 ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox