batman-adv: remove useless goto
PATCH v2 1/11 batman-adv: remove useless goto
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")
---
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(-)
multicast.c +1 -3
@@ -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; }/**
Signature · 1 line
1.8.3.2
PATCH v2 2/11 batman-adv: don't mess up with the netdev refcounting if not needed
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")
--- multicast.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-)
multicast.c +7 -26
@@ -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; }/**
Signature · 1 line
1.8.3.2
Re: [B.A.T.M.A.N.] [PATCHv2 next 02/11] batman-adv: don't mess up with the netdev refcounting if not needed
Quoted 3 lines · Antonio Quartulli
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.
Hm, I was intending to use it somewhere else as well with the next series of patches. See:
http://git.open-mesh.org/batman-adv.git/commitdiff/bd774bd7e00bbe062cb0ab591d50be77e30a557a?hp=c9c3d53851f832b32188c9dd9a3dace96a33a0c3
But ok, since it is not in a yet scheduled patchset, I guess you're right, then it should better be introduced when it is needed.
On another note, I think you're introducing a bug/memoryleak here for the compat-code case for netdev_master_upper_dev_get_rcu().
Cheers, Linus
PATCH v2 3/11 batman-adv: fix multicast kerneldoc
In reply to Antonio QuartulliThe 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")
--- multicast.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
multicast.c +6 -6
@@ -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 in case of +* memory allocation failure. */ 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)
Signature · 1 line
1.8.3.2
Re: [B.A.T.M.A.N.] [PATCHv2 next 03/11] batman-adv: fix multicast kerneldoc
Hi Antonio,
Two things are confusing me, firstly:
Quoted 3 lines · Antonio Quartulli
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.
vs.
Quoted 3 lines · Antonio Quartulli
For some reason we agreed on not using the third person while describing the function. For consistency I'd suggest you to do the same your kernel doc.
Secondly:
Why do you only change it in multicast.{c,h}, why not changing things everywhere? For instance translation-table.c sometimes uses "Returns", sometimes "Return".
Or functions in translation-table.c using first person in their description:
* batadv_tt_prepare_tvlv_global_data()
* batadv_tt_prepare_tvlv_local_data()
* batadv_tt_global_add()
* batadv_tt_global_del_orig_entry()
* batadv_tt_global_del_orig_node()
* batadv_send_roam_adv()
* batadv_tt_local_resize_to_mtu()
While these using the third one:
* batadv_transtable_best_orig()
* batadv_tt_global_print_entry()
* batadv_tt_global_crc()
* batadv_tt_check_roam_count()
Cheers, Linus
Re: [B.A.T.M.A.N.] [PATCHv2 next 03/11] batman-adv: fix multicast kerneldoc
Hi Linus,
Quoted 4 lines · Linus Lüssing
Hi Antonio,
Two things are confusing me, firstly:
Quoted 10 lines
Quoted 3 lines · Antonio Quartulli
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.vs.
Quoted 2 lines · Antonio Quartulli
For some reason we agreed on not using the third person while describing the function. For consistency I'd suggest you to do the same your kernel doc.
I think the situation is a little confusing because there is no clear statement anywhere.
We agreed on not using the third person in the function description, but we use it in the function "long" description (the one after the arguments).
Quoted 7 lines
Quoted 1 line
Secondly:
Why do you only change it in multicast.{c,h}, why not changing things everywhere? For instance
translation-table.csometimes uses "Returns", sometimes "Return".
Because these patches are meant to be squashed with what you already sent before I send them to David (this is why I have create dos many patches with different Introduced-by clauses and this is also why the patches are targeting next). They are not going to be sent ad a standalone set of changes.
Yes, we could "fix" all the kernel docs, but this should be done as a separated change. If you are willing to do that, please do :)
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [PATCHv2 next 03/11] batman-adv: fix multicast kerneldoc
Quoted 14 lines · Antonio Quartulli
Hi Linus,
Quoted 11 lines · Linus Lüssing
Hi Antonio,
Two things are confusing me, firstly:
Quoted 3 lines · Antonio Quartulli
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.vs.
Quoted 8 lines
Quoted 3 lines · Antonio Quartulli
Quoted 2 lines
For some reason we agreed on not using the third person while describing the function. For consistency I'd suggest you to do the same your kernel doc.
I think the situation is a little confusing because there is no clear statement anywhere.
We agreed on not using the third person in the function description, but we use it in the function "long" description (the one after the arguments).
I'm not quite sure about that. I specifically asked for clarification back then and got this reply which clearly references the longer function description:
Quoted 10 lines · Antonio Quartulli
Quoted 9 lines · Linus Lüssing
Quoted 8 lines
Quoted 5 lines
+/**
+ *batadv_mcast_mla_tt_update- Updates the own MLAs
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Updates the own multicast listener announcements in the translationFor some reason we agreed on not using the third person while describing the function. For consistency I'd suggest you to do the same your kernel doc.
Quoted 6 lines
Quoted 3 lines
I don't quite understand what you mean, talking in the first or second person seems strange, like "I update the multicast..." or "You update the multicast...". Do you have an example?
It should look like:
"Update the own multicast listener announcements in the translation"
well, but nevermind
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
Secondly:
Why do you only change it in multicast.{c,h}, why not changing things everywhere? For instance
translation-table.csometimes uses "Returns", sometimes "Return".
Quoted 5 lines
Because these patches are meant to be squashed with what you already sent before I send them to David (this is why I have create dos many patches with different Introduced-by clauses and this is also why the patches are targeting next). They are not going to be sent ad a standalone set of changes.
Okay that makes sense then if things are getting squashed before submission. And actually, I'd be very happy to return to the third-person singular again, the first-person version always sounded a little strange to me :).
What do you and others think about using third-person in the short description, too?
Cheers, Linus
PATCH v2 4/11 batman-adv: fix multicast kerneldoc
In reply to Antonio QuartulliThe 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")
--- multicast.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
multicast.c +6 -6
@@ -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)
Signature · 1 line
1.8.3.2
PATCH v2 5/11 batman-adv: fix multicast kerneldoc
In reply to Antonio QuartulliThe 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")
--- multicast.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
multicast.c +4 -4
@@ -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)
Signature · 1 line
1.8.3.2
PATCH v2 6/11 batman-adv: fix multicast kerneldoc
In reply to Antonio QuartulliThe 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")
--- multicast.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
multicast.c +10 -10
@@ -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. */
Signature · 1 line
1.8.3.2
PATCH v2 7/11 batman-adv: fix multicast kerneldoc
In reply to Antonio QuartulliThe 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")
--- multicast.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
multicast.c +10 -10
@@ -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,
Signature · 1 line
1.8.3.2
PATCH v2 8/11 batman-adv: adjust copyright disclaimer in multicast files
In reply to Antonio QuartulliThe 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")
--- multicast.c | 3 +++ multicast.h | 3 +++ 2 files changed, 6 insertions(+)
multicast.c +3 -0
@@ -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"
multicast.h +3 -0
@@ -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_
Signature · 1 line
1.8.3.2
PATCH v2 9/11 batman-adv: fix code style
In reply to Antonio Quartulli- 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")
--- multicast.c | 3 +-- multicast.h | 8 ++++---- translation-table.c | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-)
multicast.c +1 -2
@@ -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
multicast.h +4 -4
@@ -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 {
translation-table.c +2 -3
@@ -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; }
Signature · 1 line
1.8.3.2
PATCH v2 10/11 batman-adv: fix more code style
In reply to Antonio Quartulli- 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")
--- multicast.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
multicast.c +10 -10
@@ -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 )
Signature · 1 line
1.8.3.2
PATCH v2 11/11 batman-adv: fix more code style
In reply to Antonio Quartulli- 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")
--- multicast.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
multicast.c +16 -16
@@ -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; }
Signature · 1 line
1.8.3.2