drivers/net/ethernet/sfc/ethtool_common.c:170:32: warning: '%-24s' directive output may be truncated writing between 24 and 31 bytes into a region of size between 0 and 25

From: kernel test robot
Date: Wed Oct 18 2023 - 15:42:24 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: dd72f9c7e512da377074d47d990564959b772643
commit: 3653954da498fc80c5da3642ae3f8d8168d7f820 sfc: move some ethtool code
date: 3 years, 9 months ago
config: sparc64-allyesconfig (https://download.01.org/0day-ci/archive/20231019/202310190356.CiGFsxM8-lkp@xxxxxxxxx/config)
compiler: sparc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231019/202310190356.CiGFsxM8-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/202310190356.CiGFsxM8-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/net/ethernet/sfc/ethtool_common.c:150:6: warning: no previous prototype for 'efx_fill_test' [-Wmissing-prototypes]
150 | void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
| ^~~~~~~~~~~~~
drivers/net/ethernet/sfc/ethtool_common.c:192:5: warning: no previous prototype for 'efx_fill_loopback_test' [-Wmissing-prototypes]
192 | int efx_fill_loopback_test(struct efx_nic *efx,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/sfc/ethtool_common.c:296:8: warning: no previous prototype for 'efx_describe_per_queue_stats' [-Wmissing-prototypes]
296 | size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/sfc/ethtool_common.c: In function 'efx_fill_test':
>> drivers/net/ethernet/sfc/ethtool_common.c:170:32: warning: '%-24s' directive output may be truncated writing between 24 and 31 bytes into a region of size between 0 and 25 [-Wformat-truncation=]
170 | "%-6s %-24s", unit_str, test_str);
| ^~~~~ ~~~~~~~~
drivers/net/ethernet/sfc/ethtool_common.c:168:17: note: 'snprintf' output between 32 and 64 bytes into a destination of size 32
168 | snprintf(strings + test_index * ETH_GSTRING_LEN,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
169 | ETH_GSTRING_LEN,
| ~~~~~~~~~~~~~~~~
170 | "%-6s %-24s", unit_str, test_str);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +170 drivers/net/ethernet/sfc/ethtool_common.c

136
137 /**
138 * efx_fill_test - fill in an individual self-test entry
139 * @test_index: Index of the test
140 * @strings: Ethtool strings, or %NULL
141 * @data: Ethtool test results, or %NULL
142 * @test: Pointer to test result (used only if data != %NULL)
143 * @unit_format: Unit name format (e.g. "chan\%d")
144 * @unit_id: Unit id (e.g. 0 for "chan0")
145 * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
146 * @test_id: Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
147 *
148 * Fill in an individual self-test entry.
149 */
150 void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
151 int *test, const char *unit_format, int unit_id,
152 const char *test_format, const char *test_id)
153 {
154 char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
155
156 /* Fill data value, if applicable */
157 if (data)
158 data[test_index] = *test;
159
160 /* Fill string, if applicable */
161 if (strings) {
162 if (strchr(unit_format, '%'))
163 snprintf(unit_str, sizeof(unit_str),
164 unit_format, unit_id);
165 else
166 strcpy(unit_str, unit_format);
167 snprintf(test_str, sizeof(test_str), test_format, test_id);
168 snprintf(strings + test_index * ETH_GSTRING_LEN,
169 ETH_GSTRING_LEN,
> 170 "%-6s %-24s", unit_str, test_str);
171 }
172 }
173

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