There is no need to use a label and a goto for code that is used once only. Moreover having a goto for a single return statement should always be avoided.
Introduced by e368857f66620b8483166e8e6556d9c87f9b3e71 ("batman-adv: Multicast Listener Announcements via Translation Table")
Cc: Linus Lüssing linus.luessing@web.de Signed-off-by: Antonio Quartulli antonio@meshcoding.com --- multicast.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/multicast.c b/multicast.c index 998b429..d92de1e 100644 --- a/multicast.c +++ b/multicast.c @@ -194,12 +194,10 @@ static bool batadv_mcast_has_bridge(struct batadv_priv *bat_priv)
bridge = batadv_mcast_get_bridge(bat_priv); if (!bridge) - goto out; + return false;
dev_put(bridge); return true; -out: - return false; }
/**
Looking for an interface and increasing its refcounter only to check if it really exists is not really useful and makes the code look more complex without a real gain.
Change batadv_mcast_has_bridge() accordingly and avoid to use the pointer to the interface outside of the rcu_read_lock/unlock context.
Introduced by e368857f66620b8483166e8e6556d9c87f9b3e71 ("batman-adv: Multicast Listener Announcements via Translation Table")
Cc: Linus Lüssing linus.luessing@web.de Signed-off-by: Antonio Quartulli antonio@meshcoding.com --- multicast.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-)
diff --git a/multicast.c b/multicast.c index d92de1e..af3fe49 100644 --- a/multicast.c +++ b/multicast.c @@ -156,16 +156,16 @@ static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv, }
/** - * batadv_mcast_get_bridge - get the bridge interface on our soft interface + * batadv_mcast_has_bridge - check whether the soft-iface is bridged * @bat_priv: the bat priv with all the soft interface information * - * Return the next bridge interface on top of our soft interface and increase - * its refcount. If no such bridge interface exists, then return NULL. + * Check whether there is a bridge on top of our soft interface. Return + * true if so, false otherwise. */ -static struct net_device * -batadv_mcast_get_bridge(struct batadv_priv *bat_priv) +static bool batadv_mcast_has_bridge(struct batadv_priv *bat_priv) { struct net_device *upper = bat_priv->soft_iface; + bool has_bridge = false;
rcu_read_lock();
@@ -174,30 +174,11 @@ batadv_mcast_get_bridge(struct batadv_priv *bat_priv) } while (upper && !(upper->priv_flags & IFF_EBRIDGE));
if (upper) - dev_hold(upper); + has_bridge = true;
rcu_read_unlock();
- return upper; -} - -/** - * batadv_mcast_has_bridge - check whether the soft-iface is bridged - * @bat_priv: the bat priv with all the soft interface information - * - * Check whether there is a bridge on top of our soft interface. Return - * true if so, false otherwise. - */ -static bool batadv_mcast_has_bridge(struct batadv_priv *bat_priv) -{ - struct net_device *bridge; - - bridge = batadv_mcast_get_bridge(bat_priv); - if (!bridge) - return false; - - dev_put(bridge); - return true; + return has_bridge; }
/**
The kerneldoc should always use the third person singular in the long function description. Moreover it should always try use up to 80 chars per line.
Introduced by 86cb16e5ec1e2d75821006e8f4abbec66fb741ac ("batman-adv: Add IPv4 link-local/IPv6-ll-all-nodes multicast support")
Cc: Linus Lüssing linus.luessing@web.de Signed-off-by: Antonio Quartulli antonio@meshcoding.com --- multicast.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/multicast.c b/multicast.c index af3fe49..0e8bea8 100644 --- a/multicast.c +++ b/multicast.c @@ -256,11 +256,11 @@ out: * @skb: the IPv4 packet to check * @is_unsnoopable: stores whether the destination is snoopable * - * Check whether the given IPv4 packet has the potential to - * be forwarded with a mode more optimal than classic flooding. + * Checks whether the given IPv4 packet has the potential to be forwarded with a + * mode more optimal than classic flooding. * - * If so then return 0. Otherwise -EINVAL is returned or -ENOMEM if we are - * out of memory. + * If so then returns 0. Otherwise -EINVAL is returned or -ENOMEM if we are out + * of memory. */ static int batadv_mcast_forw_mode_check_ipv4(struct batadv_priv *bat_priv, struct sk_buff *skb, @@ -485,8 +485,8 @@ batadv_mcast_forw_ip_node_get(struct batadv_priv *bat_priv, * batadv_mcast_want_forw_unsnoop_node_get - get a node with an unsnoopable flag * @bat_priv: the bat priv with all the soft interface information * - * Return an orig_node which has the BATADV_MCAST_WANT_ALL_UNSNOOPABLES flag set - * and increase its refcount. + * Returns an orig_node which has the BATADV_MCAST_WANT_ALL_UNSNOOPABLES flag + * set and increases its refcount. */ static struct batadv_orig_node * batadv_mcast_forw_unsnoop_node_get(struct batadv_priv *bat_priv)
Hi Antonio,
On 2014-03-17 06:22, Antonio Quartulli wrote:
The kerneldoc should always use the third person singular in the long function description. Moreover it should always try use up to 80 chars per line.
Introduced by 86cb16e5ec1e2d75821006e8f4abbec66fb741ac ("batman-adv: Add IPv4 link-local/IPv6-ll-all-nodes multicast support")
Cc: Linus Lüssing linus.luessing@web.de Signed-off-by: Antonio Quartulli antonio@meshcoding.com
multicast.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/multicast.c b/multicast.c index af3fe49..0e8bea8 100644 --- a/multicast.c +++ b/multicast.c @@ -256,11 +256,11 @@ out:
- @skb: the IPv4 packet to check
- @is_unsnoopable: stores whether the destination is snoopable
- Check whether the given IPv4 packet has the potential to
- be forwarded with a mode more optimal than classic flooding.
- Checks whether the given IPv4 packet has the potential to be forwarded with a
- mode more optimal than classic flooding.
- If so then return 0. Otherwise -EINVAL is returned or -ENOMEM if we are
- out of memory.
- If so then returns 0. Otherwise -EINVAL is returned or -ENOMEM if we are out
*/
- of memory.
The commit message says you wanted to use third person singular, but your change keeps the "we are out of memory" ?
On 17/03/14 17:13, Martin Hundebøll wrote:
- If so then return 0. Otherwise -EINVAL is returned or -ENOMEM if we are
- out of memory.
- If so then returns 0. Otherwise -EINVAL is returned or -ENOMEM if we are out
*/
- of memory.
The commit message says you wanted to use third person singular, but your change keeps the "we are out of memory" ?
I meant to use third person singular when talking about the action made by the function.
Saying "we" in the code/comment is generally not nice..maybe should change that as well.
Cheers,
The kerneldoc should always use the third person singular in the long function description. Moreover it should always try use up to 80 chars per line.
Introduced by commit 01d665e054254618353ec8d9ea43d1a138de6e6d ("batman-adv: Multicast Listener Announcements via Translation Table")
Cc: Linus Lüssing linus.luessing@web.de Signed-off-by: Antonio Quartulli antonio@meshcoding.com --- multicast.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/multicast.c b/multicast.c index 0e8bea8..e2b32fd 100644 --- a/multicast.c +++ b/multicast.c @@ -27,7 +27,7 @@ * Collect multicast addresses of the local multicast listeners * on the given soft interface, dev, in the given mcast_list. * - * Return -ENOMEM on memory allocation error or the number of + * Returns -ENOMEM on memory allocation error or the number of * items added to the mcast_list otherwise. */ static int batadv_mcast_mla_softif_get(struct net_device *dev, @@ -59,7 +59,7 @@ static int batadv_mcast_mla_softif_get(struct net_device *dev, * @mcast_addr: the multicast address to check * @mcast_list: the list with multicast addresses to search in * - * Return true if the given address is already in the given list. + * Returns true if the given address is already in the given list. * Otherwise returns false. */ static bool batadv_mcast_mla_is_duplicate(uint8_t *mcast_addr, @@ -78,7 +78,7 @@ static bool batadv_mcast_mla_is_duplicate(uint8_t *mcast_addr, * batadv_mcast_mla_list_free - free a list of multicast addresses * @mcast_list: the list to free * - * Remove and free all items in the given mcast_list. + * Removes and frees all items in the given mcast_list. */ static void batadv_mcast_mla_list_free(struct hlist_head *mcast_list) { @@ -96,7 +96,7 @@ static void batadv_mcast_mla_list_free(struct hlist_head *mcast_list) * @bat_priv: the bat priv with all the soft interface information * @mcast_list: a list of addresses which should _not_ be removed * - * Retract the announcement of any multicast listener from the + * Retracts the announcement of any multicast listener from the * translation table except the ones listed in the given mcast_list. * * If mcast_list is NULL then all are retracted. @@ -128,7 +128,7 @@ static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv, * @bat_priv: the bat priv with all the soft interface information * @mcast_list: a list of addresses which are going to get added * - * Add multicast listener announcements from the given mcast_list to the + * Adds multicast listener announcements from the given mcast_list to the * translation table if they have not been added yet. */ static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv, @@ -159,7 +159,7 @@ static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv, * batadv_mcast_has_bridge - check whether the soft-iface is bridged * @bat_priv: the bat priv with all the soft interface information * - * Check whether there is a bridge on top of our soft interface. Return + * Checks whether there is a bridge on top of our soft interface. Returns * true if so, false otherwise. */ static bool batadv_mcast_has_bridge(struct batadv_priv *bat_priv)
The kerneldoc should always use the third person singular in the long function description. Moreover it should always try use up to 80 chars per line.
Introduced by f70c60d236cddb28d9e576de774ad97f9b0fd1b7 ("batman-adv: Announce new capability via multicast TVLV")
Cc: Linus Lüssing linus.luessing@web.de Signed-off-by: Antonio Quartulli antonio@meshcoding.com --- multicast.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/multicast.c b/multicast.c index e2b32fd..f8a4c4d 100644 --- a/multicast.c +++ b/multicast.c @@ -185,11 +185,11 @@ static bool batadv_mcast_has_bridge(struct batadv_priv *bat_priv) * batadv_mcast_mla_tvlv_update - update multicast tvlv * @bat_priv: the bat priv with all the soft interface information * - * Update the own multicast tvlv with our current multicast related settings, + * Updates the own multicast tvlv with our current multicast related settings, * capabilities and inabilities. * - * Return true if the tvlv container is registered afterwards. Otherwise return - * false. + * Returns true if the tvlv container is registered afterwards. Otherwise + * returns false. */ static bool batadv_mcast_mla_tvlv_update(struct batadv_priv *bat_priv) { @@ -226,7 +226,7 @@ static bool batadv_mcast_mla_tvlv_update(struct batadv_priv *bat_priv) * batadv_mcast_mla_update - update the own MLAs * @bat_priv: the bat priv with all the soft interface information * - * Update the own multicast listener announcements in the translation + * Updates the own multicast listener announcements in the translation * table as well as the own, announced multicast tvlv container. */ void batadv_mcast_mla_update(struct batadv_priv *bat_priv)
The kerneldoc should always use the third person singular in the long function description. Moreover it should always try use up to 80 chars per line.
Introduced by 90ad6a40c80323805be1e86504385de2bd861f0a ("batman-adv: Modified forwarding behaviour for multicast packets")
Cc: Linus 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 f8a4c4d..8dda617 100644 --- a/multicast.c +++ b/multicast.c @@ -294,11 +294,11 @@ static int batadv_mcast_forw_mode_check_ipv4(struct batadv_priv *bat_priv, * @skb: the IPv6 packet to check * @is_unsnoopable: stores whether the destination is snoopable * - * Check whether the given IPv6 packet has the potential to - * be forwarded with a mode more optimal than classic flooding. + * Checks whether the given IPv6 packet has the potential to be forwarded with a + * mode more optimal than classic flooding. * - * If so then return 0. Otherwise -EINVAL is returned or -ENOMEM if we are - * out of memory. + * If so then returns 0. Otherwise -EINVAL is returned or -ENOMEM if we are out + * of memory. */ static int batadv_mcast_forw_mode_check_ipv6(struct batadv_priv *bat_priv, struct sk_buff *skb, @@ -334,11 +334,11 @@ static int batadv_mcast_forw_mode_check_ipv6(struct batadv_priv *bat_priv, * @skb: the multicast frame to check * @is_unsnoopable: stores whether the destination is snoopable * - * Check whether the given multicast ethernet frame has the potential to - * be forwarded with a mode more optimal than classic flooding. + * Checks whether the given multicast ethernet frame has the potential to be + * forwarded with a mode more optimal than classic flooding. * - * If so then return 0. Otherwise -EINVAL is returned or -ENOMEM if we are - * out of memory. + * If so then returns 0. Otherwise -EINVAL is returned or -ENOMEM if we are out + * of memory. */ static int batadv_mcast_forw_mode_check(struct batadv_priv *bat_priv, struct sk_buff *skb, @@ -392,7 +392,7 @@ static int batadv_mcast_forw_want_all_ip_count(struct batadv_priv *bat_priv, * @bat_priv: the bat priv with all the soft interface information * @ethhdr: the ether header containing the multicast destination * - * Return an orig_node matching the multicast address provided by ethhdr + * Returns an orig_node matching the multicast address provided by ethhdr * via a translation table lookup. This increases the returned nodes refcount. */ static struct batadv_orig_node * @@ -514,7 +514,7 @@ unlock: * @skb: The multicast packet to check * @orig: an originator to be set to forward the skb to * - * Return the forwarding mode as enum batadv_forw_mode and in case of + * Returns the forwarding mode as enum batadv_forw_mode and in case of * BATADV_FORW_SINGLE set the orig to the single originator the skb * should be forwarded to. */
The kerneldoc should always use the third person singular in the long function description. Moreover it should always try use up to 80 chars per line.
Introduced by f2ed1502191a37abb39e3e2c80cca07f0f3bb411 ("batman-adv: Send multicast packets to nodes with a WANT_ALL flag")
Cc: Linus 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 8dda617..e8e324d 100644 --- a/multicast.c +++ b/multicast.c @@ -369,9 +369,9 @@ static int batadv_mcast_forw_mode_check(struct batadv_priv *bat_priv, * @bat_priv: the bat priv with all the soft interface information * @ethhdr: ethernet header of a packet * - * Return the number of nodes which want all IPv4 multicast traffic if - * the given ethhdr is from an IPv4 packet or the number of nodes which want - * all IPv6 traffic if it matches an IPv6 packet. + * Returns the number of nodes which want all IPv4 multicast traffic if the + * given ethhdr is from an IPv4 packet or the number of nodes which want all + * IPv6 traffic if it matches an IPv6 packet. */ static int batadv_mcast_forw_want_all_ip_count(struct batadv_priv *bat_priv, struct ethhdr *ethhdr) @@ -407,8 +407,8 @@ batadv_mcast_forw_tt_node_get(struct batadv_priv *bat_priv, * batadv_mcast_want_forw_ipv4_node_get - get a node with an ipv4 flag * @bat_priv: the bat priv with all the soft interface information * - * Return an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 flag set - * and increase its refcount. + * Returns an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 flag set and + * increases its refcount. */ static struct batadv_orig_node * batadv_mcast_forw_ipv4_node_get(struct batadv_priv *bat_priv) @@ -434,8 +434,8 @@ unlock: * batadv_mcast_want_forw_ipv6_node_get - get a node with an ipv6 flag * @bat_priv: the bat priv with all the soft interface information * - * Return an orig_node which has the BATADV_MCAST_WANT_ALL_IPV6 flag set - * and increase its refcount. + * Returns an orig_node which has the BATADV_MCAST_WANT_ALL_IPV6 flag set + * and increases its refcount. */ static struct batadv_orig_node * batadv_mcast_forw_ipv6_node_get(struct batadv_priv *bat_priv) @@ -462,9 +462,9 @@ unlock: * @bat_priv: the bat priv with all the soft interface information * @ethhdr: an ethernet header to determine the protocol family from * - * Return an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 or - * BATADV_MCAST_WANT_ALL_IPV6 flag, depending on the provided ethhdr, set - * and increase its refcount. + * Returns an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 or + * BATADV_MCAST_WANT_ALL_IPV6 flag, depending on the provided ethhdr, set and + * increases its refcount. */ static struct batadv_orig_node * batadv_mcast_forw_ip_node_get(struct batadv_priv *bat_priv,
The URL to the FSF address has to be always reported in the copyright disclaimer. This is the accepted style in the networking branch.
Introduced by e368857f66620b8483166e8e6556d9c87f9b3e71 ("batman-adv: Multicast Listener Announcements via Translation Table")
Cc: Linus Lüssing linus.luessing@web.de Signed-off-by: Antonio Quartulli antonio@meshcoding.com --- multicast.c | 3 +++ multicast.h | 3 +++ 2 files changed, 6 insertions(+)
diff --git a/multicast.c b/multicast.c index e8e324d..425978d 100644 --- a/multicast.c +++ b/multicast.c @@ -10,6 +10,9 @@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. */
#include "main.h" diff --git a/multicast.h b/multicast.h index a76bc3a..2861899 100644 --- a/multicast.h +++ b/multicast.h @@ -10,6 +10,9 @@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. */
#ifndef _NET_BATMAN_ADV_MULTICAST_H_
- don't split lines if shorter than 80 chars - don't use goto if there is no cleanup to perform
Introduced by 90ad6a40c80323805be1e86504385de2bd861f0a ("batman-adv: Modified forwarding behaviour for multicast packets")
Cc: Linux Lüssing linus.luessing@web.de Signed-off-by: Antonio Quartulli antonio@meshcoding.com --- multicast.c | 3 +-- multicast.h | 8 ++++---- translation-table.c | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/multicast.c b/multicast.c index 425978d..5a39fc1 100644 --- a/multicast.c +++ b/multicast.c @@ -318,8 +318,7 @@ static int batadv_mcast_forw_mode_check_ipv6(struct batadv_priv *bat_priv, /* TODO: Implement Multicast Router Discovery (RFC4286), * then allow scope > link local, too */ - if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) != - IPV6_ADDR_SCOPE_LINKLOCAL) + if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) != IPV6_ADDR_SCOPE_LINKLOCAL) return -EINVAL;
/* link-local-all-nodes multicast listeners behind a bridge are diff --git a/multicast.h b/multicast.h index 2861899..73b5d45 100644 --- a/multicast.h +++ b/multicast.h @@ -20,10 +20,10 @@
/** * batadv_forw_mode - the way a packet should be forwarded as - * @BATADV_FORW_ALL: forward the packet to all nodes - * (currently via classic flooding) - * @BATADV_FORW_SINGLE: forward the packet to a single node - * (currently via the BATMAN unicast routing protocol) + * @BATADV_FORW_ALL: forward the packet to all nodes (currently via classic + * flooding) + * @BATADV_FORW_SINGLE: forward the packet to a single node (currently via the + * BATMAN unicast routing protocol) * @BATADV_FORW_NONE: don't forward, drop it */ enum batadv_forw_mode { diff --git a/translation-table.c b/translation-table.c index dab5c39..d636bde 100644 --- a/translation-table.c +++ b/translation-table.c @@ -206,16 +206,15 @@ int batadv_tt_global_hash_count(struct batadv_priv *bat_priv, const uint8_t *addr, unsigned short vid) { struct batadv_tt_global_entry *tt_global_entry; - int count = 0; + int count;
tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr, vid); if (!tt_global_entry) - goto out; + return 0;
count = atomic_read(&tt_global_entry->orig_list_count); batadv_tt_global_entry_free_ref(tt_global_entry);
-out: return count; }
- 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(-)
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)
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)
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!
- 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 166d0a3..749e6f0 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; }
b.a.t.m.a.n@lists.open-mesh.org