drivers/scsi/elx/libefc/efc_node.c:254:70: warning: '%s' directive output may be truncated writing up to 15 bytes into a region of size between 0 and 31

From: kernel test robot
Date: Tue Feb 18 2025 - 07:29:57 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 2408a807bfc3f738850ef5ad5e3fd59d66168996
commit: ebc076b3eddc807729bd81f7bc48e798a3ddc477 scsi: elx: efct: Tie into kernel Kconfig and build process
date: 3 years, 8 months ago
config: x86_64-randconfig-001-20241126 (https://download.01.org/0day-ci/archive/20250218/202502182036.RChzXKS8-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250218/202502182036.RChzXKS8-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/202502182036.RChzXKS8-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/scsi/elx/libefc/efc_node.c: In function 'efc_node_alloc':
>> drivers/scsi/elx/libefc/efc_node.c:254:70: warning: '%s' directive output may be truncated writing up to 15 bytes into a region of size between 0 and 31 [-Wformat-truncation=]
254 | snprintf(node->display_name, sizeof(node->display_name), "%s.%s",
| ^~
255 | nport->display_name, portid_display);
| ~~~~~~~~~~~~~~
In function 'efc_node_update_display_name',
inlined from 'efc_node_alloc' at drivers/scsi/elx/libefc/efc_node.c:95:2:
drivers/scsi/elx/libefc/efc_node.c:254:9: note: 'snprintf' output between 2 and 48 bytes into a destination of size 32
254 | snprintf(node->display_name, sizeof(node->display_name), "%s.%s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
255 | nport->display_name, portid_display);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/elx/libefc/efc_node.c: In function 'efc_node_update_display_name':
>> drivers/scsi/elx/libefc/efc_node.c:254:70: warning: '%s' directive output may be truncated writing up to 15 bytes into a region of size between 0 and 31 [-Wformat-truncation=]
254 | snprintf(node->display_name, sizeof(node->display_name), "%s.%s",
| ^~
255 | nport->display_name, portid_display);
| ~~~~~~~~~~~~~~
drivers/scsi/elx/libefc/efc_node.c:254:9: note: 'snprintf' output between 2 and 48 bytes into a destination of size 32
254 | snprintf(node->display_name, sizeof(node->display_name), "%s.%s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
255 | nport->display_name, portid_display);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +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