ethtool: fix long statistics name
Subsystems (2)
PATCH 1/1 ethtool: fix long statistics name
Fix handling of statistics where the label is exactly 32 (ETH_GSTRING_LEN) characters long (observed with chelsio 10G driver).
Before it would print garbage because of going by end
of string. Don't need to copy string, just use formats properly.
Signed-off-by Stephen Hemminger <[email protected]>
--- ethtool.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-)
ethtool.c +4 -6
@@ -1989,12 +1989,10 @@ static int do_gstats(int fd, struct ifre/* todo - pretty-print the strings per-driver */ fprintf (stdout,"NIC statistics:\n" );for (i =0 ; i < n_stats; i++) { -char s[ETH_GSTRING_LEN ]; - -strncpy (s, (const char *) &strings->data[i *ETH_GSTRING_LEN ], -ETH_GSTRING_LEN ); -fprintf (stdout," %s: %llu\n" , - s, stats->data[i]); +fprintf (stdout," %.*s: %llu\n" , +ETH_GSTRING_LEN , + &strings->data[i *ETH_GSTRING_LEN ], + stats->data[i]); }free (strings);free (stats);
Signature · 1 line
1.4.1
Jeff Garzik
AppliedQuoted 8 lines · Stephen Hemminger
Fix handling of statistics where the label is exactly 32 (
ETH_GSTRING_LEN)
characters long (observed with chelsio 10G driver). Before it would print garbage because of going by end of string. Don't need to copy string, just use formats properly.Signed-off-by Stephen Hemminger <[email protected]>--- ethtool.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-)
applied