Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752770AbcCKMlZ (ORCPT ); Fri, 11 Mar 2016 07:41:25 -0500 Received: from mout.web.de ([212.227.17.11]:60119 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752320AbcCKMlQ (ORCPT ); Fri, 11 Mar 2016 07:41:16 -0500 Subject: [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection To: b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org, Antonio Quartulli , "David S. Miller" , Marek Lindner , Simon Wunderlich , Sven Eckelmann References: <5307CAA2.8060406@users.sourceforge.net> <564EDE1D.7070809@meshcoding.com> <564EFC67.7050307@users.sourceforge.net> <1655341.WCvHHx7pqD@bentobox> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <56E2BCD8.9010200@users.sourceforge.net> Date: Fri, 11 Mar 2016 13:40:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1655341.WCvHHx7pqD@bentobox> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:p/vdyBrLznrzUqZRTxwDgCKbXpNrxsGqya8QlUnwSm7tLKEQxPN FKMe29BOyxFYSW3hQabSC+Zu2Qcf+lcegatsDxeI1cmn4IB0Dcgj9zfofVVP6XM3WGKHHSZ anrvYHVsx0Oy8N+q9t2iL5e9/5UuqZt5f8bQUWIejYvzgOOyc24rrA5p18b80IrEqbHd8Mv RVtZWFjukmqWeNl/5GH8w== X-UI-Out-Filterresults: notjunk:1;V01:K0:Uc74JZSFhn4=:SrFCApr9476offlZY3Rqe1 zGx576S6McXnXASSSyl+FwRkYuX+1AhiS3VcAVIakSGnB6BwVZXcEqtk3MF7ue3AtzIQAGQVi h1/siyPqDxCYnSD8jJ7qBqJSM/mjVoQB48lLKvAbDyF2ZAmlkZtVnyoOENUTQHdqYtDLZ0sHP YJDsTRSrtXLMRADSQhPKFCaQDhIDvwO4H1Mvbau2lmNrVOC4b2ykZMbJtvNKuWmRAL0R35ClU BdInBn0lF4VmVyh0J5ypb36iWiAT6IjK9NFs0dY5OqACz3+yVgzXfuXxtIvBkELlCAjV3kLUP gMI8ZjR92f6BaQhNTQ1KnDrCHw+nxdDWrFUQ4c/YIl7bOwLIg+r5ODNU+Qebj18OuxUfpQ3pI nCQjfcCagBx9KNeKvjVZ4xdRjzgnJtStAO+ypV6XD9Ae+lTE7UK7zgNOBsLi9aaqjgO74OH8m nmxelbhMbXkWbU0bwrX5o4GSJGRq6O5jYqmf9BWg4hQeKJFKfhJQoX9LjYLrAA0Ij6Q14Fdoe gDySoRR7DPvJKFMRp7CUSwt28nJEUpK8P656zCbRnUrVzBRTCmW8pwWD4DGD4m9HyrHZp1lg4 v4h6on2HXQ/eikF93hEw2euLq99/PjONSa7QycocKhB3qN/xHWxLqyGJDCDlERakNfsvLGNIR ThLSqX5lJOL+iWyxylLdyeb4v5uSaui101VX2EHdOFPN2Em0QGXwZQ1PmCZFpzkwQn++QFWdc y2JaT4sSCOQfTCZW5r/yCDsT8dRBqnq81OuUMoeYMLj0RmdB7+B0phJZitwi9PQp9wyHmd+/r 61wdo49 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2199 Lines: 70 From: Markus Elfring 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 --- 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