From: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
To: gregkh@linuxfoundation.org
Cc: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 19/21] staging: rtl8192e: Fix LONG_LINE in rtllib_parse_mife_generic()
Date: Mon, 13 Apr 2015 23:47:42 +0200 [thread overview]
Message-ID: <1428961664-4241-20-git-send-email-mateusz.kulikowski@gmail.com> (raw)
In-Reply-To: <1428961664-4241-1-git-send-email-mateusz.kulikowski@gmail.com>
Simplify function to make checkpatch.pl happy. Changes:
- Helper variables used
- Local variable names compacted
- Conditions were rephrased to return quickly (and decrease indent).
Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
---
drivers/staging/rtl8192e/rtllib_rx.c | 170 +++++++++++++++++------------------
1 file changed, 85 insertions(+), 85 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 0bf0163..2e4fd33 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1806,141 +1806,141 @@ static inline void rtllib_extract_country_ie(
}
static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
- struct rtllib_info_element *info_element,
+ struct rtllib_info_element *info,
struct rtllib_network *network,
u16 *tmp_htcap_len,
u16 *tmp_htinfo_len)
{
u16 ht_realtek_agg_len = 0;
u8 ht_realtek_agg_buf[MAX_IE_LEN];
+ struct bss_ht *bssht = &network->bssht;
- if (!rtllib_parse_qos_info_param_IE(info_element, network))
+ if (!rtllib_parse_qos_info_param_IE(info, network))
return;
- if (info_element->len >= 4 &&
- info_element->data[0] == 0x00 && info_element->data[1] == 0x50 &&
- info_element->data[2] == 0xf2 && info_element->data[3] == 0x01) {
- network->wpa_ie_len = min(info_element->len + 2,
- MAX_WPA_IE_LEN);
- memcpy(network->wpa_ie, info_element, network->wpa_ie_len);
+ if (info->len >= 4 &&
+ info->data[0] == 0x00 && info->data[1] == 0x50 &&
+ info->data[2] == 0xf2 && info->data[3] == 0x01) {
+ network->wpa_ie_len = min(info->len + 2, MAX_WPA_IE_LEN);
+ memcpy(network->wpa_ie, info, network->wpa_ie_len);
return;
}
- if (info_element->len == 7 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0xe0 && info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x01 && info_element->data[4] == 0x02)
+ if (info->len == 7 &&
+ info->data[0] == 0x00 && info->data[1] == 0xe0 &&
+ info->data[2] == 0x4c && info->data[3] == 0x01 &&
+ info->data[4] == 0x02)
network->Turbo_Enable = 1;
if (*tmp_htcap_len == 0) {
- if (info_element->len >= 4 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x90 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x033) {
- *tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
+ if (info->len >= 4 &&
+ info->data[0] == 0x00 && info->data[1] == 0x90 &&
+ info->data[2] == 0x4c && info->data[3] == 0x33) {
+ *tmp_htcap_len = min_t(u8, info->len, MAX_IE_LEN);
if (*tmp_htcap_len != 0) {
- network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
- network->bssht.bdHTCapLen = min_t(u16, *tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
- memcpy(network->bssht.bdHTCapBuf,
- info_element->data,
- network->bssht.bdHTCapLen);
+ bssht->bdHTSpecVer = HT_SPEC_VER_EWC;
+ bssht->bdHTCapLen = min_t(u16, *tmp_htcap_len,
+ sizeof(bssht->bdHTCapBuf));
+ memcpy(bssht->bdHTCapBuf, info->data,
+ bssht->bdHTCapLen);
}
}
if (*tmp_htcap_len != 0) {
- network->bssht.bdSupportHT = true;
- network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+ bssht->bdSupportHT = true;
+ bssht->bdHT1R = ((((struct ht_capab_ele *)
+ (bssht->bdHTCapBuf))->MCS[1]) == 0);
} else {
- network->bssht.bdSupportHT = false;
- network->bssht.bdHT1R = false;
+ bssht->bdSupportHT = false;
+ bssht->bdHT1R = false;
}
}
if (*tmp_htinfo_len == 0) {
- if (info_element->len >= 4 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x90 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x034) {
- *tmp_htinfo_len = min_t(u8, info_element->len,
- MAX_IE_LEN);
+ if (info->len >= 4 && info->data[0] == 0x00 &&
+ info->data[1] == 0x90 &&
+ info->data[2] == 0x4c &&
+ info->data[3] == 0x034) {
+ *tmp_htinfo_len = min_t(u8, info->len, MAX_IE_LEN);
if (*tmp_htinfo_len != 0) {
- network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
- network->bssht.bdHTInfoLen = min_t(u16, *tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
- memcpy(network->bssht.bdHTInfoBuf,
- info_element->data,
- network->bssht.bdHTInfoLen);
+ bssht->bdHTSpecVer = HT_SPEC_VER_EWC;
+ bssht->bdHTInfoLen = min_t(u16, *tmp_htinfo_len,
+ sizeof(bssht->bdHTInfoBuf));
+ memcpy(bssht->bdHTInfoBuf, info->data,
+ bssht->bdHTInfoLen);
}
}
}
if (ieee->aggregation) {
- if (network->bssht.bdSupportHT) {
- if (info_element->len >= 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0xe0 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x02) {
- ht_realtek_agg_len = min_t(u8,
- info_element->len,
+ if (bssht->bdSupportHT) {
+ if (info->len >= 4 &&
+ info->data[0] == 0x00 && info->data[1] == 0xe0 &&
+ info->data[2] == 0x4c && info->data[3] == 0x02) {
+ ht_realtek_agg_len = min_t(u8, info->len,
MAX_IE_LEN);
- memcpy(ht_realtek_agg_buf, info_element->data,
- info_element->len);
+ memcpy(ht_realtek_agg_buf, info->data,
+ info->len);
}
if (ht_realtek_agg_len >= 5) {
network->realtek_cap_exit = true;
- network->bssht.bdRT2RTAggregation = true;
+ bssht->bdRT2RTAggregation = true;
if ((ht_realtek_agg_buf[4] == 1) &&
(ht_realtek_agg_buf[5] & 0x02))
- network->bssht.bdRT2RTLongSlotTime = true;
+ bssht->bdRT2RTLongSlotTime = true;
if ((ht_realtek_agg_buf[4] == 1) &&
- (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE))
- network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE;
+ (ht_realtek_agg_buf[5] &
+ RT_HT_CAP_USE_92SE))
+ bssht->RT2RT_HT_Mode |=
+ RT_HT_CAP_USE_92SE;
}
}
if (ht_realtek_agg_len >= 5) {
if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP))
- network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP;
+ bssht->RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP;
}
}
- if ((info_element->len >= 3 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x05 && info_element->data[2] == 0xb5) ||
- (info_element->len >= 3 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x0a && info_element->data[2] == 0xf7) ||
- (info_element->len >= 3 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x10 && info_element->data[2] == 0x18)) {
+ /* For all capabilities below:
+ * - We need at least 3 bytes of info data
+ * - First byte must be 0
+ */
+ if (info->len < 3 || info->data[0] != 0x00)
+ return;
+
+ if ((info->data[1] == 0x05 && info->data[2] == 0xb5) ||
+ (info->data[1] == 0x0a && info->data[2] == 0xf7) ||
+ (info->data[1] == 0x10 && info->data[2] == 0x18)) {
network->broadcom_cap_exist = true;
}
- if (info_element->len >= 3 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x0c && info_element->data[2] == 0x43)
+ if (info->data[1] == 0x0c && info->data[2] == 0x43)
network->ralink_cap_exist = true;
- if ((info_element->len >= 3 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x03 && info_element->data[2] == 0x7f) ||
- (info_element->len >= 3 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x13 && info_element->data[2] == 0x74))
+ if ((info->data[1] == 0x03 && info->data[2] == 0x7f) ||
+ (info->data[1] == 0x13 && info->data[2] == 0x74))
network->atheros_cap_exist = true;
- if ((info_element->len >= 3 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x50 && info_element->data[2] == 0x43))
+ if (info->data[1] == 0x50 && info->data[2] == 0x43)
network->marvell_cap_exist = true;
- if (info_element->len >= 3 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x40 && info_element->data[2] == 0x96)
+ if (info->data[1] == 0x40 && info->data[2] == 0x96)
network->cisco_cap_exist = true;
- if (info_element->len >= 3 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x0a && info_element->data[2] == 0xf5)
+ if (info->data[1] == 0x0a && info->data[2] == 0xf5)
network->airgo_cap_exist = true;
- if (info_element->len > 4 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x40 && info_element->data[2] == 0x96 &&
- info_element->data[3] == 0x01) {
- if (info_element->len == 6) {
- memcpy(network->CcxRmState, &info_element[4], 2);
+ /* For all capabilities below we need at least 4 bytes of data */
+ if (info->len < 4)
+ return;
+
+ if (info->data[1] == 0x40 && info->data[2] == 0x96 &&
+ info->data[3] == 0x01) {
+ if (info->len == 6) {
+ memcpy(network->CcxRmState, &info[4], 2);
if (network->CcxRmState[0] != 0)
network->bCcxRmEnable = true;
else
@@ -1960,24 +1960,24 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
network->bCcxRmEnable = false;
}
}
- if (info_element->len > 4 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x40 && info_element->data[2] == 0x96 &&
- info_element->data[3] == 0x03) {
- if (info_element->len == 5) {
+
+ if (info->data[1] == 0x40 && info->data[2] == 0x96 &&
+ info->data[3] == 0x03) {
+ if (info->len == 5) {
network->bWithCcxVerNum = true;
- network->BssCcxVerNumber = info_element->data[4];
+ network->BssCcxVerNumber = info->data[4];
} else {
network->bWithCcxVerNum = false;
network->BssCcxVerNumber = 0;
}
}
- if (info_element->len > 4 && info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x50 && info_element->data[2] == 0xf2 &&
- info_element->data[3] == 0x04) {
+
+ if (info->data[1] == 0x50 && info->data[2] == 0xf2 &&
+ info->data[3] == 0x04) {
RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n",
- info_element->len);
- network->wzc_ie_len = min(info_element->len+2, MAX_WZC_IE_LEN);
- memcpy(network->wzc_ie, info_element, network->wzc_ie_len);
+ info->len);
+ network->wzc_ie_len = min(info->len+2, MAX_WZC_IE_LEN);
+ memcpy(network->wzc_ie, info, network->wzc_ie_len);
}
}
--
1.8.4.1
next prev parent reply other threads:[~2015-04-13 21:48 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-13 21:47 [PATCH v2 00/21] staging: rtl8192e: Fix more checkpatch.pl warnings Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 01/21] staging: rtl8192e: Fix SPACE_BEFORE_TAB warnings Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 02/21] staging: rtl8192e: Copy comments from r819XE_phyreg.h to r8192E_phyreg.h Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 03/21] staging: rtl8192e: remove r819xE_phyreg.h Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 04/21] staging: rtl8192e: Fix SPACING errors Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 05/21] staging: rtl8192e: Remove bb tx gains from r8192_priv Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 06/21] staging: rtl8192e: Fix LINE_SPACING warning Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 07/21] staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtllib_parse_info_param() Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 08/21] staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtl_dm.c Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 09/21] staging: rtl8192e: Fix DeviceID in rtl8192_pci_findadapter() Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 10/21] staging: rtl8192e: replace memcpy() -> ether_addr_copy_unaligned() Mateusz Kulikowski
2015-04-14 8:00 ` Dan Carpenter
2015-04-15 21:08 ` Mateusz Kulikowski
2015-04-15 21:36 ` Joe Perches
2015-05-03 19:10 ` Greg KH
2015-05-03 19:17 ` Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 11/21] staging: rtl8192e: Fix DEEP_INDENTATION warning in rtllib_parse_info_param() Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 12/21] staging: rtl8192e: replace memcmp() with ether_addr_equal_unaligned() Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 13/21] staging: rtl8192e: Fix PREFER_PR_LEVEL warnings Mateusz Kulikowski
2015-04-14 8:07 ` Dan Carpenter
2015-04-15 21:27 ` Mateusz Kulikowski
2015-04-14 8:09 ` Dan Carpenter
2015-04-13 21:47 ` [PATCH v2 14/21] staging: rtl8192e: Fix LONG_LINE warnings Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 15/21] staging: rtl8192e: Fix LONG_LINE warnings - modify variables Mateusz Kulikowski
2015-04-14 8:40 ` Dan Carpenter
2015-04-15 21:56 ` Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 16/21] staging: rtl8192e: Fix LONG_LING in rtllib_parse_info_param() Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 17/21] staging: rtl8192e: Fix LONG_LINE warnings (conditions) Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 18/21] staging: rtl8192e: fix LONG_LINE warnings - replace ?: expressions Mateusz Kulikowski
2015-04-13 21:47 ` Mateusz Kulikowski [this message]
2015-04-13 21:47 ` [PATCH v2 20/21] staging: rtl8192e: Fix LONG_LINE in simplify rtl8192_process_phyinfo() Mateusz Kulikowski
2015-04-13 21:47 ` [PATCH v2 21/21] staging: rtl8192e: Remove unimplemented iwpriv handlers Mateusz Kulikowski
2015-04-13 22:12 ` [PATCH v2 00/21] staging: rtl8192e: Fix more checkpatch.pl warnings Dan Carpenter
2015-04-13 22:15 ` Mateusz Kulikowski
2015-04-13 22:33 ` Dan Carpenter
2015-04-13 22:39 ` Mateusz Kulikowski
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=1428961664-4241-20-git-send-email-mateusz.kulikowski@gmail.com \
--to=mateusz.kulikowski@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®