diff mbox

[v2,1/2] tipc: tipc_bcbearer_send(): simplify bearer selection

Message ID 1367244820-29881-1-git-send-email-gerlando.falauto@keymile.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Gerlando Falauto April 29, 2013, 2:13 p.m. UTC
Also some minor cosmetic improvements and comment style changes

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
---
 net/tipc/bcast.c |   29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

Comments

David Miller April 29, 2013, 7:44 p.m. UTC | #1
From: Gerlando Falauto <gerlando.falauto@keymile.com>
Date: Mon, 29 Apr 2013 16:13:39 +0200

> Also some minor cosmetic improvements and comment style changes
> 
> Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>

You're mixing too many things, and actually adding style problems.

>  		struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary;
> +		struct tipc_bearer *b = p;
>  		struct tipc_bearer *s = bcbearer->bpairs[bp_index].secondary;

Local variable declarations should be ordered from longest line
to shortest line.

> -		tipc_nmap_diff(&bcbearer->remains, &p->nodes, &bcbearer->remains_new);
> +		tipc_nmap_diff(&bcbearer->remains, &b->nodes,
> +			&bcbearer->remains_new);

This second line is indented incorrectly, do it like this:

	func(arg1, arg2,
	     arg3, arg4);

Specifically arg3 is aligned, using the appropriate mixture of TAB
and space characters, with the first column after the openning
parenthesis of the func() call.

>  		if (bcbearer->remains_new.count == bcbearer->remains.count)
> -			continue;	/* bearer pair doesn't add anything */
> +			continue;  /* Nothing added by bearer pair */

Why is two spaces better than a TAB, make it one space if you're going
to change this.

>  		if (bcbearer->remains_new.count == 0)
> -			break;	/* all targets reached */
> +			break;	/* All targets reached */

Untab this gap between break; and the comment into a space too.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 2655c9f..be1f945 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -584,8 +584,7 @@  static int tipc_bcbearer_send(struct sk_buff *buf,
 {
 	int bp_index;
 
-	/*
-	 * Prepare broadcast link message for reliable transmission,
+	/* Prepare broadcast link message for reliable transmission,
 	 * if first time trying to send it;
 	 * preparation is skipped for broadcast link protocol messages
 	 * since they are sent in an unreliable manner and don't need it
@@ -610,31 +609,33 @@  static int tipc_bcbearer_send(struct sk_buff *buf,
 
 	for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) {
 		struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary;
+		struct tipc_bearer *b = p;
 		struct tipc_bearer *s = bcbearer->bpairs[bp_index].secondary;
 
 		if (!p)
-			break;	/* no more bearers to try */
+			break;	/* No more bearers to try */
+
+		if (tipc_bearer_blocked(p)) {
+			if (!s || tipc_bearer_blocked(s))
+				continue; /* Can't use either bearer */
+			b = s;
+		}
 
-		tipc_nmap_diff(&bcbearer->remains, &p->nodes, &bcbearer->remains_new);
+		tipc_nmap_diff(&bcbearer->remains, &b->nodes,
+			&bcbearer->remains_new);
 		if (bcbearer->remains_new.count == bcbearer->remains.count)
-			continue;	/* bearer pair doesn't add anything */
+			continue;  /* Nothing added by bearer pair */
 
-		if (!tipc_bearer_blocked(p))
-			tipc_bearer_send(p, buf, &p->media->bcast_addr);
-		else if (s && !tipc_bearer_blocked(s))
-			/* unable to send on primary bearer */
-			tipc_bearer_send(s, buf, &s->media->bcast_addr);
-		else
-			/* unable to send on either bearer */
-			continue;
+		tipc_bearer_send(b, buf, &s->media->bcast_addr);
 
+		/* Swap bearers for next packet */
 		if (s) {
 			bcbearer->bpairs[bp_index].primary = s;
 			bcbearer->bpairs[bp_index].secondary = p;
 		}
 
 		if (bcbearer->remains_new.count == 0)
-			break;	/* all targets reached */
+			break;	/* All targets reached */
 
 		bcbearer->remains = bcbearer->remains_new;
 	}