drivers/scsi/elx/libefc/efc_node.c:254:65: warning: 'snprintf' output may be truncated before the last format character

From: kernel test robot
Date: Thu Nov 30 2023 - 12:11:18 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3b47bc037bd44f142ac09848e8d3ecccc726be99
commit: ebc076b3eddc807729bd81f7bc48e798a3ddc477 scsi: elx: efct: Tie into kernel Kconfig and build process
date: 2 years, 6 months ago
config: x86_64-randconfig-014-20230906 (https://download.01.org/0day-ci/archive/20231201/202312010138.o5on1HtR-lkp@xxxxxxxxx/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231201/202312010138.o5on1HtR-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312010138.o5on1HtR-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/scsi/elx/libefc/efc_node.c: In function 'efc_node_update_display_name':
>> drivers/scsi/elx/libefc/efc_node.c:254:65: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
snprintf(node->display_name, sizeof(node->display_name), "%s.%s",
^
drivers/scsi/elx/libefc/efc_node.c:254:2: note: 'snprintf' output 2 or more bytes (assuming 33) into a destination of size 32
snprintf(node->display_name, sizeof(node->display_name), "%s.%s",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nport->display_name, portid_display);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/snprintf +254 drivers/scsi/elx/libefc/efc_node.c

6bc6180d7b5c97 James Smart 2021-06-01 244
6bc6180d7b5c97 James Smart 2021-06-01 245 void
6bc6180d7b5c97 James Smart 2021-06-01 246 efc_node_update_display_name(struct efc_node *node)
6bc6180d7b5c97 James Smart 2021-06-01 247 {
6bc6180d7b5c97 James Smart 2021-06-01 248 u32 port_id = node->rnode.fc_id;
6bc6180d7b5c97 James Smart 2021-06-01 249 struct efc_nport *nport = node->nport;
6bc6180d7b5c97 James Smart 2021-06-01 250 char portid_display[16];
6bc6180d7b5c97 James Smart 2021-06-01 251
6bc6180d7b5c97 James Smart 2021-06-01 252 efc_node_fcid_display(port_id, portid_display, sizeof(portid_display));
6bc6180d7b5c97 James Smart 2021-06-01 253
6bc6180d7b5c97 James Smart 2021-06-01 @254 snprintf(node->display_name, sizeof(node->display_name), "%s.%s",
6bc6180d7b5c97 James Smart 2021-06-01 255 nport->display_name, portid_display);
6bc6180d7b5c97 James Smart 2021-06-01 256 }
6bc6180d7b5c97 James Smart 2021-06-01 257

:::::: The code at line 254 was first introduced by commit
:::::: 6bc6180d7b5c972c10a2f5392621921de32ce5bc scsi: elx: libefc: Remote node state machine interfaces

:::::: TO: James Smart <jsmart2021@xxxxxxxxx>
:::::: CC: Martin K. Petersen <martin.petersen@xxxxxxxxxx>

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