lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 15 Mar 2018 23:30:31 -0700
From:   Quytelda Kahja <quytelda@...alin.org>
To:     gregkh@...uxfoundation.org, wsa@...-dreams.de
Cc:     driverdev-devel@...uxdriverproject.org, devel@...verdev.osuosl.org,
        linux-kernel@...r.kernel.org, Quytelda Kahja <quytelda@...alin.org>
Subject: [PATCH 2/6] staging: ks7010: Factor out code into helper methods.

Some cases in the switch statement in get_ap_information() are indented
as much as five levels, which makes the code difficult to read because
of all the wrapping.  Factor them out into helper methods.

Signed-off-by: Quytelda Kahja <quytelda@...alin.org>
---
 drivers/staging/ks7010/ks_hostif.c | 46 +++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index a946ce76f899..948d45280d18 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -238,6 +238,30 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body, char *name)
 	return size;
 }
 
+static void read_ie_ext_supp_rates(struct local_ap_t *ap, unsigned char *bp)
+{
+	if ((*(bp + 1) + ap->rate_set.size) <= RATE_SET_MAX_SIZE) {
+		memcpy(&ap->rate_set.body[ap->rate_set.size],
+		       bp + 2, *(bp + 1));
+		ap->rate_set.size += *(bp + 1);
+	} else {
+		DPRINTK(1, "size over :: rate size=%d\n",
+			(*(bp + 1) + ap->rate_set.size));
+		memcpy(&ap->rate_set.body[ap->rate_set.size], bp + 2,
+		       RATE_SET_MAX_SIZE - ap->rate_set.size);
+		ap->rate_set.size += (RATE_SET_MAX_SIZE - ap->rate_set.size);
+	}
+}
+
+static void read_ie_wpa(struct local_ap_t *ap, unsigned char *bp)
+{
+	if (memcmp(bp + 2, CIPHER_ID_WPA_WEP40, 4) == 0) { /* WPA OUI check */
+		ap->wpa_ie.id = *bp;
+		ap->wpa_ie.size = read_ie(bp, RSN_IE_BODY_MAX,
+					  ap->wpa_ie.body, "wpa");
+	}
+}
+
 static
 int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
 		       struct local_ap_t *ap)
@@ -273,20 +297,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
 			break;
 		case WLAN_EID_SUPP_RATES:
 		case WLAN_EID_EXT_SUPP_RATES:
-			if ((*(bp + 1) + ap->rate_set.size) <=
-			    RATE_SET_MAX_SIZE) {
-				memcpy(&ap->rate_set.body[ap->rate_set.size],
-				       bp + 2, *(bp + 1));
-				ap->rate_set.size += *(bp + 1);
-			} else {
-				DPRINTK(1, "size over :: rate size=%d\n",
-					(*(bp + 1) + ap->rate_set.size));
-				memcpy(&ap->rate_set.body[ap->rate_set.size],
-				       bp + 2,
-				       RATE_SET_MAX_SIZE - ap->rate_set.size);
-				ap->rate_set.size +=
-				    (RATE_SET_MAX_SIZE - ap->rate_set.size);
-			}
+			read_ie_ext_supp_rates(ap, bp);
 			break;
 		case WLAN_EID_DS_PARAMS:
 			break;
@@ -296,12 +307,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
 						  ap->rsn_ie.body, "rsn");
 			break;
 		case WLAN_EID_VENDOR_SPECIFIC: /* WPA */
-			if (memcmp(bp + 2, CIPHER_ID_WPA_WEP40, 4) == 0) { /* WPA OUI check */
-				ap->wpa_ie.id = *bp;
-				ap->wpa_ie.size = read_ie(bp, RSN_IE_BODY_MAX,
-							  ap->wpa_ie.body,
-							  "wpa");
-			}
+			read_ie_wpa(ap, bp);
 			break;
 
 		case WLAN_EID_FH_PARAMS:
-- 
2.16.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ