netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH] ethtool: fix long statistics name
Date: Thu, 11 Jan 2007 15:36:10 -0800	[thread overview]
Message-ID: <20070111153610.36d0f39a@freekitty> (raw)

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



             reply	other threads:[~2007-01-11 23:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-11 23:36 Stephen Hemminger [this message]
2007-02-09 21:32 ` [PATCH] ethtool: fix long statistics name Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070111153610.36d0f39a@freekitty \
    --to=shemminger@osdl.org \
    --cc=jgarzik@pobox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).