arch/powerpc/platforms/ps3/setup.c:229:24: warning: '%u' directive output may be truncated writing between 1 and 5 bytes into a region of size between 4 and 12

From: kernel test robot
Date: Sun Dec 03 2023 - 01:07:53 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 815fb87b753055df2d9e50f6cd80eb10235fe3e9
commit: 07e2d6cf91079ca01db7fb989a02edd8009dcacd powerpc/ps3: Add firmware version to sysfs
date: 2 years, 6 months ago
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20231202/202312021810.bCVHtweA-lkp@xxxxxxxxx/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231202/202312021810.bCVHtweA-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/202312021810.bCVHtweA-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

arch/powerpc/platforms/ps3/setup.c: In function 'ps3_setup_arch':
>> arch/powerpc/platforms/ps3/setup.c:229:24: warning: '%u' directive output may be truncated writing between 1 and 5 bytes into a region of size between 4 and 12 [-Wformat-truncation=]
229 | "%u.%u.%u", ps3_firmware_version.major,
| ^~
arch/powerpc/platforms/ps3/setup.c:229:17: note: directive argument in the range [0, 65535]
229 | "%u.%u.%u", ps3_firmware_version.major,
| ^~~~~~~~~~
arch/powerpc/platforms/ps3/setup.c:228:9: note: 'snprintf' output between 6 and 18 bytes into a destination of size 16
228 | snprintf(ps3_firmware_version_str, sizeof(ps3_firmware_version_str),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
229 | "%u.%u.%u", ps3_firmware_version.major,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
230 | ps3_firmware_version.minor, ps3_firmware_version.rev);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +229 arch/powerpc/platforms/ps3/setup.c

219
220 static void __init ps3_setup_arch(void)
221 {
222 u64 tmp;
223
224 DBG(" -> %s:%d\n", __func__, __LINE__);
225
226 lv1_get_version_info(&ps3_firmware_version.raw, &tmp);
227
228 snprintf(ps3_firmware_version_str, sizeof(ps3_firmware_version_str),
> 229 "%u.%u.%u", ps3_firmware_version.major,
230 ps3_firmware_version.minor, ps3_firmware_version.rev);
231
232 printk(KERN_INFO "PS3 firmware version %s\n", ps3_firmware_version_str);
233
234 ps3_spu_set_platform();
235

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