From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-wpan@vger.kernel.org, netdev@vger.kernel.org,
Alexander Aring <alex.aring@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Johannes Berg <johannes.berg@intel.com>,
Stefan Schmidt <stefan@osg.samsung.com>,
Stephen Hemminger <stephen@networkplumber.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] 6lowpan: Combine two condition checks into one statement in lowpan_xmit()
Date: Wed, 8 Nov 2017 10:20:08 +0100 [thread overview]
Message-ID: <221426d9-d049-b304-d7c1-bdf0a788bf36@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
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;
}
--
2.15.0
reply other threads:[~2017-11-08 9:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=221426d9-d049-b304-d7c1-bdf0a788bf36@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alex.aring@gmail.com \
--cc=davem@davemloft.net \
--cc=johannes.berg@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stefan@osg.samsung.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).