From patchwork Tue Nov 3 20:56:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 4724 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=212.227.17.12; helo=mout.web.de; envelope-from=elfring@users.sourceforge.net; receiver=b.a.t.m.a.n@lists.open-mesh.org Received: from mout.web.de (mout.web.de [212.227.17.12]) by open-mesh.org (Postfix) with ESMTPS id 1A2CB816A9 for ; Tue, 3 Nov 2015 21:56:29 +0100 (CET) Received: from [192.168.1.3] ([78.48.236.222]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0M6DyQ-1aee0i0bHe-00yCfm; Tue, 03 Nov 2015 21:56:22 +0100 To: Antonio Quartulli , "David S. Miller" , Marek Lindner , Simon Wunderlich , b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <56391CF7.9080400@users.sourceforge.net> From: SF Markus Elfring Message-ID: <56391F73.7090605@users.sourceforge.net> Date: Tue, 3 Nov 2015 21:56:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <56391CF7.9080400@users.sourceforge.net> X-Provags-ID: V03:K0:13/TSE5gi2Lcv19sj2d+RtHeCmgw3BElWxdBX29qw2RIV8oQMvz c1FsDkQF6uJa4CZMc5Zr3fngRhamV+asj34uAlJWaf1/ASsHAZKNzSKl4jnVrYNC7O5nM82 ezevHeS3/s2lfOR9QGMSYp5nhF+I/aJPSYYr4dZYrJPhGZ39eEnBHXnYAsLM2+p32Ooq9pV hRanrIZK/AINNCz62Eaww== X-UI-Out-Filterresults: notjunk:1; V01:K0:KDSTUo3Ltus=:nskwzDjF8F4iJBVGy4ICko zWgp1a6xT+bpBuXsu3kncnDTj+/3DCY3ybFEzJioWwZ/HEqM7tgLmhbRn2rW9ysAMLvERpOKk 4mM9ef67b6mX6ByhfGtM/besCem036l54jINv5fYAIszooum7duS2ldJrXXOI2y8lIhuqDrvu 5/Hdx6/SmXLOVFTTpJ0A2WDLiuDjwdCtLlXrpdL8mIPTO/5K5AFGEZdB4cWcrbYU8X4OJaDR2 1nEamVKAJY9la/ue+DJqf/oqzErmOPyTpYB2+ApwJf0PrVAkf/f2/2XiRGfLhgmSTDGumH3u2 uL0WieAXSwAYz5B/N64lDxbQJhwmR66wT2Ic3ofbi2Jw+BobY4ifPPD5ksXIi5Fcx0sbMeKjm JKOsQ84Kz9WDQEVfr1bdfrC6SvOH90aRQpdU1Q9pmD6rHDb0nZa9L2hZyQBsJi3D6+S04UVPv 6+csl95/z1jIW3R6kVYnnB97BzGtSuMVy549IeraofIe6RQhJkwEMBbrEutBn7+da2rVZ9qjS eUfSY4cfg58ibqM3EmY/Y/KwtefhfWF9Xqak0Hz/VFgXuxni9SKRlziKAKPMASFatkgKCdLVf mA5QlIFnIGzjtA3v2kEf1o0Sas1CEVbWMMdkWGdwtiFvx0N4465Vs66HG1gC3vB685ZMvVgZd UCcwqcCIxy4OskKMV8oH3SqLh/zxCeWHPHdLSNqj9BioglH54S+NyqBmQ5n+24IQVgWwoiay5 pe3p7Xeqpi64gOL8fpIlBP2OVrdm0n6Mg9oyuJI3SOSkzQJh9TbbS74qmsEfvTKQlPcczCqKQ B0OZSLj X-Mailman-Approved-At: Wed, 04 Nov 2015 06:46:06 +0100 Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML Subject: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Nov 2015 20:56:30 -0000 From: Markus Elfring 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 --- 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; }