staging: rtl8723au: Fix up some random bit-flag handling
authorJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 21 May 2014 07:37:29 +0000 (09:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 May 2014 07:27:41 +0000 (16:27 +0900)
Randomly mixing true/false/_FAIL/0/1 is a recipe for disaster

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_cmd.c
drivers/staging/rtl8723au/core/rtw_mlme.c
drivers/staging/rtl8723au/core/rtw_pwrctrl.c
drivers/staging/rtl8723au/core/rtw_recv.c
drivers/staging/rtl8723au/core/rtw_security.c
drivers/staging/rtl8723au/core/rtw_xmit.c
drivers/staging/rtl8723au/include/rtw_security.h
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
drivers/staging/rtl8723au/os_dep/os_intfs.c

index b28afb1b8380f8c8d93b745b573ae9c6847e5856..5abe936e479e8a4202c3be09ef0f86c68b359fe0 100644 (file)
@@ -755,7 +755,7 @@ int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key)
         }
 
        /* jeff: set this becasue at least sw key is ready */
-       padapter->securitypriv.busetkipkey = true;
+       padapter->securitypriv.busetkipkey = 1;
 
        res = rtw_enqueue_cmd23a(pcmdpriv, ph2c);
 
index b912d09d6550d5a39ae1bb2081e9c044e500327a..8c6b0947ee92ff6ecc145ab61aedd8eb8030a9ed 100644 (file)
@@ -1027,9 +1027,8 @@ rtw_joinbss_update_stainfo(struct rtw_adapter *padapter,
                /* security related */
                if (padapter->securitypriv.dot11AuthAlgrthm ==
                    dot11AuthAlgrthm_8021X) {
-                       padapter->securitypriv.binstallGrpkey = false;
-                       padapter->securitypriv.busetkipkey = false;
-                       padapter->securitypriv.bgrpkey_handshake = false;
+                       padapter->securitypriv.binstallGrpkey = 0;
+                       padapter->securitypriv.busetkipkey = 0;
 
                        psta->ieee8021x_blocked = true;
                        psta->dot118021XPrivacy =
index 96337a87b1d8132f6a1448051472737101e750f3..707b5ccd951b72512c463796baf6809abab15adf 100644 (file)
@@ -306,7 +306,7 @@ static u8 PS_RDY_CHECK(struct rtw_adapter * padapter)
        if (pwrpriv->bInSuspend)
                return false;
        if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X &&
-           padapter->securitypriv.binstallGrpkey == false) {
+           !padapter->securitypriv.binstallGrpkey) {
                DBG_8723A("Group handshake still in progress !!!\n");
                return false;
        }
index eda495a1d5d86105da1d522b4eb20b8c8da2b5a2..84e6a1875cf4649ca2e5d0947b57c051fbc6241e 100644 (file)
@@ -313,7 +313,7 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
                                         ("\n recvframe_chkmic: bcmc key\n"));
 
-                               if (psecuritypriv->binstallGrpkey == false) {
+                               if (!psecuritypriv->binstallGrpkey) {
                                        res = _FAIL;
                                        RT_TRACE(_module_rtl871x_recv_c_,
                                                 _drv_err_,
@@ -442,9 +442,9 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
                                res = _FAIL;
                        } else {
                                /* mic checked ok */
-                               if ((psecuritypriv->bcheck_grpkey == false) &&
-                                   (is_multicast_ether_addr(prxattrib->ra))) {
-                                       psecuritypriv->bcheck_grpkey = true;
+                               if (!psecuritypriv->bcheck_grpkey &&
+                                   is_multicast_ether_addr(prxattrib->ra)) {
+                                       psecuritypriv->bcheck_grpkey = 1;
                                        RT_TRACE(_module_rtl871x_recv_c_,
                                                 _drv_err_,
                                                 ("psecuritypriv->bcheck_grp"
@@ -507,7 +507,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter,
        }
 
        if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0))) {
-               psecuritypriv->hw_decrypted = false;
+               psecuritypriv->hw_decrypted = 0;
                switch (prxattrib->encrypt) {
                case _WEP40_:
                case _WEP104_:
@@ -525,7 +525,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter,
        } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 &&
                   (psecuritypriv->busetkipkey == 1 ||
                    prxattrib->encrypt != _TKIP_)) {
-                       psecuritypriv->hw_decrypted = true;
+                       psecuritypriv->hw_decrypted = 1;
        }
 
        if (res == _FAIL) {
index 77709fea856ca9bdeb0ccbd16db84bdb7e136db0..96347e73b4f673ce2416dc56e5e39a1bffcc4ab6 100644 (file)
@@ -744,7 +744,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
                if (stainfo!= NULL) {
 
                        if (is_multicast_ether_addr(prxattrib->ra)) {
-                               if (psecuritypriv->binstallGrpkey == false) {
+                               if (psecuritypriv->binstallGrpkey == 0) {
                                        res = _FAIL;
                                        DBG_8723A("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__);
                                        goto exit;
@@ -1645,7 +1645,7 @@ void rtw_use_tkipkey_handler23a(void *FunctionContext)
        struct rtw_adapter *padapter = (struct rtw_adapter *)FunctionContext;
 
        RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler23a ^^^\n"));
-       padapter->securitypriv.busetkipkey = true;
+       padapter->securitypriv.busetkipkey = 1;
        RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
                 ("^^^rtw_use_tkipkey_handler23a padapter->securitypriv.busetkipkey =%d^^^\n",
                 padapter->securitypriv.busetkipkey));
index 65e7de8de916159d112a1c68676b3d47abc31f10..eeaaa8fc7a4c2da9d16ed471619cd2f623c8c03d 100644 (file)
@@ -604,10 +604,10 @@ static int update_attrib(struct rtw_adapter *padapter,
                pattrib->iv_len = 8;
                pattrib->icv_len = 4;
 
-               if (padapter->securitypriv.busetkipkey == _FAIL) {
+               if (!padapter->securitypriv.busetkipkey) {
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
                                 ("\npadapter->securitypriv.busetkip"
-                                 "key(%d) == _FAIL drop packet\n",
+                                 "key(%d) == false drop packet\n",
                                  padapter->securitypriv.busetkipkey));
                        res = _FAIL;
                        goto exit;
@@ -630,7 +630,7 @@ static int update_attrib(struct rtw_adapter *padapter,
        RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
                 ("update_attrib: encrypt =%d\n", pattrib->encrypt));
 
-       if (pattrib->encrypt && psecuritypriv->hw_decrypted == false) {
+       if (pattrib->encrypt && !psecuritypriv->hw_decrypted) {
                pattrib->bswenc = true;
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
                         ("update_attrib: encrypt =%d bswenc = true\n",
index e9e850616359def0f80032cc264341448dc2410b..d117a2053396caa41875f147b9ed032d22890f00 100644 (file)
@@ -139,11 +139,10 @@ struct security_priv {
 
        u8 wps_ie[MAX_WPS_IE_LEN];/* added in assoc req */
        int wps_ie_len;
-       u8      binstallGrpkey;
-       u8      busetkipkey;
-       u8      bcheck_grpkey;
-       u8      bgrpkey_handshake;
-       s32     hw_decrypted;
+       unsigned int binstallGrpkey:1;
+       unsigned int busetkipkey:1;
+       unsigned int bcheck_grpkey:1;
+       unsigned int hw_decrypted:1;
        u32 ndisauthtype;       /*  enum ndis_802_11_auth_mode */
        u32 ndisencryptstatus;  /*  NDIS_802_11_ENCRYPTION_STATUS */
        struct wlan_bssid_ex sec_bss;  /* for joinbss (h2c buffer) usage */
index aac1d418d9dd7ca862f9d0dfbfc1fde837899468..35ed47a79d279f6c3fdc09ea39bd4362d275cd80 100644 (file)
@@ -689,7 +689,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
                                                             idx].skey,
                                       &param->u.crypt.key[24], 8);
 
-                               psecuritypriv->busetkipkey = true;
+                               psecuritypriv->busetkipkey = 1;
 
                        } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
                                DBG_8723A("%s, set group_key, CCMP\n",
@@ -712,7 +712,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
 
                        psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx;
 
-                       psecuritypriv->binstallGrpkey = true;
+                       psecuritypriv->binstallGrpkey = 1;
 
                        psecuritypriv->dot11PrivacyAlgrthm =
                                psecuritypriv->dot118021XGrpPrivacy;
@@ -767,7 +767,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
                                        memcpy(psta->dot11tkiprxmickey.skey,
                                               &param->u.crypt.key[24], 8);
 
-                                       psecuritypriv->busetkipkey = true;
+                                       psecuritypriv->busetkipkey = 1;
 
                                } else if (!strcmp(param->u.crypt.alg, "CCMP")) {
 
@@ -831,7 +831,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
                                               skey, &param->u.crypt.key[24],
                                               8);
 
-                                       psecuritypriv->busetkipkey = true;
+                                       psecuritypriv->busetkipkey = 1;
 
                                } else if (!strcmp(param->u.crypt.alg, "CCMP")) {
                                        psecuritypriv->dot118021XGrpPrivacy =
@@ -852,7 +852,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
                                psecuritypriv->dot118021XGrpKeyid =
                                        param->u.crypt.idx;
 
-                               psecuritypriv->binstallGrpkey = true;
+                               psecuritypriv->binstallGrpkey = 1;
 
                                psecuritypriv->dot11PrivacyAlgrthm =
                                        psecuritypriv->dot118021XGrpPrivacy;
@@ -1003,7 +1003,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
                                                       8);
 
                                                padapter->securitypriv.
-                                                       busetkipkey = false;
+                                                       busetkipkey = 0;
                                        }
                                        DBG_8723A(" ~~~~set sta key:unicastkey\n");
 
@@ -1029,7 +1029,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
                                               skey, &param->u.crypt.key[24],
                                               8);
                                        padapter->securitypriv.binstallGrpkey =
-                                           true;
+                                               1;
                                        /* DEBUG_ERR((" param->u.crypt.key_len"
                                           "=%d\n", param->u.crypt.key_len)); */
                                        DBG_8723A
index 5be8dd9e1fea1612dcae46e2e6b8a9697588ceba..d6d0e9a1c9367734ec31bb2b2365d6a1a0a9edbe 100644 (file)
@@ -401,7 +401,7 @@ static int rtw_init_default_value(struct rtw_adapter *padapter)
        pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */
 
        /* security_priv */
-       psecuritypriv->binstallGrpkey = _FAIL;
+       psecuritypriv->binstallGrpkey = 0;
 
         /* open system */
        psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;