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

From: SF Markus Elfring
Date: Tue Nov 03 2015 - 15:56:33 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 3 Nov 2015 21:10:51 +0100

The variables "tt_local_entry" and "tt_global_entry" were eventually checked
again despite of a corresponding null pointer test before.
Let us avoid this double check by reordering a function call sequence
and the better selection of jump targets.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
net/batman-adv/translation-table.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 965a004..3ac32d9 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3323,27 +3323,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_free;

tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
if (!tt_local_entry)
- goto out;
+ goto vlan_free;

tt_global_entry = batadv_tt_global_hash_find(bat_priv, src, vid);
if (!tt_global_entry)
- goto out;
+ goto local_entry_free;

- if (!_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
- goto out;
-
- ret = true;
+ if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
+ ret = true;

-out:
+ batadv_tt_global_entry_free_ref(tt_global_entry);
+local_entry_free:
+ batadv_tt_local_entry_free_ref(tt_local_entry);
+vlan_free:
batadv_softif_vlan_free_ref(vlan);
- if (tt_global_entry)
- batadv_tt_global_entry_free_ref(tt_global_entry);
- if (tt_local_entry)
- batadv_tt_local_entry_free_ref(tt_local_entry);
return ret;
}

--
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/