staging: r8188eu: remove unncessary ternary operator
PATCH 1/1 staging: r8188eu: remove unncessary ternary operator
Using the ternary operator to assign true or false is redundant. There are many places in the driver code where this is done. Remove the unnecessary operator to improve readbility.
---
Tested on x86_64 with Inter-Tech DMG-02.
drivers/staging/r8188eu/core/rtw_p2p.c | 2 +- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 4 ++-- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 4 ++-- drivers/staging/r8188eu/core/rtw_wlan_util.c | 2 +- drivers/staging/r8188eu/hal/hal_com.c | 2 +- drivers/staging/r8188eu/hal/odm_HWConfig.c | 4 ++-- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/r8188eu/include/HalVerDef.h | 4 ++-- drivers/staging/r8188eu/include/ieee80211.h | 8 ++++---- drivers/staging/r8188eu/os_dep/osdep_service.c | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-)
drivers/staging/r8188eu/core/rtw_p2p.c +1 -1
@@ -951,7 +951,7 @@ u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint le/* issue Device Discoverability Response */ issue_p2p_devdisc_resp (pwdinfo,GetAddr2Ptr (pframe), status, dialogToken); -return (status ==P2P_STATUS_SUCCESS ) ? true : false; +return status ==P2P_STATUS_SUCCESS ; }u32 process_p2p_devdisc_resp (struct wifidirect_info *pwdinfo,u8 *pframe,uint len)
drivers/staging/r8188eu/core/rtw_pwrctrl.c +2 -2
@@ -348,7 +348,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) pwrctrlpriv->LpsIdleCount =0 ; pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ - pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; + pwrctrlpriv->bLeisurePs =PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt; pwrctrlpriv->bFwCurrentInPSMode = false;
@@ -426,7 +426,7 @@ int rtw_pm_set_lps(struct adapter *padapter, u8 mode)else pwrctrlpriv->LpsIdleCount =2 ; pwrctrlpriv->power_mgnt = mode; - pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; + pwrctrlpriv->bLeisurePs =PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt; } }else { ret = -EINVAL ;
drivers/staging/r8188eu/core/rtw_sta_mgt.c +2 -2
@@ -470,9 +470,9 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)spin_unlock_bh (&pacl_node_q->lock);if (pacl_list->mode ==1 )/* accept unless in deny list */ - res = (match) ? false : true; + res = !match;else if (pacl_list->mode ==2 )/* deny unless in accept list */ - res = (match) ? true : false; + res = match;else res = true;
drivers/staging/r8188eu/core/rtw_wlan_util.c +1 -1
@@ -1482,7 +1482,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) tid = (param >>2 ) &0x0f ; preorder_ctrl = &psta->recvreorder_ctrl[tid]; preorder_ctrl->indicate_seq =0xffff ; - preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq) ? true : false; + preorder_ctrl->enable = pmlmeinfo->bAcceptAddbaReq; } }
drivers/staging/r8188eu/hal/hal_com.c +1 -1
@@ -267,7 +267,7 @@ static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)bool Hal_MappingOutPipe (struct adapter *adapter,u8 numoutpipe) {struct registry_priv *pregistrypriv = &adapter->registrypriv; -bool wifi_cfg = (pregistrypriv->wifi_spec) ? true : false; +bool wifi_cfg = pregistrypriv->wifi_spec;bool result = true;switch (numoutpipe) {
drivers/staging/r8188eu/hal/odm_HWConfig.c +2 -2
@@ -65,7 +65,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm,struct phy_status_rpt *pPhyStaRpt = (struct phy_status_rpt *)pPhyStatus; - isCCKrate = ((pPktinfo->Rate >=DESC92C_RATE1M ) && (pPktinfo->Rate <=DESC92C_RATE11M )) ? true : false; + isCCKrate = pPktinfo->Rate >=DESC92C_RATE1M && pPktinfo->Rate <=DESC92C_RATE11M ;if (isCCKrate) {u8 cck_agc_rpt;
@@ -234,7 +234,7 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm,if ((!pPktinfo->bPacketMatchBSSID))return ; - isCCKrate = ((pPktinfo->Rate >=DESC92C_RATE1M ) && (pPktinfo->Rate <=DESC92C_RATE11M )) ? true : false; + isCCKrate = pPktinfo->Rate >=DESC92C_RATE1M && pPktinfo->Rate <=DESC92C_RATE11M ;/* Smart Antenna Debug Message------------------ */ if ((dm_odm->AntDivType ==CG_TRX_HW_ANTDIV ) || (dm_odm->AntDivType ==CGCS_RX_HW_ANTDIV )) {
drivers/staging/r8188eu/hal/rtl8188e_cmd.c +1 -1
@@ -137,7 +137,7 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi bitmap |= ((raid <<28 ) &0xf0000000 ); - short_gi_rate = (arg &BIT (5 )) ? true : false; + short_gi_rate = arg &BIT (5 ); raid = (bitmap >>28 ) &0x0f ;
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1 -1
@@ -747,7 +747,7 @@ void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoL/* decide hw if support remote wakeup function */ /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */ - padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0 ] &BIT (1 )) ? true : false; + padapter->pwrctrlpriv.bSupportRemoteWakeup = hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0 ] &BIT (1 ); }void Hal_ReadTxPowerInfo88E (struct adapter *padapter,u8 *PROMContent,bool AutoLoadFail)
drivers/staging/r8188eu/include/HalVerDef.h +2 -2
@@ -34,10 +34,10 @@ struct HAL_VERSION {/* HAL_CHIP_TYPE_E */ #define IS_NORMAL_CHIP (version) \ - ((GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP) ? true : false) + (GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP)/* HAL_VENDOR_E */ #define IS_CHIP_VENDOR_TSMC (version) \ - ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_TSMC) ? true : false) + (GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_TSMC)#endif
drivers/staging/r8188eu/include/ieee80211.h +4 -4
@@ -127,7 +127,7 @@ enum NETWORK_TYPE { (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)#define IsSupported24G (NetType) \ - ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) + ((NetType) & SUPPORTED_24G_NETTYPE_MSK)#define IsEnableHWCCK (NetType) \ IsSupported24G(NetType)
@@ -135,11 +135,11 @@ enum NETWORK_TYPE {#define IsSupportedRxCCK (NetType) IsEnableHWCCK(NetType)#define IsSupportedTxCCK (NetType) \ - ((NetType) & (WIRELESS_11B) ? true : false) + ((NetType) & WIRELESS_11B)#define IsSupportedTxOFDM (NetType) \ - ((NetType) & (WIRELESS_11G) ? true : false) + ((NetType) & WIRELESS_11G)#define IsSupportedTxMCS (NetType) \ - ((NetType) & (WIRELESS_11_24N) ? true : false) + ((NetType) & WIRELESS_11_24N)struct ieee_param {u32 cmd;
drivers/staging/r8188eu/os_dep/osdep_service.c +1 -1
@@ -220,7 +220,7 @@ void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len)*/ inline bool rtw_cbuf_empty (struct rtw_cbuf *cbuf) { -return (cbuf->write == cbuf->read) ? true : false; +return cbuf->write == cbuf->read; }/**
Signature · 1 line
2.35.1
drivers/staging/r8188eu/hal/rtl8188e_cmd.c void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi · line 141
Quoted 11 lines · Michael Straube
drivers/staging/r8188eu/hal/rtl8188e_cmd.c +1
-1@@ -137,7 +137,7 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi bitmap |= ((raid <<28 ) &0xf0000000 ); - short_gi_rate = (arg &BIT (5 )) ? true : false; + short_gi_rate = arg &BIT (5 );
This is a bug. Valid values of short_gi_rate are 0 and 1 but this sets it to BIT(5) so it will break odm_RateUp_8188E() which tests for:
else if ((pRaInfo->SGIEnable) != 1)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoL · line 750
Quoted 12 lines
drivers/staging/r8188eu/hal/rtl8188e_cmd.c +0
-0raid = (bitmap >>28 ) &0x0f ;drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1
-1@@ -747,7 +747,7 @@ void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoL/* decide hw if support remote wakeup function */ /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */ - padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0 ] &BIT (1 )) ? true : false; + padapter->pwrctrlpriv.bSupportRemoteWakeup = hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0 ] &BIT (1 );
I have not looked at this one to see if has a similar issue... I don't necessarily want to audit all of these. I guess I will, but could you do it first and then I will check?
drivers/staging/r8188eu/include/ieee80211.h enum NETWORK_TYPE { · line 130
Quoted 10 lines
drivers/staging/r8188eu/include/ieee80211.h +1
-1@@ -127,7 +127,7 @@ enum NETWORK_TYPE { (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)#define IsSupported24G (NetType) \ - ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) + ((NetType) & SUPPORTED_24G_NETTYPE_MSK)
This too.
Quoted 6 lines
drivers/staging/r8188eu/include/ieee80211.h +0
-0#define IsEnableHWCCK (NetType) \ IsSupported24G(NetType)@@ -135,11 +135,11 @@ enum NETWORK_TYPE {#define IsSupportedRxCCK (NetType) IsEnableHWCCK(NetType)
drivers/staging/r8188eu/include/ieee80211.h enum NETWORK_TYPE { · line 143
Quoted 10 lines
drivers/staging/r8188eu/include/ieee80211.h +3
-3#define IsSupportedTxCCK (NetType) \ - ((NetType) & (WIRELESS_11B) ? true : false) + ((NetType) & WIRELESS_11B)#define IsSupportedTxOFDM (NetType) \ - ((NetType) & (WIRELESS_11G) ? true : false) + ((NetType) & WIRELESS_11G)#define IsSupportedTxMCS (NetType) \ - ((NetType) & (WIRELESS_11_24N) ? true : false) + ((NetType) & WIRELESS_11_24N)
And this.
regards,
dan carpenter
Quoted 9 lines · Dan Carpenter
Quoted 8 lines · Michael Straube
drivers/staging/r8188eu/hal/rtl8188e_cmd.c +0
-0@@ -137,7 +137,7 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi bitmap |= ((raid <<28 ) &0xf0000000 );
Quoted 9 lines
drivers/staging/r8188eu/hal/rtl8188e_cmd.c void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi · line 141
Quoted 3 lines
drivers/staging/r8188eu/hal/rtl8188e_cmd.c +1
-1- short_gi_rate = (arg &BIT (5 )) ? true : false; + short_gi_rate = arg &BIT (5 );This is a bug. Valid values of
short_gi_rateare 0 and 1 but this sets it to BIT(5) so it will breakodm_RateUp_8188E()which tests for:else if ((pRaInfo->SGIEnable) != 1)
Oh I see, I should have been more careful with this type of removals.
Quoted 8 lines
Quoted 8 lines
drivers/staging/r8188eu/hal/rtl8188e_cmd.c +0
-0raid = (bitmap >>28 ) &0x0f ;drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +0
-0@@ -747,7 +747,7 @@ void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoL
Quoted 9 lines
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoL · line 750
Quoted 4 lines
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1
-1/* decide hw if support remote wakeup function */ /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */ - padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0 ] &BIT (1 )) ? true : false; + padapter->pwrctrlpriv.bSupportRemoteWakeup = hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0 ] &BIT (1 );I have not looked at this one to see if has a similar issue... I don't necessarily want to audit all of these. I guess I will, but could you do it first and then I will check?
Sure I'll do.
Thanks,
Michael
Quoted 35 lines
drivers/staging/r8188eu/include/ieee80211.h enum NETWORK_TYPE { · line 130
Quoted 10 lines
drivers/staging/r8188eu/include/ieee80211.h +1
-1@@ -127,7 +127,7 @@ enum NETWORK_TYPE { (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)#define IsSupported24G (NetType) \ - ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) + ((NetType) & SUPPORTED_24G_NETTYPE_MSK)This too.
Quoted 6 lines
drivers/staging/r8188eu/include/ieee80211.h +0
-0#define IsEnableHWCCK (NetType) \ IsSupported24G(NetType)@@ -135,11 +135,11 @@ enum NETWORK_TYPE {#define IsSupportedRxCCK (NetType) IsEnableHWCCK(NetType)drivers/staging/r8188eu/include/ieee80211.h enum NETWORK_TYPE { · line 143
Quoted 10 lines
drivers/staging/r8188eu/include/ieee80211.h +3
-3#define IsSupportedTxCCK (NetType) \ - ((NetType) & (WIRELESS_11B) ? true : false) + ((NetType) & WIRELESS_11B)#define IsSupportedTxOFDM (NetType) \ - ((NetType) & (WIRELESS_11G) ? true : false) + ((NetType) & WIRELESS_11G)#define IsSupportedTxMCS (NetType) \ - ((NetType) & (WIRELESS_11_24N) ? true : false) + ((NetType) & WIRELESS_11_24N)And this.
regards,
dan carpenter
Hi Dan,
Quoted 26 lines · Dan Carpenter
drivers/staging/r8188eu/hal/rtl8188e_cmd.c void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi · line 141
Quoted 11 lines · Michael Straube
drivers/staging/r8188eu/hal/rtl8188e_cmd.c +1
-1@@ -137,7 +137,7 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi bitmap |= ((raid <<28 ) &0xf0000000 ); - short_gi_rate = (arg &BIT (5 )) ? true : false; + short_gi_rate = arg &BIT (5 );This is a bug. Valid values of
short_gi_rateare 0 and 1 but this sets it to BIT(5) so it will breakodm_RateUp_8188E()which tests for:else if ((pRaInfo->SGIEnable) != 1)Quoted 8 lines
drivers/staging/r8188eu/hal/rtl8188e_cmd.c +0
-0raid = (bitmap >>28 ) &0x0f ;drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +0
-0@@ -747,7 +747,7 @@ void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoL
Quoted 9 lines
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoL · line 750
Quoted 4 lines
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1
-1/* decide hw if support remote wakeup function */ /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */ - padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0 ] &BIT (1 )) ? true : false; + padapter->pwrctrlpriv.bSupportRemoteWakeup = hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0 ] &BIT (1 );I have not looked at this one to see if has a similar issue... I don't necessarily want to audit all of these. I guess I will, but could you do it first and then I will check?
It has the same issue. I'll leave these two as is in v2.
Quoted 19 lines
drivers/staging/r8188eu/include/ieee80211.h enum NETWORK_TYPE { · line 130
Quoted 10 lines
drivers/staging/r8188eu/include/ieee80211.h +1
-1@@ -127,7 +127,7 @@ enum NETWORK_TYPE { (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)#define IsSupported24G (NetType) \ - ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) + ((NetType) & SUPPORTED_24G_NETTYPE_MSK)This too.
Quoted 6 lines
drivers/staging/r8188eu/include/ieee80211.h +0
-0#define IsEnableHWCCK (NetType) \ IsSupported24G(NetType)@@ -135,11 +135,11 @@ enum NETWORK_TYPE {#define IsSupportedRxCCK (NetType) IsEnableHWCCK(NetType)
Quoted 12 lines
drivers/staging/r8188eu/include/ieee80211.h enum NETWORK_TYPE { · line 143
Quoted 10 lines
drivers/staging/r8188eu/include/ieee80211.h +3
-3#define IsSupportedTxCCK (NetType) \ - ((NetType) & (WIRELESS_11B) ? true : false) + ((NetType) & WIRELESS_11B)#define IsSupportedTxOFDM (NetType) \ - ((NetType) & (WIRELESS_11G) ? true : false) + ((NetType) & WIRELESS_11G)#define IsSupportedTxMCS (NetType) \ - ((NetType) & (WIRELESS_11_24N) ? true : false) + ((NetType) & WIRELESS_11_24N)And this.
It turned out that these are all unused and can be removed. I should really have looked deeper into this, sorry.
I'll remove them in a separate patch in v2.
thanks,
Michael