* [PATCH] ethtool: fix long statistics name
@ 2007-01-11 23:36 Stephen Hemminger
2007-02-09 21:32 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2007-01-11 23:36 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ethtool: fix long statistics name
2007-01-11 23:36 [PATCH] ethtool: fix long statistics name Stephen Hemminger
@ 2007-02-09 21:32 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2007-02-09 21:32 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, netdev
Stephen Hemminger wrote:
> 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(-)
applied
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-02-09 21:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-11 23:36 [PATCH] ethtool: fix long statistics name Stephen Hemminger
2007-02-09 21:32 ` Jeff Garzik
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).