[next,10/11] batman-adv: fix more code style

Message ID 1395062574-28291-10-git-send-email-antonio@meshcoding.com (mailing list archive)
State Superseded, archived
Commit 45dab5f5509023946793fc9d1d0566c12ca8bb52
Headers

Commit Message

Antonio Quartulli March 17, 2014, 1:22 p.m. UTC
  - keep variable declarations in ascendant line length order
- use common iteration style pattern when looking up an
  object

Introduced by 86cb16e5ec1e2d75821006e8f4abbec66fb741ac
("batman-adv: Add IPv4 link-local/IPv6-ll-all-nodes multicast support")

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

Comments

Martin Hundebøll March 17, 2014, 4:19 p.m. UTC | #1
On 2014-03-17 06:22, Antonio Quartulli wrote:
> - keep variable declarations in ascendant line length order
> - use common iteration style pattern when looking up an
>   object

Do you mean descending line length?

// Martin

> Introduced by 86cb16e5ec1e2d75821006e8f4abbec66fb741ac
> ("batman-adv: Add IPv4 link-local/IPv6-ll-all-nodes multicast support")
> 
> Cc: Linux Lüssing <linus.luessing@web.de>
> Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
> ---
>  multicast.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/multicast.c b/multicast.c
> index 5a39fc1..166d0a3 100644
> --- a/multicast.c
> +++ b/multicast.c
> @@ -493,20 +493,20 @@ batadv_mcast_forw_ip_node_get(struct batadv_priv *bat_priv,
>  static struct batadv_orig_node *
>  batadv_mcast_forw_unsnoop_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_unsnoopables_list,
>  				 mcast_want_all_unsnoopables_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;
>  }
>  
> @@ -524,9 +524,9 @@ enum batadv_forw_mode
>  batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
>  		       struct batadv_orig_node **orig)
>  {
> -	struct ethhdr *ethhdr;
> -	bool is_unsnoopable = false;
>  	int ret, tt_count, ip_count, unsnoop_count, total_count;
> +	bool is_unsnoopable = false;
> +	struct ethhdr *ethhdr;
>  
>  	ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable);
>  	if (ret == -ENOMEM)
>
  
Antonio Quartulli March 17, 2014, 4:33 p.m. UTC | #2
On 17/03/14 17:19, Martin Hundebøll wrote:
> On 2014-03-17 06:22, Antonio Quartulli wrote:
>> - keep variable declarations in ascendant line length order
>> - use common iteration style pattern when looking up an
>>   object
> 
> Do you mean descending line length?

Yes, you are right.

Thanks!
  

Patch

diff --git a/multicast.c b/multicast.c
index 5a39fc1..166d0a3 100644
--- a/multicast.c
+++ b/multicast.c
@@ -493,20 +493,20 @@  batadv_mcast_forw_ip_node_get(struct batadv_priv *bat_priv,
 static struct batadv_orig_node *
 batadv_mcast_forw_unsnoop_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_unsnoopables_list,
 				 mcast_want_all_unsnoopables_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;
 }
 
@@ -524,9 +524,9 @@  enum batadv_forw_mode
 batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
 		       struct batadv_orig_node **orig)
 {
-	struct ethhdr *ethhdr;
-	bool is_unsnoopable = false;
 	int ret, tt_count, ip_count, unsnoop_count, total_count;
+	bool is_unsnoopable = false;
+	struct ethhdr *ethhdr;
 
 	ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable);
 	if (ret == -ENOMEM)