Thread (23 messages) flat view 23 messages, 5 authors, 2016-06-22

RE: [iproute PATCH v2 7/7] ip/tcp_metrics: Simplify process_msg a bit

From: David Laight <hidden>
Date: 2016-06-21 16:31:40

From: Of Phil Sutter
quoted hunk ↗ jump to hunk
Sent: 21 June 2016 17:19
By combining the attribute extraction and check for existence, the
additional indentation level in the 'else' clause can be avoided.

In addition to that, common actions for 'daddr' are combined since the
function returns if neither of the branches are taken.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 ip/tcp_metrics.c | 45 ++++++++++++++++++---------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)
diff --git a/ip/tcp_metrics.c b/ip/tcp_metrics.c
index f82604f458ada..899830c127bcb 100644
--- a/ip/tcp_metrics.c
+++ b/ip/tcp_metrics.c
@@ -112,47 +112,38 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
 	parse_rtattr(attrs, TCP_METRICS_ATTR_MAX, (void *) ghdr + GENL_HDRLEN,
 		     len);

-	a = attrs[TCP_METRICS_ATTR_ADDR_IPV4];
-	if (a) {
+	if ((a = attrs[TCP_METRICS_ATTR_ADDR_IPV4])) {
horrid
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help