drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:125:50: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8

From: kernel test robot
Date: Thu Nov 02 2023 - 20:46:31 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4652b8e4f3ffa48c706ec334f048c217a7d9750d
commit: 353d5c241e83c4de04ca5ec0d7922bfb0809aa25 dmaengine: dw-edma: Add HDMA DebugFS support
date: 5 months ago
config: parisc-randconfig-001-20231102 (https://download.01.org/0day-ci/archive/20231103/202311030809.CjufIFaP-lkp@xxxxxxxxx/config)
compiler: hppa-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231103/202311030809.CjufIFaP-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/202311030809.CjufIFaP-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/dma/dw-edma/dw-hdma-v0-debugfs.c: In function 'dw_hdma_v0_debugfs_on':
>> drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:125:50: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
125 | snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
| ^~
In function 'dw_hdma_debugfs_regs_wr',
inlined from 'dw_hdma_debugfs_regs' at drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:156:2,
inlined from 'dw_hdma_v0_debugfs_on' at drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:169:2:
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:125:46: note: directive argument in the range [-2147483641, 65534]
125 | snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
| ^~~~~~~
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:125:17: note: 'snprintf' output between 10 and 20 bytes into a destination of size 16
125 | snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c: In function 'dw_hdma_v0_debugfs_on':
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:142:50: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
142 | snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
| ^~
In function 'dw_hdma_debugfs_regs_rd',
inlined from 'dw_hdma_debugfs_regs' at drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:157:2,
inlined from 'dw_hdma_v0_debugfs_on' at drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:169:2:
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:142:46: note: directive argument in the range [-2147483641, 65534]
142 | snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
| ^~~~~~~
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c:142:17: note: 'snprintf' output between 10 and 20 bytes into a destination of size 16
142 | snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +125 drivers/dma/dw-edma/dw-hdma-v0-debugfs.c

115
116 static void dw_hdma_debugfs_regs_wr(struct dw_edma *dw, struct dentry *dent)
117 {
118 struct dentry *regs_dent, *ch_dent;
119 char name[16];
120 int i;
121
122 regs_dent = debugfs_create_dir(WRITE_STR, dent);
123
124 for (i = 0; i < dw->wr_ch_cnt; i++) {
> 125 snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
126
127 ch_dent = debugfs_create_dir(name, regs_dent);
128
129 dw_hdma_debugfs_regs_ch(dw, EDMA_DIR_WRITE, i, ch_dent);
130 }
131 }
132

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