Skip to content

Commit 79fa295

Browse files
committed
net: selftests: use ethtool_sprintf()
During a W=1 build GCC 13.2 says: net/core/selftests.c: In function ‘net_selftest_get_strings’: net/core/selftests.c:404:52: error: ‘%s’ directive output may be truncated writing up to 279 bytes into a region of size 28 [-Werror=format-truncation=] 404 | snprintf(p, ETH_GSTRING_LEN, "%2d. %s", i + 1, | ^~ net/core/selftests.c:404:17: note: ‘snprintf’ output between 5 and 284 bytes into a destination of size 32 404 | snprintf(p, ETH_GSTRING_LEN, "%2d. %s", i + 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 405 | net_selftests[i].name); | ~~~~~~~~~~~~~~~~~~~~~~ avoid it by using ethtool_sprintf(). Reviewed-by: Oleksij Rempel <[email protected]> Tested-by: Oleksij Rempel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6808918 commit 79fa295

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

net/core/selftests.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,11 @@ EXPORT_SYMBOL_GPL(net_selftest_get_count);
397397

398398
void net_selftest_get_strings(u8 *data)
399399
{
400-
u8 *p = data;
401400
int i;
402401

403-
for (i = 0; i < net_selftest_get_count(); i++) {
404-
snprintf(p, ETH_GSTRING_LEN, "%2d. %s", i + 1,
405-
net_selftests[i].name);
406-
p += ETH_GSTRING_LEN;
407-
}
402+
for (i = 0; i < net_selftest_get_count(); i++)
403+
ethtool_sprintf(&data, "%2d. %s", i + 1,
404+
net_selftests[i].name);
408405
}
409406
EXPORT_SYMBOL_GPL(net_selftest_get_strings);
410407

0 commit comments

Comments
 (0)