* [PATCH] 6lowpan: Combine two condition checks into one statement in lowpan_xmit()
@ 2017-11-08 9:20 SF Markus Elfring
0 siblings, 0 replies; only message in thread
From: SF Markus Elfring @ 2017-11-08 9:20 UTC (permalink / raw)
To: linux-wpan, netdev, Alexander Aring, David S. Miller,
Johannes Berg, Stefan Schmidt, Stephen Hemminger
Cc: LKML, kernel-janitors
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-11-08 9:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-08 9:20 [PATCH] 6lowpan: Combine two condition checks into one statement in lowpan_xmit() SF Markus Elfring
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).