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 ---
Changes from v3: - simply has_bridge() function even more
Changes from v2: - added compat code change to 2/11 to accommodate new use of netdev_master_upper_dev_get_rcu()
Changes from v1: - change "we are out of memory" to "in case of memory allocation failure" in 3/11 - fix commit message in 10/11
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 --- compat.h | 19 ++++--------------- multicast.c | 33 ++++----------------------------- 2 files changed, 8 insertions(+), 44 deletions(-)
diff --git a/compat.h b/compat.h index e14c6bb..5eb5fe6 100644 --- a/compat.h +++ b/compat.h @@ -164,14 +164,8 @@ static inline int batadv_param_set_copystring(const char *val, #define NET_ADDR_RANDOM 0
#define netdev_master_upper_dev_get_rcu(dev) \ - upper; \ - if (dev->br_port ? 1 : 0) { \ - rcu_read_unlock(); \ - dev_hold(dev); \ - return dev; \ - } else {\ - dev = NULL; \ - } + (dev->br_port ? dev : NULL); \ + break;
#endif /* < KERNEL_VERSION(2, 6, 36) */
@@ -375,13 +369,8 @@ static int __batadv_interface_tx(struct sk_buff *skb, \
#ifndef netdev_master_upper_dev_get_rcu #define netdev_master_upper_dev_get_rcu(dev) \ - upper; \ - if (dev->priv_flags & IFF_BRIDGE_PORT) { \ - rcu_read_unlock(); \ - dev_hold(dev); \ - return dev; \ - } else \ - dev = NULL; + (dev->priv_flags & IFF_BRIDGE_PORT ? dev : NULL); \ + break;
#endif /* netdev_master_upper_dev_get_rcu */
diff --git a/multicast.c b/multicast.c index d92de1e..edce295 100644 --- a/multicast.c +++ b/multicast.c @@ -156,51 +156,26 @@ 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;
rcu_read_lock(); - do { upper = netdev_master_upper_dev_get_rcu(upper); } while (upper && !(upper->priv_flags & IFF_EBRIDGE)); - - if (upper) - dev_hold(upper); - 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; -} - -/** * batadv_mcast_mla_tvlv_update - update multicast tvlv * @bat_priv: the bat priv with all the soft interface information *
On Wednesday 19 March 2014 18:55:38 Antonio Quartulli wrote:
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
compat.h | 19 ++++--------------- multicast.c | 33 ++++----------------------------- 2 files changed, 8 insertions(+), 44 deletions(-)
Applied in revision 9ef7aad.
Thanks, Marek
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 edce295..e2ad525 100644 --- a/multicast.c +++ b/multicast.c @@ -250,11 +250,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 in case of + * memory allocation failure. */ static int batadv_mcast_forw_mode_check_ipv4(struct batadv_priv *bat_priv, struct sk_buff *skb, @@ -479,8 +479,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)
On Wednesday 19 March 2014 18:55:39 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(-)
Applied in revision a36b345.
Thanks, Marek
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 e2ad525..ae2cb48 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)
On Wednesday 19 March 2014 18:55:40 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 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(-)
Applied in revision da22087.
Thanks, Marek
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 ae2cb48..5bc0703 100644 --- a/multicast.c +++ b/multicast.c @@ -179,11 +179,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) { @@ -220,7 +220,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 5bc0703..25b2632 100644 --- a/multicast.c +++ b/multicast.c @@ -288,11 +288,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, @@ -328,11 +328,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, @@ -386,7 +386,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 * @@ -508,7 +508,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. */
On Wednesday 19 March 2014 18:57:30 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 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(-)
Applied in revision 076d6a6.
Thanks, Marek
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 25b2632..53d82e2 100644 --- a/multicast.c +++ b/multicast.c @@ -363,9 +363,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) @@ -401,8 +401,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) @@ -428,8 +428,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) @@ -456,9 +456,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,
On Wednesday 19 March 2014 18:57:31 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 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(-)
Applied in revision 5690930.
Thanks, Marek
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 53d82e2..9a9e7f4 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_
On Wednesday 19 March 2014 18:57:32 Antonio Quartulli wrote:
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(+)
Applied in revision 04ff3a0.
Thanks, Marek
- 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 9a9e7f4..d67d75d 100644 --- a/multicast.c +++ b/multicast.c @@ -312,8 +312,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; }
On Wednesday 19 March 2014 18:57:33 Antonio Quartulli wrote:
- 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(-)
Applied in revision bc45afd.
Thanks, Marek
- keep variable declarations in descending 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 d67d75d..dfe4cd6 100644 --- a/multicast.c +++ b/multicast.c @@ -487,20 +487,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; }
@@ -518,9 +518,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 Wednesday 19 March 2014 18:57:34 Antonio Quartulli wrote:
- keep variable declarations in descending 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(-)
Applied in revision 45dab5f.
Thanks, Marek
- 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 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; }
On Wednesday 19 March 2014 18:57:35 Antonio Quartulli wrote:
- 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(-)
Applied in revision b08dc3d.
Thanks, Marek
On Wednesday 19 March 2014 18:57:29 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 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(-)
Applied in revision 3b44ced.
Thanks, Marek
On Wednesday 19 March 2014 18:55:37 Antonio Quartulli wrote:
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
Changes from v3:
- simply has_bridge() function even more
Changes from v2:
- added compat code change to 2/11 to accommodate new use of netdev_master_upper_dev_get_rcu()
Changes from v1:
- change "we are out of memory" to "in case of memory allocation failure" in
3/11
- fix commit message in 10/11
multicast.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Applied in revision 6f54268.
Thanks, Marek
b.a.t.m.a.n@lists.open-mesh.org