drivers/misc/pci_endpoint_test.c:38:41: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 2

From: kernel test robot
Date: Sat Nov 18 2023 - 08:44:00 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 791c8ab095f71327899023223940dd52257a4173
commit: 2c156ac71c6b2518f3d589190f2a8872a8764faf misc: Add host side PCI driver for PCI test function device
date: 7 years ago
config: x86_64-buildonly-randconfig-001-20231012 (https://download.01.org/0day-ci/archive/20231118/202311182130.6duKTiLv-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/20231118/202311182130.6duKTiLv-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/202311182130.6duKTiLv-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/misc/pci_endpoint_test.c: In function 'pci_endpoint_test_probe':
>> drivers/misc/pci_endpoint_test.c:38:41: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=]
38 | #define DRV_MODULE_NAME "pci-endpoint-test"
| ^~~~~~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:463:38: note: in expansion of macro 'DRV_MODULE_NAME'
463 | snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
| ^~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:503:57: note: format string is defined here
503 | if (sscanf(misc_device->name, DRV_MODULE_NAME ".%d", &id) != 1)
| ^~
drivers/misc/pci_endpoint_test.c:38:41: note: directive argument in the range [0, 2147483647]
38 | #define DRV_MODULE_NAME "pci-endpoint-test"
| ^~~~~~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:463:38: note: in expansion of macro 'DRV_MODULE_NAME'
463 | snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
| ^~~~~~~~~~~~~~~
drivers/misc/pci_endpoint_test.c:463:9: note: 'snprintf' output between 20 and 29 bytes into a destination of size 20
463 | snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +38 drivers/misc/pci_endpoint_test.c

37
> 38 #define DRV_MODULE_NAME "pci-endpoint-test"
39

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