All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192u: ieee80211: Move assignment out of the if.
@ 2016-10-19 22:13 Elise Lennion
  0 siblings, 0 replies; 2+ messages in thread
From: Elise Lennion @ 2016-10-19 22:13 UTC (permalink / raw)
  To: gregkh, outreachy-kernel

Actually, I want to cancel this patch, since C uses short-circuiting on
&& operators and the assignment is the third verification.

sorry,

elise


^ permalink raw reply	[flat|nested] 2+ messages in thread
* [PATCH] staging: rtl8192u: ieee80211: Move assignment out of the if.
@ 2016-10-19 21:56 Elise Lennion
  0 siblings, 0 replies; 2+ messages in thread
From: Elise Lennion @ 2016-10-19 21:56 UTC (permalink / raw)
  To: gregkh, outreachy-kernel

Assignments inside of if statements confuse the reader and should be
avoided, so it was moved out before the if.

Found with Coccinelle, semantic patch:
@@
expression e1, e2;
statement S;
position p;
@@

+ e1 = e2;
if (<+...
- (e1 = e2)
 @p
+ e1
 ...+>)
S

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index 89cbc07..0d81b3a 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -1145,8 +1145,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 
 	/* skb: hdr + (possibly fragmented, possibly encrypted) payload */
 
-	if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
-	    (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
+	keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt);
+	if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) && keyidx < 0)
 	{
 		printk("decrypt frame error\n");
 		goto rx_dropped;
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-19 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-19 22:13 [PATCH] staging: rtl8192u: ieee80211: Move assignment out of the if Elise Lennion
  -- strict thread matches above, loose matches on Subject: below --
2016-10-19 21:56 Elise Lennion

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.