[ogabbay:habanalabs-next 1/3] drivers/misc/habanalabs/common/debugfs.c:599:9: warning: function 'hl_engine_data_sprintf' might be a candidate for 'gnu_printf' format attribute

From: kernel test robot
Date: Thu Jul 14 2022 - 12:32:58 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux.git habanalabs-next
head: 0339d759da283025aa01ba72cb7e5b6df9978670
commit: b916f64dace37d374de75823a203749caf30fd7c [1/3] habanalabs: removed seq_file parameter from is_idle asic functions
config: i386-randconfig-a001 (https://download.01.org/0day-ci/archive/20220715/202207150057.RUJOxIhW-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux.git/commit/?id=b916f64dace37d374de75823a203749caf30fd7c
git remote add ogabbay https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux.git
git fetch --no-tags ogabbay habanalabs-next
git checkout b916f64dace37d374de75823a203749caf30fd7c
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/misc/

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

All warnings (new ones prefixed by >>):

drivers/misc/habanalabs/common/debugfs.c: In function 'hl_engine_data_sprintf':
>> drivers/misc/habanalabs/common/debugfs.c:599:9: warning: function 'hl_engine_data_sprintf' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
599 | str_size = vsnprintf(NULL, 0, fmt, args) + 1;
| ^~~~~~~~
drivers/misc/habanalabs/common/debugfs.c:604:17: warning: function 'hl_engine_data_sprintf' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
604 | vsnprintf(e->buf + e->actual_size, str_size, fmt, args);
| ^~~~~~~~~


vim +599 drivers/misc/habanalabs/common/debugfs.c

589
590 void hl_engine_data_sprintf(struct engines_data *e, const char *fmt, ...)
591 {
592 va_list args;
593 int str_size;
594
595 va_start(args, fmt);
596 /* Calculate formatted string length. Assuming each string is null terminated, hence
597 * increment result by 1
598 */
> 599 str_size = vsnprintf(NULL, 0, fmt, args) + 1;
600 va_end(args);
601
602 if ((e->actual_size + str_size) < e->allocated_buf_size) {
603 va_start(args, fmt);
604 vsnprintf(e->buf + e->actual_size, str_size, fmt, args);
605 va_end(args);
606 }
607
608 /* Need to update the size even when not updating destination buffer to get the exact size
609 * of all input strings
610 */
611 e->actual_size += str_size;
612

--
0-DAY CI Kernel Test Service
https://01.org/lkp