kernel/printk/printk.c:1913:9: warning: function 'printk_sprint' might be a candidate for 'gnu_printf' format attribute

From: kernel test robot
Date: Mon Sep 27 2021 - 09:29:21 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 92477dd1faa650e50bd3bb35a6c0b8d09198cc35
commit: b031a684bfd01d633c79d281bd0cf11c2f834ada printk: remove logbuf_lock writer-protection of ringbuffer
date: 10 months ago
:::::: branch date: 6 days ago
:::::: commit date: 10 months ago
config: mips-randconfig-r012-20210927 (attached as .config)
compiler: mips-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b031a684bfd01d633c79d281bd0cf11c2f834ada
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout b031a684bfd01d633c79d281bd0cf11c2f834ada
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=mips

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

kernel/printk/printk.c: In function 'printk_sprint':
>> kernel/printk/printk.c:1913:9: warning: function 'printk_sprint' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
1913 | text_len = vscnprintf(text, size, fmt, args);
| ^~~~~~~~


vim +1913 kernel/printk/printk.c

b031a684bfd01d John Ogness 2020-12-09 1907
b031a684bfd01d John Ogness 2020-12-09 1908 static u16 printk_sprint(char *text, u16 size, int facility, enum log_flags *lflags,
b031a684bfd01d John Ogness 2020-12-09 1909 const char *fmt, va_list args)
b031a684bfd01d John Ogness 2020-12-09 1910 {
b031a684bfd01d John Ogness 2020-12-09 1911 u16 text_len;
b031a684bfd01d John Ogness 2020-12-09 1912
b031a684bfd01d John Ogness 2020-12-09 @1913 text_len = vscnprintf(text, size, fmt, args);
b031a684bfd01d John Ogness 2020-12-09 1914
b031a684bfd01d John Ogness 2020-12-09 1915 /* Mark and strip a trailing newline. */
b031a684bfd01d John Ogness 2020-12-09 1916 if (text_len && text[text_len - 1] == '\n') {
b031a684bfd01d John Ogness 2020-12-09 1917 text_len--;
b031a684bfd01d John Ogness 2020-12-09 1918 *lflags |= LOG_NEWLINE;
b031a684bfd01d John Ogness 2020-12-09 1919 }
b031a684bfd01d John Ogness 2020-12-09 1920
b031a684bfd01d John Ogness 2020-12-09 1921 /* Strip log level and control flags. */
b031a684bfd01d John Ogness 2020-12-09 1922 if (facility == 0) {
b031a684bfd01d John Ogness 2020-12-09 1923 u16 prefix_len;
b031a684bfd01d John Ogness 2020-12-09 1924
b031a684bfd01d John Ogness 2020-12-09 1925 prefix_len = parse_prefix(text, NULL, NULL);
b031a684bfd01d John Ogness 2020-12-09 1926 if (prefix_len) {
b031a684bfd01d John Ogness 2020-12-09 1927 text_len -= prefix_len;
b031a684bfd01d John Ogness 2020-12-09 1928 memmove(text, text + prefix_len, text_len);
b031a684bfd01d John Ogness 2020-12-09 1929 }
b031a684bfd01d John Ogness 2020-12-09 1930 }
b031a684bfd01d John Ogness 2020-12-09 1931
b031a684bfd01d John Ogness 2020-12-09 1932 return text_len;
b031a684bfd01d John Ogness 2020-12-09 1933 }
b031a684bfd01d John Ogness 2020-12-09 1934

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip