public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Antonio Quartulli <antonio@meshcoding.com>
Subject: [B.A.T.M.A.N.] [PATCHv2 next 11/11] batman-adv: fix more code style
Date: Wed, 19 Mar 2014 09:08:52 +0100	[thread overview]
Message-ID: <1395216532-31099-11-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1395216532-31099-1-git-send-email-antonio@meshcoding.com>

- use common iteration style pattern when looking up an
  object

Introduced by f2ed1502191a37abb39e3e2c80cca07f0f3bb411
("batman-adv: Send multicast packets to nodes with a WANT_ALL flag")

Cc: Linux Lüssing <linus.luessing@web.de>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
---
 multicast.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/multicast.c b/multicast.c
index 79a18a0..de47018 100644
--- a/multicast.c
+++ b/multicast.c
@@ -415,20 +415,20 @@ batadv_mcast_forw_tt_node_get(struct batadv_priv *bat_priv,
 static struct batadv_orig_node *
 batadv_mcast_forw_ipv4_node_get(struct batadv_priv *bat_priv)
 {
-	struct batadv_orig_node *orig_node;
+	struct batadv_orig_node *tmp_orig_node, *orig_node = NULL;
 
 	rcu_read_lock();
-	hlist_for_each_entry_rcu(orig_node,
+	hlist_for_each_entry_rcu(tmp_orig_node,
 				 &bat_priv->mcast.want_all_ipv4_list,
 				 mcast_want_all_ipv4_node) {
-		if (atomic_inc_not_zero(&orig_node->refcount))
-			goto unlock;
-	}
-
-	orig_node = NULL;
+		if (!atomic_inc_not_zero(&orig_node->refcount))
+			continue;
 
-unlock:
+		orig_node = tmp_orig_node;
+		break;
+	}
 	rcu_read_unlock();
+
 	return orig_node;
 }
 
@@ -442,20 +442,20 @@ unlock:
 static struct batadv_orig_node *
 batadv_mcast_forw_ipv6_node_get(struct batadv_priv *bat_priv)
 {
-	struct batadv_orig_node *orig_node;
+	struct batadv_orig_node *tmp_orig_node, *orig_node = NULL;
 
 	rcu_read_lock();
-	hlist_for_each_entry_rcu(orig_node,
+	hlist_for_each_entry_rcu(tmp_orig_node,
 				 &bat_priv->mcast.want_all_ipv6_list,
 				 mcast_want_all_ipv6_node) {
-		if (atomic_inc_not_zero(&orig_node->refcount))
-			goto unlock;
-	}
-
-	orig_node = NULL;
+		if (!atomic_inc_not_zero(&orig_node->refcount))
+			continue;
 
-unlock:
+		orig_node = tmp_orig_node;
+		break;
+	}
 	rcu_read_unlock();
+
 	return orig_node;
 }
 
-- 
1.8.3.2


      parent reply	other threads:[~2014-03-19  8:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19  8:08 [B.A.T.M.A.N.] [PATCHv2 next 01/11] batman-adv: remove useless goto Antonio Quartulli
2014-03-19  8:08 ` [B.A.T.M.A.N.] [PATCHv2 next 02/11] batman-adv: don't mess up with the netdev refcounting if not needed Antonio Quartulli
2014-03-19 10:02   ` Linus Lüssing
2014-03-19  8:08 ` [B.A.T.M.A.N.] [PATCHv2 next 03/11] batman-adv: fix multicast kerneldoc Antonio Quartulli
2014-03-19  9:03   ` Linus Lüssing
2014-03-19  9:12     ` Antonio Quartulli
2014-03-19  9:38       ` Linus Lüssing
2014-03-19  8:08 ` [B.A.T.M.A.N.] [PATCHv2 next 04/11] " Antonio Quartulli
2014-03-19  8:08 ` [B.A.T.M.A.N.] [PATCHv2 next 05/11] " Antonio Quartulli
2014-03-19  8:08 ` [B.A.T.M.A.N.] [PATCHv2 next 06/11] " Antonio Quartulli
2014-03-19  8:08 ` [B.A.T.M.A.N.] [PATCHv2 next 07/11] " Antonio Quartulli
2014-03-19  8:08 ` [B.A.T.M.A.N.] [PATCHv2 next 08/11] batman-adv: adjust copyright disclaimer in multicast files Antonio Quartulli
2014-03-19  8:08 ` [B.A.T.M.A.N.] [PATCHv2 next 09/11] batman-adv: fix code style Antonio Quartulli
2014-03-19  8:08 ` [B.A.T.M.A.N.] [PATCHv2 next 10/11] batman-adv: fix more " Antonio Quartulli
2014-03-19  8:08 ` Antonio Quartulli [this message]

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=1395216532-31099-11-git-send-email-antonio@meshcoding.com \
    --to=antonio@meshcoding.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.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