drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c:841:52: warning: '%s' directive output may be truncated writing up to 431 bytes into a region of size 28

From: kernel test robot
Date: Sat Jan 11 2025 - 20:12:43 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: b62cef9a5c673f1b8083159f5dc03c1c5daced2f
commit: 091810dbded96c2af81f645e386e4262553e3493 net: stmmac: Introduce selftests support
date: 6 years ago
config: x86_64-rhel-8.3-kunit (https://download.01.org/0day-ci/archive/20250112/202501120912.Z88mEJSU-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/20250112/202501120912.Z88mEJSU-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/202501120912.Z88mEJSU-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c: In function 'stmmac_selftest_get_strings':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c:841:52: warning: '%s' directive output may be truncated writing up to 431 bytes into a region of size 28 [-Wformat-truncation=]
841 | snprintf(p, ETH_GSTRING_LEN, "%2d. %s", i + 1,
| ^~
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c:841:17: note: 'snprintf' output between 5 and 436 bytes into a destination of size 32
841 | snprintf(p, ETH_GSTRING_LEN, "%2d. %s", i + 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
842 | stmmac_selftests[i].name);
| ~~~~~~~~~~~~~~~~~~~~~~~~~


vim +841 drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c

834
835 void stmmac_selftest_get_strings(struct stmmac_priv *priv, u8 *data)
836 {
837 u8 *p = data;
838 int i;
839
840 for (i = 0; i < stmmac_selftest_get_count(priv); i++) {
> 841 snprintf(p, ETH_GSTRING_LEN, "%2d. %s", i + 1,
842 stmmac_selftests[i].name);
843 p += ETH_GSTRING_LEN;
844 }
845 }
846

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