Commit 8f284d79 authored by Simon Schuster's avatar Simon Schuster Committed by Greg Kroah-Hartman

Staging: vt6656: Combined nested conditions

This patch reduces the level of indentation in bssdb.c of the vt6656
driver by transforming nested conditions to a series of logical
conjunctions. E.g.

if (cond1) {
        if (cond2) {
                block();
        }
}

is transformed to

if (cond1 && cond2) {
        block();
}
Signed-off-by: default avatarSebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: default avatarSimon Schuster <linux@rationality.eu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b7fce6ae
......@@ -107,10 +107,9 @@ PKnownBSS BSSpSearchBSSList(struct vnt_private *pDevice,
(memcmp(pbyDesireBSSID, ZeroBSSID, 6) != 0))
pbyBSSID = pbyDesireBSSID;
}
if (pbyDesireSSID != NULL) {
if (((PWLAN_IE_SSID) pbyDesireSSID)->len != 0)
if ((pbyDesireSSID != NULL) &&
(((PWLAN_IE_SSID) pbyDesireSSID)->len != 0))
pSSID = (PWLAN_IE_SSID) pbyDesireSSID;
}
if ((pbyBSSID != NULL) && (pDevice->bRoaming == false)) {
/* match BSSID first */
......@@ -120,21 +119,22 @@ PKnownBSS BSSpSearchBSSList(struct vnt_private *pDevice,
pCurrBSS->bSelected = false;
if ((pCurrBSS->bActive) &&
(pCurrBSS->bSelected == false)) {
if (ether_addr_equal(pCurrBSS->abyBSSID, pbyBSSID)) {
(pCurrBSS->bSelected == false) &&
(ether_addr_equal(pCurrBSS->abyBSSID, pbyBSSID))) {
if (pSSID != NULL) {
/* compare ssid */
if (!memcmp(pSSID->abySSID,
if ((!memcmp(pSSID->abySSID,
((PWLAN_IE_SSID) pCurrBSS->abySSID)->abySSID,
pSSID->len)) {
if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))
) {
pSSID->len)) &&
((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) &&
WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) &&
WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)))) {
pCurrBSS->bSelected = true;
return pCurrBSS;
}
}
} else if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))) {
......@@ -143,7 +143,6 @@ PKnownBSS BSSpSearchBSSList(struct vnt_private *pDevice,
}
}
}
}
} else {
/* ignore BSSID */
for (ii = 0; ii < MAX_BSS_NUM; ii++) {
......@@ -156,16 +155,17 @@ PKnownBSS BSSpSearchBSSList(struct vnt_private *pDevice,
pCurrBSS->bSelected = false;
if (pCurrBSS->bActive) {
if (pSSID != NULL) {
if ((pSSID != NULL) &&
/* matched SSID */
if (memcmp(pSSID->abySSID,
(memcmp(pSSID->abySSID,
((PWLAN_IE_SSID) pCurrBSS->abySSID)->abySSID,
pSSID->len) ||
(pSSID->len != ((PWLAN_IE_SSID) pCurrBSS->abySSID)->len)) {
(pSSID->len !=
((PWLAN_IE_SSID) pCurrBSS->abySSID)->len))) {
/* SSID not match skip this BSS */
continue;
}
}
if (((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) ||
((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo))
) {
......@@ -174,14 +174,15 @@ PKnownBSS BSSpSearchBSSList(struct vnt_private *pDevice,
continue;
}
if (ePhyType != PHY_TYPE_AUTO) {
if (((ePhyType == PHY_TYPE_11A) && (PHY_TYPE_11A != pCurrBSS->eNetworkTypeInUse)) ||
((ePhyType != PHY_TYPE_11A) && (PHY_TYPE_11A == pCurrBSS->eNetworkTypeInUse))) {
if ((ePhyType != PHY_TYPE_AUTO) &&
(((ePhyType == PHY_TYPE_11A) &&
(PHY_TYPE_11A != pCurrBSS->eNetworkTypeInUse)) ||
((ePhyType != PHY_TYPE_11A) &&
(PHY_TYPE_11A == pCurrBSS->eNetworkTypeInUse)))) {
/* PhyType not match skip this BSS */
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Physical type mismatch.... ePhyType[%d] BSS[%d]\n", ePhyType, pCurrBSS->eNetworkTypeInUse);
continue;
}
}
pMgmt->pSameBSS[jj].uChannel = pCurrBSS->uChannel;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
......@@ -228,8 +229,8 @@ void BSSvClearBSSList(struct vnt_private *pDevice, int bKeepCurrBSSID)
int ii;
for (ii = 0; ii < MAX_BSS_NUM; ii++) {
if (bKeepCurrBSSID) {
if (pMgmt->sBSSList[ii].bActive &&
if (bKeepCurrBSSID &&
pMgmt->sBSSList[ii].bActive &&
ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID,
pMgmt->abyCurrBSSID)) {
......@@ -243,7 +244,6 @@ void BSSvClearBSSList(struct vnt_private *pDevice, int bKeepCurrBSSID)
continue;
}
}
pMgmt->sBSSList[ii].bActive = false;
memset(&pMgmt->sBSSList[ii], 0, sizeof(KnownBSS));
......@@ -268,17 +268,14 @@ PKnownBSS BSSpAddrIsInBSSList(struct vnt_private *pDevice,
for (ii = 0; ii < MAX_BSS_NUM; ii++) {
pBSSList = &(pMgmt->sBSSList[ii]);
if (pBSSList->bActive) {
if (ether_addr_equal(pBSSList->abyBSSID, abyBSSID)) {
if (pSSID->len == ((PWLAN_IE_SSID) pBSSList->abySSID)->len) {
if (memcmp(pSSID->abySSID,
if ((pBSSList->bActive) &&
(ether_addr_equal(pBSSList->abyBSSID, abyBSSID)) &&
(pSSID->len == ((PWLAN_IE_SSID) pBSSList->abySSID)->len) &&
(memcmp(pSSID->abySSID,
((PWLAN_IE_SSID) pBSSList->abySSID)->abySSID,
pSSID->len) == 0)
pSSID->len) == 0))
return pBSSList;
}
}
}
}
return NULL;
}
......@@ -371,11 +368,10 @@ int BSSbInsertToBSSList(struct vnt_private *pDevice,
pBSSList->bySQ = pRxPacket->bySQ;
if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
(pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
(pMgmt->eCurrState == WMAC_STATE_ASSOC) &&
/* assoc with BSS */
if (pBSSList == pMgmt->pCurrBSS)
(pBSSList == pMgmt->pCurrBSS))
bParsingQuiet = true;
}
WPA_ClearRSN(pBSSList);
......@@ -421,13 +417,19 @@ int BSSbInsertToBSSList(struct vnt_private *pDevice,
pBSSList->abyBSSID,
&pBSSList->sRSNCapObj);
if ((pDevice->bLinkPass == true) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
if ((KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) == true) ||
(KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey) == true)) {
if ((pDevice->bLinkPass == true) &&
(pMgmt->eCurrState == WMAC_STATE_ASSOC) &&
((KeybGetTransmitKey(&(pDevice->sKey),
pDevice->abyBSSID,
PAIRWISE_KEY,
&pTransmitKey) == true) ||
(KeybGetTransmitKey(&(pDevice->sKey),
pDevice->abyBSSID,
GROUP_KEY,
&pTransmitKey) == true))) {
pDevice->gsPMKIDCandidate.StatusType = Ndis802_11StatusType_PMKID_CandidateList;
pDevice->gsPMKIDCandidate.Version = 1;
}
}
}
......@@ -524,11 +526,10 @@ int BSSbUpdateToBSSList(struct vnt_private *pDevice,
pBSSList->bySQ = pRxPacket->bySQ;
if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
(pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
(pMgmt->eCurrState == WMAC_STATE_ASSOC) &&
/* assoc with BSS */
if (pBSSList == pMgmt->pCurrBSS)
(pBSSList == pMgmt->pCurrBSS))
bParsingQuiet = true;
}
WPA_ClearRSN(pBSSList); /* mike update */
......@@ -597,14 +598,13 @@ int BSSbIsSTAInNodeDB(struct vnt_private *pDevice,
/* Index = 0 reserved for AP Node */
for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
if (pMgmt->sNodeDBTable[ii].bActive) {
if (ether_addr_equal(abyDstAddr,
pMgmt->sNodeDBTable[ii].abyMACAddr)) {
if ((pMgmt->sNodeDBTable[ii].bActive) &&
(ether_addr_equal(abyDstAddr,
pMgmt->sNodeDBTable[ii].abyMACAddr))) {
*puNodeIndex = ii;
return true;
}
}
}
return false;
};
......@@ -1064,9 +1064,9 @@ void BSSvSecondCallBack(struct work_struct *work)
}
if (pDevice->bLinkPass == true) {
if (pMgmt->eAuthenMode < WMAC_AUTH_WPA ||
pDevice->fWPA_Authened == true) {
if (++pDevice->tx_data_time_out > 40) {
if ((pMgmt->eAuthenMode < WMAC_AUTH_WPA ||
pDevice->fWPA_Authened == true) &&
(++pDevice->tx_data_time_out > 40)) {
pDevice->tx_trigger = true;
PSbSendNullPacket(pDevice);
......@@ -1074,7 +1074,6 @@ void BSSvSecondCallBack(struct work_struct *work)
pDevice->tx_trigger = false;
pDevice->tx_data_time_out = 0;
}
}
if (netif_queue_stopped(pDevice->dev))
netif_wake_queue(pDevice->dev);
......@@ -1177,12 +1176,11 @@ void BSSvUpdateNodeTxCounter(struct vnt_private *pDevice, u8 byTSR, u8 byPktNO)
}
}
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
(pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
if (BSSbIsSTAInNodeDB((void *) pDevice,
if (((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
(pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) &&
(BSSbIsSTAInNodeDB((void *) pDevice,
pbyDestAddr,
&uNodeIndex)) {
&uNodeIndex))) {
pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts += 1;
if (!(byTSR & (TSR_TMO | TSR_RETRYTMO))) {
/* transmit success, TxAttempts at least plus one */
......@@ -1233,7 +1231,6 @@ void BSSvUpdateNodeTxCounter(struct vnt_private *pDevice, u8 byTSR, u8 byPktNO)
}
}
}
}
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment