From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Subject: [PATCH iproute2-next v2 1/6] ipaddress: Unify print_link_stats() and print_link_stats64()
Date: Wed, 7 Feb 2018 08:30:51 +0200 [thread overview]
Message-ID: <1517985056-10043-2-git-send-email-serhe.popovych@gmail.com> (raw)
In-Reply-To: <1517985056-10043-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 4707c2b..a80a385 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -609,8 +609,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) {
@@ -647,8 +646,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) {
@@ -668,9 +666,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",
@@ -691,7 +689,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);
@@ -700,7 +697,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_);
@@ -753,9 +749,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) {
@@ -775,9 +770,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();
@@ -792,9 +786,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) {
@@ -811,9 +804,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));
}
@@ -824,7 +815,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-07 6:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 6:30 [PATCH iproute2-next v2 0/6] ip: Use netlink to walk through network device list Serhey Popovych
2018-02-07 6:30 ` Serhey Popovych [this message]
2018-02-07 6:30 ` [PATCH iproute2-next v2 2/6] ip: Introduce get_rtnl_link_stats_rta() to get link statistics Serhey Popovych
2018-02-07 6:30 ` [PATCH iproute2-next v2 3/6] tunnel: Split statistic getting and printing Serhey Popovych
2018-02-07 6:30 ` [PATCH iproute2-next v2 4/6] iptunnel/ip6tunnel: Code cleanups Serhey Popovych
2018-02-07 6:30 ` [PATCH iproute2-next v2 5/6] iptunnel/ip6tunnel: Use netlink to walk through tunnels list Serhey Popovych
2018-02-07 6:30 ` [PATCH iproute2-next v2 6/6] tuntap: Use netlink to walk through tuntap list Serhey Popovych
2018-02-08 0:20 ` [PATCH iproute2-next v2 0/6] ip: Use netlink to walk through network device list David Ahern
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=1517985056-10043-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).