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(-)

diff --git a/ethtool.c b/ethtool.c
index 6e68009..0a50144 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -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);
-- 
1.4.1


-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to