From patchwork Wed Mar 19 17:57:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 3886 Return-Path: Received: from s3.neomailbox.net (s3.neomailbox.net [178.209.62.157]) by open-mesh.org (Postfix) with ESMTPS id 50624602349 for ; Wed, 19 Mar 2014 18:57:51 +0100 (CET) From: Antonio Quartulli To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 19 Mar 2014 18:57:35 +0100 Message-Id: <1395251855-30765-7-git-send-email-antonio@meshcoding.com> In-Reply-To: <1395251855-30765-1-git-send-email-antonio@meshcoding.com> References: <1395251747-27289-1-git-send-email-antonio@meshcoding.com> <1395251855-30765-1-git-send-email-antonio@meshcoding.com> MIME-Version: 1.0 Cc: Antonio Quartulli Subject: [B.A.T.M.A.N.] [PATCHv4 next 11/11] batman-adv: fix more code style X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Mar 2014 17:57:51 -0000 - 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 Signed-off-by: Antonio Quartulli --- multicast.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/multicast.c b/multicast.c index dfe4cd6..8c7ca81 100644 --- a/multicast.c +++ b/multicast.c @@ -409,20 +409,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; } @@ -436,20 +436,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; }