mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 01:21:58 +00:00
staging: rtl8723au: Reorganize a few functions to remove indentation
Prior to this commit, functions rtw_tkip_encrypt23a and rtw_tkip_decrypt23a had large if blocks which contained the majority of the logic in the functions. Rework these functions so that if the negated version of the aforementioned if blocks' conditions are true, we return from the function with _FAIL, as expected by the calling code. This lets us remove two levels of indentation from the functions in question, making them more readable. Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a239023958
commit
c3cc7593ec
1 changed files with 122 additions and 123 deletions
|
@ -615,14 +615,16 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
|
|||
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||
int res = _SUCCESS;
|
||||
|
||||
if (pattrib->encrypt != WLAN_CIPHER_SUITE_TKIP)
|
||||
return _FAIL;
|
||||
|
||||
if (!pxmitframe->buf_addr)
|
||||
return _FAIL;
|
||||
|
||||
hw_hdr_offset = TXDESC_OFFSET;
|
||||
|
||||
pframe = pxmitframe->buf_addr + hw_hdr_offset;
|
||||
/* 4 start to encrypt each fragment */
|
||||
if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
|
||||
|
||||
if (pattrib->psta)
|
||||
stainfo = pattrib->psta;
|
||||
else {
|
||||
|
@ -631,16 +633,21 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
|
|||
&pattrib->ra[0]);
|
||||
}
|
||||
|
||||
if (stainfo != NULL) {
|
||||
|
||||
if (!(stainfo->state & _FW_LINKED)) {
|
||||
DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state);
|
||||
if (stainfo == NULL) {
|
||||
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
|
||||
"rtw_tkip_encrypt23a: stainfo == NULL!!!\n");
|
||||
DBG_8723A("%s, psta == NUL\n", __func__);
|
||||
return _FAIL;
|
||||
}
|
||||
|
||||
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
|
||||
"rtw_tkip_encrypt23a: stainfo!= NULL!!!\n");
|
||||
|
||||
if (!(stainfo->state & _FW_LINKED)) {
|
||||
DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state);
|
||||
return _FAIL;
|
||||
}
|
||||
|
||||
if (is_multicast_ether_addr(pattrib->ra))
|
||||
prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
|
||||
else
|
||||
|
@ -648,6 +655,7 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
|
|||
|
||||
prwskeylen = 16;
|
||||
|
||||
/* 4 start to encrypt each fragment */
|
||||
for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
|
||||
iv = pframe + pattrib->hdrlen;
|
||||
payload = pframe + pattrib->iv_len + pattrib->hdrlen;
|
||||
|
@ -693,15 +701,6 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
|
|||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
|
||||
"rtw_tkip_encrypt23a: stainfo == NULL!!!\n");
|
||||
DBG_8723A("%s, psta == NUL\n", __func__);
|
||||
res = _FAIL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -725,15 +724,20 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
|
|||
struct sk_buff *skb = precvframe->pkt;
|
||||
int res = _SUCCESS;
|
||||
|
||||
pframe = skb->data;
|
||||
if (prxattrib->encrypt != WLAN_CIPHER_SUITE_TKIP)
|
||||
return _FAIL;
|
||||
|
||||
/* 4 start to decrypt recvframe */
|
||||
if (prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
|
||||
pframe = skb->data;
|
||||
|
||||
stainfo = rtw_get_stainfo23a(&padapter->stapriv,
|
||||
&prxattrib->ta[0]);
|
||||
if (stainfo != NULL) {
|
||||
if (stainfo == NULL) {
|
||||
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
|
||||
"rtw_tkip_decrypt23a: stainfo == NULL!!!\n");
|
||||
return _FAIL;
|
||||
}
|
||||
|
||||
/* 4 start to decrypt recvframe */
|
||||
if (is_multicast_ether_addr(prxattrib->ra)) {
|
||||
if (psecuritypriv->binstallGrpkey == 0) {
|
||||
res = _FAIL;
|
||||
|
@ -777,12 +781,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
|
|||
crc[0], payload[length - 4]);
|
||||
res = _FAIL;
|
||||
}
|
||||
} else {
|
||||
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
|
||||
"rtw_tkip_decrypt23a: stainfo == NULL!!!\n");
|
||||
res = _FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue