From patchwork Wed Nov 8 09:20:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10048057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37C056032D for ; Wed, 8 Nov 2017 09:20:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31A102A4CE for ; Wed, 8 Nov 2017 09:20:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 265A72A4D3; Wed, 8 Nov 2017 09:20:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD07F2A4CE for ; Wed, 8 Nov 2017 09:20:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751106AbdKHJUf (ORCPT ); Wed, 8 Nov 2017 04:20:35 -0500 Received: from mout.web.de ([212.227.17.11]:58301 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750752AbdKHJUc (ORCPT ); Wed, 8 Nov 2017 04:20:32 -0500 Received: from [192.168.1.3] ([77.181.94.27]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Lnj7L-1esr5L02db-00hslG; Wed, 08 Nov 2017 10:20:16 +0100 To: linux-wpan@vger.kernel.org, netdev@vger.kernel.org, Alexander Aring , "David S. Miller" , Johannes Berg , Stefan Schmidt , Stephen Hemminger From: SF Markus Elfring Subject: [PATCH] 6lowpan: Combine two condition checks into one statement in lowpan_xmit() Cc: LKML , kernel-janitors@vger.kernel.org Message-ID: <221426d9-d049-b304-d7c1-bdf0a788bf36@users.sourceforge.net> Date: Wed, 8 Nov 2017 10:20:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:j11YPsFtI2t/UFxT4Nf6xWnqy8AjDDo6W7ISagGnk4Kpxfiy03M GHnHguAxmot5yDSghUTbA7yllsZ5FHSgLYK/2vMqntRLuoa+48daNSb3Ie8D2qsnGU1c1LP Dgep7mK1J0viHqyf8trm7C9GfVO0SKGCVMIDDjCt2mQcBQd+62j8ONAYu9HMa3VME8EwtAg XqBsVBcOiv5PhIOSrSneg== X-UI-Out-Filterresults: notjunk:1; V01:K0:Qee5yiEwuEA=:WsK7U1NKqYlO7RVFaDtu/1 09YKy0nQTiODSHPMRIp7bpTpP70rhFMZKZqL2yrZfL8D5DS/OOL+GxetyptAa79Eg2SZYn1VT y6iibKiC0aMsWbgysoGkvpyiywu9OUHeICs1w/9OiopmGJjdQ9i2O40+sW32wlWMvk07k3K7e 9MRDYuV1hnLuIO23Q8gWkSDPPPoVuknMBDK4BK8et7jtzWL5eKhK0ZMNprLTYDR4MlInh6opV k756+ITUJylKC0YLZFhli5SJoCpl8Vf5Kduph+DnEd2vTdtocGVQ3tr/dywjtHv2qrQnF7FnJ ZfIMeZyqI/RZy/51KgUhWgrJyobQepITBk579j4/m3QenklVMTmqbZbcsVyjMMZuS2v9qPdCl SsgGH42Dhl4joyduhiWLOWDJLL3nl1xBsg3LI6CRjsaqldxuLKBOFORa3/9FowAXpItj0Smnp vhfyJVuMbGlgheDS0HpYVpNi6Ou3uWtUA/Qd6OQmfdjzo5Bie9n6BuqjVA0Yrl26NA78LWlv/ gj5UhLiztec9O7JDZR/0EugGiU1cXeDhZC7H1SJSA/SvXI/TFFV5MJnmLfWnkHoyJy46p66CW Tq6kShhMlfUU1BBQQJ+4+ql4w6+zz4Cyz0GhfFjzQku2ywHkciYP4nwlC0B0Q0NHhW5lt0ni8 uRACVXyXuBey+GUsSaSMrR6HVRDVtf0u9u+/biAAcKCoRAlgf/tu6e+0D4YcE4UAdbwgaMN7c JgBOQqJH85TRCTeETDNG3PJJUBGzvOWqCMjaVzxPjQU9zBgyyEeqCXAR891rIIgPUDzfsikPD ZvDuKnRvYaEqifuNX7y2vZTOTnmpNTSfKwmW6fcEspJ/LiJUEs= Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Wed, 8 Nov 2017 10:10:41 +0100 The same exception handling was used in an if branch of two separate statements. * Merge their condition checks into a single statement instead. * Delete the local variable "ret" which became unnecessary with this refactoring. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- net/ieee802154/6lowpan/tx.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c index e6ff5128e61a..1b0757db2078 100644 --- a/net/ieee802154/6lowpan/tx.c +++ b/net/ieee802154/6lowpan/tx.c @@ -255,7 +255,7 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *ldev, netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev) { struct ieee802154_hdr wpan_hdr; - int max_single, ret; + int max_single; u16 dgram_size, dgram_offset; pr_debug("package xmit\n"); @@ -269,13 +269,8 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev) if (!skb) return NET_XMIT_DROP; - ret = lowpan_header(skb, ldev, &dgram_size, &dgram_offset); - if (ret < 0) { - kfree_skb(skb); - return NET_XMIT_DROP; - } - - if (ieee802154_hdr_peek(skb, &wpan_hdr) < 0) { + if (lowpan_header(skb, ldev, &dgram_size, &dgram_offset) < 0 || + ieee802154_hdr_peek(skb, &wpan_hdr) < 0) { kfree_skb(skb); return NET_XMIT_DROP; }