net: selftests: use ethtool_sprintf()
authorJakub Kicinski <kuba@kernel.org>
Thu, 26 Oct 2023 02:29:16 +0000 (19:29 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 27 Oct 2023 15:09:26 +0000 (08:09 -0700)
commit79fa29570bd340d5cb6229f047f2b9127dbff32c
tree1866c5cb0337521de8fd55090500fb5bd6a7581a
parent6808918343a8b4b6970ba52ba2d1d511a0976748
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 <o.rempel@pengutronix.de>
Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/r/20231026022916.566661-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/selftests.c