All of lore.kernel.org
 help / color / mirror / Atom feed
From: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
To: Larry.Finger@lwfinger.net, florian.c.schilhabel@googlemail.com,
	gregkh@linuxfoundation.org
Cc: outreachy-kernel@googlegroups.com,
	Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Subject: [PATCH 3/4] staging: rtl8712: Refactor conditionals in r8711_wx_get_rate
Date: Fri, 10 Mar 2017 17:59:59 +0200	[thread overview]
Message-ID: <97c61822ad55d9e65bc292b6082d2247d9174916.1489161001.git.narcisaanamaria12@gmail.com> (raw)
In-Reply-To: <cover.1489161001.git.narcisaanamaria12@gmail.com>

Reduce indentation level in r8711_wx_get_rate.
This was done using the following Coccinelle script:

@disable neg_if@
expression e,E;
statement S;
@@

*if (e)
S
else { return -E; }

@disable neg_if@
expression e,E;
statement S;
identifier l;
@@

*if (e)
S
else { rc = -E; goto l; }

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 72 +++++++++++++--------------
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index add46ff..7ba8cf6 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1409,44 +1409,44 @@ static int r8711_wx_get_rate(struct net_device *dev,
 	u16 mcs_rate = 0;
 
 	i = 0;
-	if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {
-		p = r8712_get_ie(&pcur_bss->IEs[12],
-				 _HT_CAPABILITY_IE_, &ht_ielen,
-		    pcur_bss->IELength - 12);
-		if (p && ht_ielen > 0) {
-			ht_cap = true;
-			pht_capie = (struct ieee80211_ht_cap *)(p + 2);
-			memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2);
-			bw_40MHz = (le16_to_cpu(pht_capie->cap_info) &
-				    IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0;
-			short_GI = (le16_to_cpu(pht_capie->cap_info) &
-				    (IEEE80211_HT_CAP_SGI_20 |
-				    IEEE80211_HT_CAP_SGI_40)) ? 1 : 0;
-		}
-		while ((pcur_bss->rates[i] != 0) &&
-			(pcur_bss->rates[i] != 0xFF)) {
-			rate = pcur_bss->rates[i] & 0x7F;
-			if (rate > max_rate)
-				max_rate = rate;
-			wrqu->bitrate.fixed = 0;	/* no auto select */
-			wrqu->bitrate.value = rate * 500000;
-			i++;
-		}
-		if (ht_cap) {
-			if (mcs_rate & 0x8000 /* MCS15 */
-				&&
-				rf_type == RTL8712_RF_2T2R)
-				max_rate = (bw_40MHz) ? ((short_GI) ? 300 :
-					    270) : ((short_GI) ? 144 : 130);
-			else /* default MCS7 */
-				max_rate = (bw_40MHz) ? ((short_GI) ? 150 :
-					    135) : ((short_GI) ? 72 : 65);
-			max_rate *= 2; /* Mbps/2 */
-		}
-		wrqu->bitrate.value = max_rate * 500000;
-	} else {
+	if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE))
 		return -ENOLINK;
+
+	p = r8712_get_ie(&pcur_bss->IEs[12],
+			 _HT_CAPABILITY_IE_, &ht_ielen,
+	    pcur_bss->IELength - 12);
+	if (p && ht_ielen > 0) {
+		ht_cap = true;
+		pht_capie = (struct ieee80211_ht_cap *)(p + 2);
+		memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2);
+		bw_40MHz = (le16_to_cpu(pht_capie->cap_info) &
+			    IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0;
+		short_GI = (le16_to_cpu(pht_capie->cap_info) &
+			    (IEEE80211_HT_CAP_SGI_20 |
+			    IEEE80211_HT_CAP_SGI_40)) ? 1 : 0;
 	}
+	while ((pcur_bss->rates[i] != 0) &&
+		(pcur_bss->rates[i] != 0xFF)) {
+		rate = pcur_bss->rates[i] & 0x7F;
+		if (rate > max_rate)
+			max_rate = rate;
+		wrqu->bitrate.fixed = 0;	/* no auto select */
+		wrqu->bitrate.value = rate * 500000;
+		i++;
+	}
+	if (ht_cap) {
+		if (mcs_rate & 0x8000 /* MCS15 */
+			&&
+			rf_type == RTL8712_RF_2T2R)
+			max_rate = (bw_40MHz) ? ((short_GI) ? 300 :
+				    270) : ((short_GI) ? 144 : 130);
+		else /* default MCS7 */
+			max_rate = (bw_40MHz) ? ((short_GI) ? 150 :
+				    135) : ((short_GI) ? 72 : 65);
+		max_rate *= 2; /* Mbps/2 */
+	}
+	wrqu->bitrate.value = max_rate * 500000;
+
 	return 0;
 }
 
-- 
1.9.1



  parent reply	other threads:[~2017-03-10 16:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 15:58 [PATCH 0/4] staging: rtl8712: Refactor conditionals Narcisa Ana Maria Vasile
2017-03-10 15:59 ` [PATCH 1/4] staging: rtl8712: Refactor conditionals in wpa_set_encryption Narcisa Ana Maria Vasile
2017-03-10 18:21   ` [Outreachy kernel] " Julia Lawall
2017-03-10 15:59 ` [PATCH 2/4] staging: rtl8712: Refactor conditional in r8711_wx_get_freq Narcisa Ana Maria Vasile
2017-03-10 18:19   ` [Outreachy kernel] " Julia Lawall
2017-03-10 15:59 ` Narcisa Ana Maria Vasile [this message]
2017-03-10 18:15   ` [Outreachy kernel] [PATCH 3/4] staging: rtl8712: Refactor conditionals in r8711_wx_get_rate Julia Lawall
2017-03-10 16:00 ` [PATCH 4/4] staging: rtl8712: Refactor conditional in r871x_get_ap_info Narcisa Ana Maria Vasile
2017-03-10 18:08   ` [Outreachy kernel] " Julia Lawall
2017-03-10 20:37     ` Narcisa Ana Maria Vasile
2017-03-10 20:41       ` Julia Lawall
2017-03-10 18:22 ` [Outreachy kernel] [PATCH 0/4] staging: rtl8712: Refactor conditionals Julia Lawall
2017-03-18 18:33 ` [PATCH v2 0/4] staging: rtl8712: Invert if statements to reduce indentation level Narcisa Ana Maria Vasile
2017-03-18 18:34   ` [PATCH v2 1/4] " Narcisa Ana Maria Vasile
2017-03-18 18:35   ` [PATCH v2 2/4] staging: rtl8712: Invert if statement " Narcisa Ana Maria Vasile
2017-03-18 18:35   ` [PATCH v2 3/4] staging: rtl8712: Invert if statements to " Narcisa Ana Maria Vasile
2017-03-18 18:35   ` [PATCH v2 4/4] staging: rtl8712: Invert if statement " Narcisa Ana Maria Vasile
2017-03-21  7:44   ` [PATCH v2 0/4] staging: rtl8712: Invert if statements " Greg KH
2017-03-21 22:52 ` [PATCH v3 0/4] staging: rtl8712: Refactor conditionals to reduce indentation Narcisa Ana Maria Vasile
2017-03-21 22:52   ` [PATCH v3 1/4] staging: rtl8712: Invert if statements to reduce indentation level Narcisa Ana Maria Vasile
2017-03-21 22:52   ` [PATCH v3 2/4] staging: rtl8712: Invert the test on check_fwstate() to reduce indentation Narcisa Ana Maria Vasile
2017-03-21 22:53   ` [PATCH v3 3/4] staging: rtl8712: Restructure code for clarity Narcisa Ana Maria Vasile
2017-03-21 22:53   ` [PATCH v3 4/4] staging: rtl8712: Invert comparison to reduce indentation Narcisa Ana Maria Vasile

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=97c61822ad55d9e65bc292b6082d2247d9174916.1489161001.git.narcisaanamaria12@gmail.com \
    --to=narcisaanamaria12@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=florian.c.schilhabel@googlemail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=outreachy-kernel@googlegroups.com \
    /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 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.