Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752562AbbKOIqN (ORCPT ); Sun, 15 Nov 2015 03:46:13 -0500 Received: from mout.web.de ([212.227.15.4]:65468 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752014AbbKOIqK (ORCPT ); Sun, 15 Nov 2015 03:46:10 -0500 Subject: [PATCH 2/2] batman-adv: Less checks in batadv_tvlv_unicast_send() 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> <56484502.8000206@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <5648463F.3070403@users.sourceforge.net> Date: Sun, 15 Nov 2015 09:45:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <56484502.8000206@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:z5kc7u8+JEBQlfzNT9fNjsADY8ZSh0IRAzAsi1ESMGd76XEjEOj YSlJxP01tNVi5/0T5ib9SyqVh6zlvBwy3f88JYpSDEgA+fo8bm+YSg4BTmbfVR03ahKppfy /FQQwM1FNzDAtUUCCGmCsPuODFngxwau6X9kiadwaWR+oh1dVq5mCPOvuH83nSFpgQYh1LI LCZMsJSTi8yVx5YjiFN+g== X-UI-Out-Filterresults: notjunk:1;V01:K0:W9fTJqKSZ3s=:n9pHGtLfeKrbWTnmZpvly/ hBqbK1yY7YFDkr2Sm5Bq/Wb8gW75/8i7JBbQrkkcdacK4co1V422dEd8KhZOcn7J6AaUSkzEy 4C1+BA0qajJEoyiKLTFuLeqW8BBZS7yckVQUciYJGX0EnIqzV281zdVISYW6p9EoteSyotqQe 3vT5rm3Umq6CAVEbx5xGVDkrJhHilLiMK+PJEqvGB/F25ng8oE3aMAJrqyDwM/qtU26heFOpx rsmba1TrmLhagt7TqOhIALwmZrjgyOrDs4Lq8uGHXM+9gtQaTF0B1EcjEbJCeeWbjk1CbUyp/ BSM/eNvz1x+cLMRs7m7NL0Dg+r/qbGqNg2Ov9F8XrDO9ZbCuBMGC63p41XMjB7Yb26vZVI2ro eEXDTpNcLRZywjLAXmZlAmR5XRXVDNv6T0AP2eXb1rW9xnC8mbBvYOAUEPehV1PqKxYPXoBiB 45R+KE+FfDQNxo3k7k53kvCmSsWoDXx0NH3aA6blPT553S0eXeyvI3a9t2rOdE6xDj8a3bEsa HX2xCUOfHi7CFrwoOTBz6dneQfyOv2Qc77e1f4Q9O7YI77UA/AafIx57f0pIPQT8rJlYq9AD2 Qp+nQDmLx7XCfMTsTCT5nCJlcRpc+a6Wzvyx2aclv6bcmGQhGVj1kXoABLLlALpZncn4IXG6o 8FNTNDSaxg90hO2VjLKZAxyU4YkOsMgMkLXP1XgWCMdpsg/4e2c22mwWIWcb75G1osaxIL+AG Rys/VsyW1IlIzHHAVYDiPt9nT8XiCFJCMUkiWCPpBABrlp9/6NpriOWOSRaNux9+jtQpXOo5N jRL5ZkE Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1971 Lines: 64 From: Markus Elfring Date: Sun, 15 Nov 2015 09:00:42 +0100 * Let us return directly if a call of the batadv_orig_hash_find() function returned a null pointer. * Omit the initialisation for the variable "skb" at the beginning. * Replace an assignment by a call of the kfree_skb() function and delete the affected variable "ret" then. Signed-off-by: Markus Elfring --- net/batman-adv/main.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 9e9b8f6..4eaa09a 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -1143,15 +1143,14 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src, struct batadv_unicast_tvlv_packet *unicast_tvlv_packet; struct batadv_tvlv_hdr *tvlv_hdr; struct batadv_orig_node *orig_node; - struct sk_buff *skb = NULL; + struct sk_buff *skb; unsigned char *tvlv_buff; unsigned int tvlv_len; ssize_t hdr_len = sizeof(*unicast_tvlv_packet); - bool ret = false; orig_node = batadv_orig_hash_find(bat_priv, dst); if (!orig_node) - goto out; + return; tvlv_len = sizeof(*tvlv_hdr) + tvlv_value_len; @@ -1180,14 +1179,10 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src, tvlv_buff += sizeof(*tvlv_hdr); memcpy(tvlv_buff, tvlv_value, tvlv_value_len); - if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP) - ret = true; - -out: - if (!ret) + if (batadv_send_skb_to_orig(skb, orig_node, NULL) == NET_XMIT_DROP) kfree_skb(skb); - if (orig_node) - batadv_orig_node_free_ref(orig_node); +out: + batadv_orig_node_free_ref(orig_node); } /** -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/