From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Subject: [RFC][PATCH iproute2-next 1/6] ipaddress: Unify print_link_stats() and print_link_stats64()
Date: Thu, 1 Feb 2018 21:40:53 +0200 [thread overview]
Message-ID: <1517514058-23596-2-git-send-email-serhe.popovych@gmail.com> (raw)
In-Reply-To: <1517514058-23596-1-git-send-email-serhe.popovych@gmail.com>
To show real differences between these two variants adjust
whitespace intendation and use print_uint() instead of
print_int() as all members in both @struct rtnl_link_stats
and @struct rtnl_link_stats64 are unsigned.
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
ip/ipaddress.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index b18b6f4..ae419f0 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -610,8 +610,7 @@ static void print_link_stats64(FILE *fp, const struct rtnl_link_stats64 *s,
print_uint(PRINT_JSON, "multicast", NULL, s->multicast);
if (s->rx_compressed)
print_uint(PRINT_JSON,
- "compressed",
- NULL, s->rx_compressed);
+ "compressed", NULL, s->rx_compressed);
/* RX error stats */
if (show_stats > 1) {
@@ -648,8 +647,7 @@ static void print_link_stats64(FILE *fp, const struct rtnl_link_stats64 *s,
print_uint(PRINT_JSON, "collisions", NULL, s->collisions);
if (s->tx_compressed)
print_uint(PRINT_JSON,
- "compressed",
- NULL, s->tx_compressed);
+ "compressed", NULL, s->tx_compressed);
/* TX error stats */
if (show_stats > 1) {
@@ -669,9 +667,9 @@ static void print_link_stats64(FILE *fp, const struct rtnl_link_stats64 *s,
print_uint(PRINT_JSON, "carrier_changes", NULL,
rta_getattr_u32(carrier_changes));
}
+
close_json_object();
close_json_object();
-
} else {
/* RX stats */
fprintf(fp, " RX: bytes packets errors dropped overrun mcast %s%s",
@@ -692,7 +690,6 @@ static void print_link_stats64(FILE *fp, const struct rtnl_link_stats64 *s,
fprintf(fp, "%s", _SL_);
fprintf(fp, " RX errors: length crc frame fifo missed%s%s",
s->rx_nohandler ? " nohandler" : "", _SL_);
-
fprintf(fp, " ");
print_num(fp, 8, s->rx_length_errors);
print_num(fp, 7, s->rx_crc_errors);
@@ -701,7 +698,6 @@ static void print_link_stats64(FILE *fp, const struct rtnl_link_stats64 *s,
print_num(fp, 7, s->rx_missed_errors);
if (s->rx_nohandler)
print_num(fp, 7, s->rx_nohandler);
-
}
fprintf(fp, "%s", _SL_);
@@ -754,9 +750,8 @@ static void print_link_stats32(FILE *fp, const struct rtnl_link_stats *s,
print_uint(PRINT_JSON, "over_errors", NULL, s->rx_over_errors);
print_uint(PRINT_JSON, "multicast", NULL, s->multicast);
if (s->rx_compressed)
- print_int(PRINT_JSON,
- "compressed",
- NULL, s->rx_compressed);
+ print_uint(PRINT_JSON,
+ "compressed", NULL, s->rx_compressed);
/* RX error stats */
if (show_stats > 1) {
@@ -776,9 +771,8 @@ static void print_link_stats32(FILE *fp, const struct rtnl_link_stats *s,
"missed_errors",
NULL, s->rx_missed_errors);
if (s->rx_nohandler)
- print_int(PRINT_JSON,
- "nohandler",
- NULL, s->rx_nohandler);
+ print_uint(PRINT_JSON,
+ "nohandler", NULL, s->rx_nohandler);
}
close_json_object();
@@ -793,9 +787,8 @@ static void print_link_stats32(FILE *fp, const struct rtnl_link_stats *s,
NULL, s->tx_carrier_errors);
print_uint(PRINT_JSON, "collisions", NULL, s->collisions);
if (s->tx_compressed)
- print_int(PRINT_JSON,
- "compressed",
- NULL, s->tx_compressed);
+ print_uint(PRINT_JSON,
+ "compressed", NULL, s->tx_compressed);
/* TX error stats */
if (show_stats > 1) {
@@ -812,9 +805,7 @@ static void print_link_stats32(FILE *fp, const struct rtnl_link_stats *s,
"heartbeat_errors",
NULL, s->tx_heartbeat_errors);
if (carrier_changes)
- print_uint(PRINT_JSON,
- "carrier_changes",
- NULL,
+ print_uint(PRINT_JSON, "carrier_changes", NULL,
rta_getattr_u32(carrier_changes));
}
@@ -825,7 +816,6 @@ static void print_link_stats32(FILE *fp, const struct rtnl_link_stats *s,
fprintf(fp, " RX: bytes packets errors dropped overrun mcast %s%s",
s->rx_compressed ? "compressed" : "", _SL_);
-
fprintf(fp, " ");
print_num(fp, 10, s->rx_bytes);
print_num(fp, 8, s->rx_packets);
--
1.7.10.4
next prev parent reply other threads:[~2018-02-01 19:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-01 19:40 [RFC][PATCH iproute2-next 0/6] ip: Use netlink to walk through network device list Serhey Popovych
2018-02-01 19:40 ` Serhey Popovych [this message]
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 2/6] ip: Introduce get_rtnl_link_stats_rta() to get link statistics Serhey Popovych
2018-02-01 23:32 ` Stephen Hemminger
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 3/6] tunnel: Split statistic getting and printing Serhey Popovych
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 4/6] iptunnel/ip6tunnel: Code cleanups Serhey Popovych
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 5/6] iptunnel/ip6tunnel: Use netlink to walk through tunnels list Serhey Popovych
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 6/6] tuntap: Use netlink to walk through tuntap list Serhey Popovych
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=1517514058-23596-2-git-send-email-serhe.popovych@gmail.com \
--to=serhe.popovych@gmail.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).