netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Bofjäll" <andreas.bofjall@ericsson.com>
To: Erik Hugne <erik.hugne@ericsson.com>,
	David Laight <David.Laight@ACULAB.COM>
Cc: jon.maloy@ericsson.com, netdev@vger.kernel.org,
	tipc-discussion@lists.sourceforge.net, davem@davemloft.net,
	Paul.Gortmaker@windriver.com
Subject: Re: [PATCH net-next] tipc: remove two indentation levels in tipc_recv_msg routine
Date: Tue, 29 Oct 2013 13:40:09 +0100	[thread overview]
Message-ID: <526FACA9.9020004@ericsson.com> (raw)
In-Reply-To: <20131029120708.GI14038@eerihug-hybrid.rnd.ki.sw.ericsson.se>

On 10/29/2013 01:07 PM, Erik Hugne wrote:
> On Tue, Oct 29, 2013 at 11:13:09AM +0000, David Laight wrote:
>> I can only see one 'goto cont', an explicit kfree_skb() and
>> continue would be clearer.
>
> There's actually a few more 'goto cont' in the early error checks
> in this function causes it to bail early. Those are not visible
> in the patchdiff however.

If you wanted to make this a bit simpler, you could make two labels and 
move the calls to tipc_node_unlock(n_ptr). The blocks on lines 1545, 
1558 and 1614 (in the patched code) could be replaced by a simple "goto 
unlock" this way.

--- link.c-old	2013-10-29 13:34:35.804926348 +0100
+++ link.c	2013-10-29 13:39:23.991842809 +0100
@@ -1541,10 +1541,8 @@

  		/* Locate unicast link endpoint that should handle message */
  		l_ptr = n_ptr->links[b_ptr->identity];
-		if (unlikely(!l_ptr)) {
-			tipc_node_unlock(n_ptr);
-			goto cont;
-		}
+		if (unlikely(!l_ptr))
+			goto unlock;

  		/* Verify that communication with node is currently allowed */
  		if ((n_ptr->block_setup & WAIT_PEER_DOWN) &&
@@ -1554,10 +1552,8 @@
  			!msg_redundant_link(msg))
  			n_ptr->block_setup &= ~WAIT_PEER_DOWN;

-		if (n_ptr->block_setup) {
-			tipc_node_unlock(n_ptr);
-			goto cont;
-		}
+		if (n_ptr->block_setup)
+			goto unlock;

  		/* Validate message sequence number info */
  		seq_no = msg_seqno(msg);
@@ -1611,8 +1607,7 @@
  				tipc_node_unlock(n_ptr);
  				continue;
  			}
-			tipc_node_unlock(n_ptr);
-			goto cont;
+			goto unlock;
  		}

  		/* Link is now in state WORKING_WORKING */
@@ -1681,6 +1676,9 @@
  		tipc_node_unlock(n_ptr);
  		tipc_net_route_msg(buf);
  		continue;
+
+unlock:
+		tipc_node_unlock(n_ptr);
  cont:
  		kfree_skb(buf);
  	}

/Andreas

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk

  reply	other threads:[~2013-10-29 12:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-29 11:01 [PATCH net-next] tipc: remove two indentation levels in tipc_recv_msg routine Ying Xue
2013-10-29 11:13 ` David Laight
2013-10-29 12:07   ` Erik Hugne
2013-10-29 12:40     ` Andreas Bofjäll [this message]
2013-10-29 12:42       ` [tipc-discussion] " David Laight
2013-10-30  1:34         ` Ying Xue

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=526FACA9.9020004@ericsson.com \
    --to=andreas.bofjall@ericsson.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=Paul.Gortmaker@windriver.com \
    --cc=davem@davemloft.net \
    --cc=erik.hugne@ericsson.com \
    --cc=jon.maloy@ericsson.com \
    --cc=netdev@vger.kernel.org \
    --cc=tipc-discussion@lists.sourceforge.net \
    /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).