diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2016-03-11 13:10:20 +0100 |
---|---|---|
committer | Simon Wunderlich <sw@simonwunderlich.de> | 2016-10-18 15:02:43 +0200 |
commit | 393b299d2cb804f09e05aafbdce9e3d3f61438cf (patch) | |
tree | 5eefac18ba3aadb904d781a04be42e8330ec8294 /net/batman-adv | |
parent | 0566df307bc882bfca4128521f01a48f4579d27d (diff) | |
download | linux-393b299d2cb804f09e05aafbdce9e3d3f61438cf.tar.gz linux-393b299d2cb804f09e05aafbdce9e3d3f61438cf.tar.bz2 linux-393b299d2cb804f09e05aafbdce9e3d3f61438cf.zip |
batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
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>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/translation-table.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 7f663092f6de..ad1e3bc0e205 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -3835,8 +3835,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; @@ -3845,27 +3845,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; } |