]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: rtl8188eu: ternary operator (?:) replaced by min_t kernel macro
authorIvan Safonov <insafonov@gmail.com>
Tue, 27 Oct 2015 15:18:10 +0000 (22:18 +0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2015 00:09:08 +0000 (09:09 +0900)
min_t macro better conveys the meaning of the code.

Signed-off-by: Ivan Safonov <insafonov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_ap.c
drivers/staging/rtl8188eu/core/rtw_ieee80211.c
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
drivers/staging/rtl8188eu/core/rtw_wlan_util.c
drivers/staging/rtl8188eu/hal/odm_HWConfig.c
drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
drivers/staging/rtl8188eu/os_dep/mlme_linux.c

index 5c45f8a8c2cf77053d73456be62bdc159689812c..3cdb40fea5ee7041ed253de939dbd006b786052b 100644 (file)
@@ -1795,7 +1795,7 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset)
                plist = plist->next;
 
                issue_action_spct_ch_switch(padapter, psta->hwaddr, new_ch, ch_offset);
-               psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2);
+               psta->expire_to = min_t(unsigned int, pstapriv->expire_to * 2, 5);
        }
        spin_unlock_bh(&pstapriv->asoc_list_lock);
 
index 82d4e888ca63502ee6d417aff6c465b5e8b2e3ef..742b29c590df92a676732341db82c7984ab6e3aa 100644 (file)
@@ -1392,6 +1392,6 @@ static const char *_action_public_str[] = {
 
 const char *action_public_str(u8 action)
 {
-       action = (action >= ACT_PUBLIC_MAX) ? ACT_PUBLIC_MAX : action;
+       action = min_t(u8, action, ACT_PUBLIC_MAX);
        return _action_public_str[action];
 }
index e15c198abbe33dd4eee96871e9984de2b1c1625a..cc5806f9229ace24d5d75306bae82e91ad4255a6 100644 (file)
@@ -418,7 +418,7 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms)
 
        /*  supported rates... */
        rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-       pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen);
+       pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen);
 
        /*  DS parameter set */
        pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen);
@@ -578,7 +578,7 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da)
 
                /*  supported rates... */
                rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-               pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen);
+               pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen);
 
                /*  DS parameter set */
                pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen);
index 3bb40a7fe3ce480734bd51646e9be5fbb93ec454..59b443255a90992e67e71a5888bbe142e68c26d6 100644 (file)
@@ -1227,7 +1227,7 @@ unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz)
        unsigned int i, num_of_rate;
        unsigned int mask = 0;
 
-       num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz;
+       num_of_rate = min_t(unsigned int, ptn_sz, NumRates);
 
        for (i = 0; i < num_of_rate; i++) {
                if ((*(ptn + i)) & 0x80)
@@ -1241,7 +1241,7 @@ unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz)
        unsigned int i, num_of_rate;
        unsigned int mask = 0;
 
-       num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz;
+       num_of_rate = min_t(unsigned int, ptn_sz, NumRates);
 
        for (i = 0; i < num_of_rate; i++)
                mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i));
index 3dd6cff873d9d110e2a4075059276b7430cdb0dd..28b9f7f591c015c635b8c3fed527c0d48215a46a 100644 (file)
@@ -394,7 +394,7 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm,
                        OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i) & BIT(0);
 
                if (pEntry->rssi_stat.ValidBit == 64) {
-                       Weighting = ((OFDM_pkt<<4) > 64) ? 64 : (OFDM_pkt<<4);
+                       Weighting = min_t(u32, OFDM_pkt << 4, 64);
                        UndecoratedSmoothedPWDB = (Weighting*UndecoratedSmoothedOFDM+(64-Weighting)*UndecoratedSmoothedCCK)>>6;
                } else {
                        if (pEntry->rssi_stat.ValidBit != 0)
index 2d88c5a44439475f8727740662be76649ccbcb41..580876313e98c709d8a5e2179664b2a58542eb55 100644 (file)
@@ -277,7 +277,7 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength)
 
        /*  supported rates... */
        rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-       pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen);
+       pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(u32, rate_len, 8), cur_network->SupportedRates, &pktlen);
 
        /*  DS parameter set */
        pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen);
index fd01ca4b0c0f699258f4727c5abf76683bc90577..9c11ef4bc88fdb8421933a129c3cc2e10842f6a7 100644 (file)
@@ -457,7 +457,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
                                        psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
 
                                if (param->u.crypt.set_tx == 1) { /* pairwise key */
-                                       memcpy(psta->dot118021x_UncstKey.skey,  param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
+                                       memcpy(psta->dot118021x_UncstKey.skey,  param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));
 
                                        if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */
                                                memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8);
@@ -469,7 +469,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
 
                                        rtw_setstakey_cmd(padapter, (unsigned char *)psta, true);
                                } else { /* group key */
-                                       memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey,  param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
+                                       memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey,  param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16 ));
                                        memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8);
                                        memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8);
                                        padapter->securitypriv.binstallGrpkey = true;
@@ -1321,7 +1321,7 @@ static int rtw_wx_set_essid(struct net_device *dev,
        authmode = padapter->securitypriv.ndisauthtype;
        DBG_88E("=>%s\n", __func__);
        if (wrqu->essid.flags && wrqu->essid.length) {
-               len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE;
+               len = min_t(uint, wrqu->essid.length, IW_ESSID_MAX_SIZE);
 
                if (wrqu->essid.length != 33)
                        DBG_88E("ssid =%s, len =%d\n", extra, wrqu->essid.length);
@@ -2335,7 +2335,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
                                DBG_88E("%s, set group_key, WEP\n", __func__);
 
                                memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey,
-                                           param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
+                                           param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));
 
                                psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
                                if (param->u.crypt.key_len == 13)
@@ -2344,7 +2344,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
                                DBG_88E("%s, set group_key, TKIP\n", __func__);
                                psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
                                memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey,
-                                           param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
+                                           param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));
                                /* set mic key */
                                memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8);
                                memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8);
@@ -2354,7 +2354,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
                                DBG_88E("%s, set group_key, CCMP\n", __func__);
                                psecuritypriv->dot118021XGrpPrivacy = _AES_;
                                memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey,
-                                           param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
+                                           param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));
                        } else {
                                DBG_88E("%s, set group_key, none\n", __func__);
                                psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
@@ -2375,7 +2375,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
        if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) { /*  psk/802_1x */
                if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
                        if (param->u.crypt.set_tx == 1) {
-                               memcpy(psta->dot118021x_UncstKey.skey,  param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
+                               memcpy(psta->dot118021x_UncstKey.skey,  param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));
 
                                if (strcmp(param->u.crypt.alg, "WEP") == 0) {
                                        DBG_88E("%s, set pairwise key, WEP\n", __func__);
@@ -2409,7 +2409,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
                        } else { /* group key??? */
                                if (strcmp(param->u.crypt.alg, "WEP") == 0) {
                                        memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey,
-                                                   param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
+                                                   param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));
                                        psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
                                        if (param->u.crypt.key_len == 13)
                                                psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
@@ -2417,7 +2417,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
                                        psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
 
                                        memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey,
-                                                   param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
+                                                   param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));
 
                                        /* set mic key */
                                        memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8);
@@ -2428,7 +2428,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
                                        psecuritypriv->dot118021XGrpPrivacy = _AES_;
 
                                        memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey,
-                                                   param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
+                                                   param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));
                                } else {
                                        psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
                                }
index eb8ecb7fbd16fc1a251f3adbeaaa495a89cd4b74..08bfa76f4975cf61c49003cb4f918b2eba36d63a 100644 (file)
@@ -116,14 +116,13 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
                p = buff;
                p += sprintf(p, "ASSOCINFO(ReqIEs =");
                len = sec_ie[1]+2;
-               len =  (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
+               len =  min_t(uint, len, IW_CUSTOM_MAX);
                for (i = 0; i < len; i++)
                        p += sprintf(p, "%02x", sec_ie[i]);
                p += sprintf(p, ")");
                memset(&wrqu, 0, sizeof(wrqu));
                wrqu.data.length = p-buff;
-               wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
-                                  wrqu.data.length : IW_CUSTOM_MAX;
+               wrqu.data.length = min_t(__u16, wrqu.data.length, IW_CUSTOM_MAX);
                wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
                kfree(buff);
        }