diff options
author | Stephen Hemminger <shemminger@osdl.org> | 2007-01-11 15:36:10 -0800 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-09 16:32:06 -0500 |
commit | 7764430a139e4a089127f5616b0d56f497be1036 (patch) | |
tree | 428cfd6a2b0d23e9833fd3ba4dd87162af05a2ae /ethtool.c | |
parent | 5ab06db9d8777aef9307357b49d94cc267ba8105 (diff) | |
download | ethtool-7764430a139e4a089127f5616b0d56f497be1036.tar.gz |
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 <shemminger@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'ethtool.c')
-rw-r--r-- | ethtool.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -2023,12 +2023,10 @@ static int do_gstats(int fd, struct ifreq *ifr) /* 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); |