lkml.org 
[lkml]   [2021]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectkernel/bpf/btf.c:5346:29: warning: function 'btf_seq_show' might be a candidate for 'gnu_printf' format attribute
Hi Alan,

FYI, the error/warning still remains.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: a90af8f15bdc9449ee2d24e1d73fa3f7e8633f81
commit: 31d0bc81637d8d974a6dad9827b765b4b70c89d7 bpf: Move to generic BTF show support, apply it to seq files/strings
date: 1 year, 2 months ago
config: nds32-buildonly-randconfig-r002-20210927 (attached as .config)
compiler: nds32le-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=31d0bc81637d8d974a6dad9827b765b4b70c89d7
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 31d0bc81637d8d974a6dad9827b765b4b70c89d7
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=nds32

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

All warnings (new ones prefixed by >>):

kernel/bpf/btf.c: In function 'btf_seq_show':
>> kernel/bpf/btf.c:5346:29: warning: function 'btf_seq_show' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
5346 | seq_vprintf((struct seq_file *)show->target, fmt, args);
| ^~~~~~~~
kernel/bpf/btf.c: In function 'btf_snprintf_show':
>> kernel/bpf/btf.c:5383:9: warning: function 'btf_snprintf_show' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
5383 | len = vsnprintf(show->target, ssnprintf->len_left, fmt, args);
| ^~~


vim +5346 kernel/bpf/btf.c

5342
5343 static void btf_seq_show(struct btf_show *show, const char *fmt,
5344 va_list args)
5345 {
> 5346 seq_vprintf((struct seq_file *)show->target, fmt, args);
5347 }
5348
5349 static int btf_type_seq_show_flags(const struct btf *btf, u32 type_id,
5350 void *obj, struct seq_file *m, u64 flags)
5351 {
5352 struct btf_show sseq;
5353
5354 sseq.target = m;
5355 sseq.showfn = btf_seq_show;
5356 sseq.flags = flags;
5357
5358 btf_type_show(btf, type_id, obj, &sseq);
5359
5360 return sseq.state.status;
5361 }
5362
5363 void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj,
5364 struct seq_file *m)
5365 {
5366 (void) btf_type_seq_show_flags(btf, type_id, obj, m,
5367 BTF_SHOW_NONAME | BTF_SHOW_COMPACT |
5368 BTF_SHOW_ZERO | BTF_SHOW_UNSAFE);
5369 }
5370
5371 struct btf_show_snprintf {
5372 struct btf_show show;
5373 int len_left; /* space left in string */
5374 int len; /* length we would have written */
5375 };
5376
5377 static void btf_snprintf_show(struct btf_show *show, const char *fmt,
5378 va_list args)
5379 {
5380 struct btf_show_snprintf *ssnprintf = (struct btf_show_snprintf *)show;
5381 int len;
5382
> 5383 len = vsnprintf(show->target, ssnprintf->len_left, fmt, args);
5384
5385 if (len < 0) {
5386 ssnprintf->len_left = 0;
5387 ssnprintf->len = len;
5388 } else if (len > ssnprintf->len_left) {
5389 /* no space, drive on to get length we would have written */
5390 ssnprintf->len_left = 0;
5391 ssnprintf->len += len;
5392 } else {
5393 ssnprintf->len_left -= len;
5394 ssnprintf->len += len;
5395 show->target += len;
5396 }
5397 }
5398

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[unhandled content-type:application/gzip]
\
 
 \ /
  Last update: 2021-11-20 07:05    [W:0.732 / U:0.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site