Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1355887 > unrolled thread

[PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2016-03-11 13:50 +0100
Last post2016-03-15 01:20 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated()  after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-03-11 13:50 +0100
    Re: [PATCH] batman-adv: Less function calls in  batadv_is_ap_isolated() after error detection David Miller <davem@davemloft.net> - 2016-03-14 20:30 +0100
      Re: [PATCH] batman-adv: Less function calls in  batadv_is_ap_isolated() after error detection Antonio Quartulli <a@unstable.cc> - 2016-03-15 01:20 +0100

#1355887 — [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-03-11 13:50 +0100
Subject[PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
Message-ID<rbuFZ-6nv-27@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 11 Mar 2016 13:10:20 +0100

The variables "tt_local_entry" and "tt_global_entry" were eventually
checked again despite of a corresponding null pointer test before.

* Avoid this double check by reordering a function call sequence
  and the better selection of jump targets.

* Omit the initialisation for these variables at the beginning then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/batman-adv/translation-table.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 0b43e86..9c0193ee 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3403,8 +3403,8 @@ void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv)
 bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
 			   unsigned short vid)
 {
-	struct batadv_tt_local_entry *tt_local_entry = NULL;
-	struct batadv_tt_global_entry *tt_global_entry = NULL;
+	struct batadv_tt_local_entry *tt_local_entry;
+	struct batadv_tt_global_entry *tt_global_entry;
 	struct batadv_softif_vlan *vlan;
 	bool ret = false;
 
@@ -3413,27 +3413,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
 		return false;
 
 	if (!atomic_read(&vlan->ap_isolation))
-		goto out;
+		goto vlan_put;
 
 	tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
 	if (!tt_local_entry)
-		goto out;
+		goto vlan_put;
 
 	tt_global_entry = batadv_tt_global_hash_find(bat_priv, src, vid);
 	if (!tt_global_entry)
-		goto out;
-
-	if (!_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
-		goto out;
+		goto local_entry_put;
 
-	ret = true;
+	if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
+		ret = true;
 
-out:
+	batadv_tt_global_entry_put(tt_global_entry);
+local_entry_put:
+	batadv_tt_local_entry_put(tt_local_entry);
+vlan_put:
 	batadv_softif_vlan_put(vlan);
-	if (tt_global_entry)
-		batadv_tt_global_entry_put(tt_global_entry);
-	if (tt_local_entry)
-		batadv_tt_local_entry_put(tt_local_entry);
 	return ret;
 }
 
-- 
2.7.2

[toc] | [next] | [standalone]


#1357569 — Re: [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection

FromDavid Miller <davem@davemloft.net>
Date2016-03-14 20:30 +0100
SubjectRe: [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
Message-ID<rcGlH-86m-9@gated-at.bofh.it>
In reply to#1355887
From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 11 Mar 2016 13:40:56 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 11 Mar 2016 13:10:20 +0100
> 
> The variables "tt_local_entry" and "tt_global_entry" were eventually
> checked again despite of a corresponding null pointer test before.
> 
> * Avoid this double check by reordering a function call sequence
>   and the better selection of jump targets.
> 
> * Omit the initialisation for these variables at the beginning then.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

I am assuming Antonio will take this in via his tree.

[toc] | [prev] | [next] | [standalone]


#1357710 — Re: [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection

FromAntonio Quartulli <a@unstable.cc>
Date2016-03-15 01:20 +0100
SubjectRe: [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
Message-ID<rcKSm-2ES-3@gated-at.bofh.it>
In reply to#1357569

[Multipart message — attachments visible in raw view] — view raw

On Mon, Mar 14, 2016 at 03:25:02PM -0400, David Miller wrote:
> From: SF Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 11 Mar 2016 13:40:56 +0100
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Fri, 11 Mar 2016 13:10:20 +0100
> > 
> > The variables "tt_local_entry" and "tt_global_entry" were eventually
> > checked again despite of a corresponding null pointer test before.
> > 
> > * Avoid this double check by reordering a function call sequence
> >   and the better selection of jump targets.
> > 
> > * Omit the initialisation for these variables at the beginning then.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> I am assuming Antonio will take this in via his tree.
> 

Yeah, it will go through our tree. Still under review right now.

Cheers,

-- 
Antonio Quartulli

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web