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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ee7ae7337f398ebd7aae6018762915ae8ba4766e.1441955761.git.raphael.beamonte@gmail.com>
Date:	Fri, 11 Sep 2015 03:29:11 -0400
From:	Raphaël Beamonte <raphael.beamonte@...il.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:	Dan Carpenter <dan.carpenter@...cle.com>,
	Raphaël Beamonte <raphael.beamonte@...il.com>,
	Cristina Opriceana <cristina.opriceana@...il.com>,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters

Add some temporary variables to reduce line length under the maximum
of 80 characters, as per the kernel code style.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@...il.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 139 ++++++++++++++++++++++-----------
 1 file changed, 94 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 37c17eb..c8724cd 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -177,6 +177,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 {
 	int i, max_chan = -1, min_chan = -1;
 	struct ieee80211_device *ieee = priv->ieee80211;
+	struct CHANNEL_LIST cl;
 
 	switch (channel_plan) {
 	case COUNTRY_CODE_FCC:
@@ -200,15 +201,18 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 				 "unknown rf chip, can't set channel map in function:%s()\n",
 				 __func__);
 		}
-		if (ChannelPlan[channel_plan].Len != 0) {
+		cl = ChannelPlan[channel_plan];
+		if (cl.Len != 0) {
 			/* Clear old channel map */
 			memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
 			       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
 			/* Set new channel map */
-			for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
-				if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
+			for (i = 0; i < cl.Len; i++) {
+				u8 chan = cl.Channel[i];
+
+				if (chan < min_chan || chan > max_chan)
 					break;
-				GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
+				GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
 			}
 		}
 		break;
@@ -1699,9 +1703,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 					  &zero, 0, tx_zero_isr, dev);
 			status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
 			if (status) {
+				atomic_t tx =
+					priv->tx_pending[tcb_desc->queue_index];
+
 				RT_TRACE(COMP_ERR,
 					 "Error TX URB for zero byte %d, error %d",
-					 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
+					 atomic_read(&tx),
 					 status);
 				return -1;
 			}
@@ -1748,8 +1755,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
 		oldaddr = priv->oldaddr;
 		align = ((long)oldaddr) & 3;
 		if (align) {
-			newaddr = oldaddr + 4 - align;
-			priv->rx_urb[16]->transfer_buffer_length = 16 - 4 + align;
+			align = 4 - align;
+			newaddr = oldaddr + align;
+			priv->rx_urb[16]->transfer_buffer_length = 16 - align;
 		} else {
 			newaddr = oldaddr;
 			priv->rx_urb[16]->transfer_buffer_length = 16;
@@ -1913,7 +1921,9 @@ static void rtl8192_qos_activate(struct work_struct *work)
 	 */
 	for (i = 0; i <  QOS_QUEUE_NUM; i++) {
 		/* Mode G/A: slotTimeTimer = 9; Mode B: 20 */
-		u1bAIFS = qos_parameters->aifs[i] * ((mode & (IEEE_G | IEEE_N_24G)) ? 9 : 20) + aSifsTime;
+		int slotTimeTimer = ((mode & (IEEE_G | IEEE_N_24G)) ? 9 : 20);
+
+		u1bAIFS = qos_parameters->aifs[i] * slotTimeTimer + aSifsTime;
 		u1bAIFS <<= AC_PARAM_AIFS_OFFSET;
 		op_limit = (u32)le16_to_cpu(qos_parameters->tx_op_limit[i]);
 		op_limit <<= AC_PARAM_TXOP_LIMIT_OFFSET;
@@ -2121,10 +2131,12 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev)
 		return false;
 	} else if ((wpa_ie_len != 0)) {
 		/* parse pairwise key type */
-		if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) || ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
-			return true;
-		else
-			return false;
+		bool wpaie_dd = (ieee->wpa_ie[0] == 0xdd &&
+				 !memcmp(&ieee->wpa_ie[14], ccmp_ie, 4));
+		bool wpaie_30 = (ieee->wpa_ie[0] == 0x30 &&
+				 !memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4));
+
+		return (wpaie_dd || wpaie_30);
 	} else {
 		return true;
 	}
@@ -2470,9 +2482,9 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 		int i;
 
 		for (i = 0; i < 6; i += 2) {
-			u16 tmp = 0;
+			u16 tmp = ((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1);
 
-			tmp = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1));
+			tmp = eprom_read(dev, tmp);
 			*(u16 *)(&dev->dev_addr[i]) = tmp;
 		}
 	} else {
@@ -3002,9 +3014,11 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 			u32 tmpRegA = rtl8192_QueryBBReg(dev,
 							 rOFDM0_XATxIQImbalance,
 							 bMaskDWord);
+			txbbgain_struct *tx = priv->txbbgain_table;
+			ccktxbbgain_struct *cck = priv->cck_txbbgain_table;
 
 			for (i = 0; i < TxBBGainTableLength; i++) {
-				if (tmpRegA == priv->txbbgain_table[i].txbbgain_value) {
+				if (tmpRegA == tx[i].txbbgain_value) {
 					priv->rfa_txpowertrackingindex = (u8)i;
 					priv->rfa_txpowertrackingindex_real =
 						(u8)i;
@@ -3019,8 +3033,7 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 						     bMaskByte2);
 
 			for (i = 0; i < CCKTxBBGainTableLength; i++) {
-
-				if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) {
+				if (TempCCk == cck[i].ccktxbb_valuearray[0]) {
 					priv->cck_present_attentuation_20Mdefault = (u8)i;
 					break;
 				}
@@ -3080,13 +3093,15 @@ static RESET_TYPE TxCheckStuck(struct net_device *dev)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	u8			QueueID;
 	bool			bCheckFwTxCnt = false;
+	struct ieee80211_device *ieee = priv->ieee80211;
 
 	/* Decide such threshold according to current power save mode */
 
 	for (QueueID = 0; QueueID <= BEACON_QUEUE; QueueID++) {
 		if (QueueID == TXCMD_QUEUE)
 			continue;
-		if ((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0)  && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0))
+		if (skb_queue_len(&ieee->skb_waitQ[QueueID]) == 0 &&
+		    skb_queue_len(&ieee->skb_aggQ[QueueID]) == 0)
 			continue;
 
 		bCheckFwTxCnt = true;
@@ -3107,6 +3122,8 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	bool bStuck = false;
 	static u8	rx_chk_cnt;
+	long pwdb = priv->undecorated_smoothed_pwdb;
+	bool channelWidth20;
 
 	read_nic_word(dev, 0x130, &RegRxCounter);
 	RT_TRACE(COMP_RESET,
@@ -3116,18 +3133,21 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 	 * or maybe it will continuous silent reset every 2 seconds.
 	 */
 	rx_chk_cnt++;
-	if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High + 5)) {
+
+	channelWidth20 = (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20);
+
+	if (pwdb >= (RateAdaptiveTH_High + 5)) {
 		rx_chk_cnt = 0;	/* high rssi, check rx stuck right now. */
-	} else if (priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High + 5) &&
-		   ((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M) ||
-		    (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M))) {
+	} else if (pwdb < (RateAdaptiveTH_High + 5) &&
+		   ((!channelWidth20 && pwdb >= RateAdaptiveTH_Low_40M) ||
+		    (channelWidth20 && pwdb >= RateAdaptiveTH_Low_20M))) {
 		if (rx_chk_cnt < 2)
 			return bStuck;
 
 		rx_chk_cnt = 0;
-	} else if (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M) ||
-		    (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M)) &&
-		     priv->undecorated_smoothed_pwdb >= VeryLowRSSI) {
+	} else if (((!channelWidth20 && pwdb < RateAdaptiveTH_Low_40M) ||
+		    (channelWidth20 && pwdb < RateAdaptiveTH_Low_20M)) &&
+		     pwdb >= VeryLowRSSI) {
 		if (rx_chk_cnt < 4)
 			return bStuck;
 
@@ -3443,6 +3463,7 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 	bool bBusyTraffic = false;
 	u32	TotalRxBcnNum = 0;
 	u32	TotalRxDataNum = 0;
+	bool resetSilent;
 
 	if (!priv->up)
 		return;
@@ -3488,10 +3509,14 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 		ResetType = rtl819x_ifcheck_resetornot(dev);
 		check_reset_cnt = 3;
 	}
+
 	/* This is control by OID set in Pomelo */
-	if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET &&
-	    (priv->bForcedSilentReset ||
-	    (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_SILENT)))) {
+	resetSilent = (!priv->bDisableNormalResetCheck &&
+		       ResetType == RESET_TYPE_SILENT);
+	resetSilent = (priv->bForcedSilentReset || resetSilent);
+
+	if (priv->force_reset ||
+	    (priv->ResetProgress == RESET_TYPE_NORESET && resetSilent)) {
 		RT_TRACE(COMP_RESET,
 			 "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",
 			 __func__, priv->force_reset, priv->ResetProgress,
@@ -4254,7 +4279,7 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc;
 	u8	*prxpkt;
 	u8	i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
-	char	rx_pwr[4], rx_pwr_all = 0;
+	char	rx_pwr[4], rx_pwr_all = 0, tmp;
 	char	rx_snrX, rx_evmX;
 	u8	evm, pwdb_all;
 	u32	RSSI, total_rssi = 0;
@@ -4303,35 +4328,37 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 		if (!priv->bCckHighPower) {
 			report = pcck_buf->cck_agc_rpt & 0xc0;
 			report >>= 6;
+			tmp = pcck_buf->cck_agc_rpt & 0x3e;
 			switch (report) {
 			case 0x3:
-				rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = -35 - tmp;
 				break;
 			case 0x2:
-				rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = -23 - tmp;
 				break;
 			case 0x1:
-				rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = -11 - tmp;
 				break;
 			case 0x0:
-				rx_pwr_all = 6 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = 6 - tmp;
 				break;
 			}
 		} else {
 			report = pcck_buf->cck_agc_rpt & 0x60;
 			report >>= 5;
+			tmp = (pcck_buf->cck_agc_rpt & 0x1f) << 1;
 			switch (report) {
 			case 0x3:
-				rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = -35 - tmp;
 				break;
 			case 0x2:
-				rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = -23 - tmp;
 				break;
 			case 0x1:
-				rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = -11 - tmp;
 				break;
 			case 0x0:
-				rx_pwr_all = 6 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = 6 - tmp;
 				break;
 			}
 		}
@@ -4460,9 +4487,11 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	} else {
 		/* We can judge RX path number now. */
 		if (rf_rx_num != 0) {
+			long currsig = (total_rssi /= rf_rx_num);
+
 			pstats->SignalStrength =
 				precord_stats->SignalStrength =
-				(u8)(rtl819x_signal_scale_mapping((long)(total_rssi /= rf_rx_num)));
+				(u8)(rtl819x_signal_scale_mapping(currsig));
 		}
 	}
 }	/* QueryRxPhyStatus8190Pci */
@@ -4492,6 +4521,8 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	static struct ieee80211_rx_stats  previous_stats;
 	struct rtl_80211_hdr_3addr *hdr;
 	u16 fc, type;
+	u8 *addr;
+	bool bssid_eq_addr;
 
 	/* Get Signal Quality for only RX data queue (but not command queue) */
 
@@ -4506,10 +4537,19 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	type = WLAN_FC_GET_TYPE(fc);
 	praddr = hdr->addr1;
 
+	if (fc & IEEE80211_FCTL_TODS)
+		addr = hdr->addr1;
+	else if (fc & IEEE80211_FCTL_FROMDS)
+		addr = hdr->addr2;
+	else
+		addr = hdr->addr3;
+
+	bssid_eq_addr = eqMacAddr(priv->ieee80211->current_network.bssid, addr);
+
 	/* Check if the received packet is acceptable. */
 	bpacket_match_bssid = (IEEE80211_FTYPE_CTL != type) &&
-			       (eqMacAddr(priv->ieee80211->current_network.bssid,  (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3))
-			       && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV);
+			       bssid_eq_addr && (!pstats->bHwError) &&
+			       (!pstats->bCRC) && (!pstats->bICV);
 	bpacket_toself =  bpacket_match_bssid &
 			  (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
 
@@ -4781,9 +4821,10 @@ static void rtl8192_rx_nomal(struct sk_buff *skb)
 	u32 rx_pkt_len = 0;
 	struct rtl_80211_hdr_1addr *ieee80211_hdr = NULL;
 	bool unicast_packet = false;
+	int size = 20 + sizeof(rx_desc_819x_usb);
 
 	/* 20 is for ps-poll */
-	if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+	if ((skb->len >= size) && (skb->len < RX_URB_SIZE)) {
 		/* first packet should not contain Rx aggregation header */
 		query_rxdesc_status(skb, &stats, false);
 		/* TODO */
@@ -4889,8 +4930,9 @@ static void rtl8192_rx_cmd(struct sk_buff *skb)
 		.rate = 0,
 		.freq = IEEE80211_24GHZ_BAND,
 	};
+	int size = 20 + sizeof(rx_desc_819x_usb);
 
-	if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+	if ((skb->len >= size) && (skb->len < RX_URB_SIZE)) {
 
 		query_rx_cmdpkt_desc_status(skb, &stats);
 		/* prfd->queue_id = 1; */
@@ -5131,11 +5173,17 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
 	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 	struct ieee80211_device *ieee = priv->ieee80211;
 
+	bool ktype_wep = (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
+			 (KEY_TYPE_WEP104 == ieee->pairwise_key_type);
+	bool ktype_ccmp_tkip = ieee->pairwise_key_type
+			       & (KEY_TYPE_CCMP | KEY_TYPE_TKIP);
+
 	SECR_value = SCR_TxEncEnable | SCR_RxDecEnable;
-	if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) {
+
+	if (ktype_wep && (priv->ieee80211->auth_mode != 2)) {
 		SECR_value |= SCR_RxUseDK;
 		SECR_value |= SCR_TxUseDK;
-	} else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) {
+	} else if (ktype_ccmp_tkip && (ieee->iw_mode == IW_MODE_ADHOC)) {
 		SECR_value |= SCR_RxUseDK;
 		SECR_value |= SCR_TxUseDK;
 	}
@@ -5202,7 +5250,8 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
 		} else {
 			/* Key Material */
 			if (KeyContent != NULL) {
-				write_nic_dword(dev, WCAMI, (u32)(*(KeyContent + i - 2)));
+				TargetContent = (u32)(*(KeyContent + i - 2));
+				write_nic_dword(dev, WCAMI, TargetContent);
 				write_nic_dword(dev, RWCAM, TargetCommand);
 			}
 		}
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ