Bool tests don't need comparisons
cover Bool tests don't need comparisons
This patchset removes explicit comparisons involving bool variables. Warnings detected by coccinelle.
Cristina Opriceana (3):
Staging: rtl8188eu: Bool tests don't need comparisons
Staging: rtl8192e: Bool tests don't need comparisons
Staging: rtl8192u: Bool tests don't need comparisons
drivers/staging/rtl8188eu/hal/rf_cfg.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 40 +++++++++++----------- .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 5 ++- drivers/staging/rtl8192u/r8192U_core.c | 2 +- drivers/staging/rtl8192u/r819xU_firmware.c | 6 ++-- drivers/staging/rtl8192u/r819xU_phy.c | 2 +- 6 files changed, 28 insertions(+), 29 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/3 Staging: rtl8188eu: Bool tests don't need comparisons
This patch simplifies the if condition by removing the comparison to bool values. It also removes the following coccinelle warning:
"WARNING: Comparison to bool".
--- drivers/staging/rtl8188eu/hal/rf_cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/hal/rf_cfg.c +1 -1
@@ -295,7 +295,7 @@ static bool rf6052_conf_para(struct adapter *adapt)break ; } -if (rtstatus != true) +if (!rtstatus)return false; }
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH 1/3] Staging: rtl8188eu: Bool tests don't need comparisons
Quoted 14 lines · Cristina Opriceana
This patch simplifies the if condition by removing the comparison to bool values. It also removes the following coccinelle warning:
"WARNING: Comparison to bool".Signed-off-by Cristina Opriceana <[email protected]>--- drivers/staging/rtl8188eu/hal/rf_cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/rtl8188eu/hal/rf_cfg.c +0
-0
drivers/staging/rtl8188eu/hal/rf_cfg.c static bool rf6052_conf_para(struct adapter *adapt) · line 299
Quoted 6 lines
drivers/staging/rtl8188eu/hal/rf_cfg.c +1
-1@@ -295,7 +295,7 @@ static bool rf6052_conf_para(struct adapter *adapt)break ; } -if (rtstatus != true) +if (!rtstatus)return false;
Looking at this code a bit, I can't see how rtstatus could be anything other than true. So perhaps the test, and even the variable, is not needed?
julia
Quoted 12 lines
drivers/staging/rtl8188eu/hal/rf_cfg.c +0
-0}Signature · 8 lines
1.9.1 -- You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/89c63fedf7d2979ad94f85a601bc6d8ef80fe142.1426273386.git.cristina.opriceana%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Outreachy kernel] [PATCH 1/3] Staging: rtl8188eu: Bool tests don't need comparisons
Quoted 18 lines
drivers/staging/rtl8188eu/hal/rf_cfg.c static bool rf6052_conf_para(struct adapter *adapt) · line 299
Quoted 13 lines
drivers/staging/rtl8188eu/hal/rf_cfg.c +1
-1@@ -295,7 +295,7 @@ static bool rf6052_conf_para(struct adapter *adapt)break ; } -if (rtstatus != true) +if (!rtstatus)return false;Looking at this code a bit, I can't see how rtstatus could be anything other than true. So perhaps the test, and even the variable, is not needed?
Quoted 2 lines
julia
I had a look at it. rtstatus is only modified in
rtstatus = rtl88e_phy_config_rf_with_headerfile(adapt);
And indeed, this function returns only true. I will make another patch removing unnecessary code.
Thanks,
Cristina
PATCH 2/3 Staging: rtl8192e: Bool tests don't need comparisons
In reply to Cristina OpriceanaThis patch removes comparisons to true/false values on bool variables. Warning found by coccinelle:
"WARNING: Comparison to bool".
--- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +20 -20
@@ -67,7 +67,7 @@ static int r8192_wx_set_rate(struct net_device *dev,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -87,7 +87,7 @@ static int r8192_wx_set_rts(struct net_device *dev,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -115,7 +115,7 @@ static int r8192_wx_set_power(struct net_device *dev,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) { +if (priv->bHwRadioOff) {RT_TRACE (COMP_ERR ,"%s():Hw is Radio Off, we can't set " "Power,return\n" , __func__);return 0 ;
@@ -145,7 +145,7 @@ static int r8192_wx_set_rawtx(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);int ret; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -308,7 +308,7 @@ static int r8192_wx_set_debugflag(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);u8 c = *extra; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ; printk(KERN_INFO "=====>%s(), *extra:%x, debugflag:%x\n", __func__,
@@ -329,7 +329,7 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,enum rt_rf_power_state rtState;int ret; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ; rtState = priv->rtllib->eRFPowerState;down (&priv->wx_sem);
@@ -470,7 +470,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,return 0 ; } -if (priv->bHwRadioOff == true) { +if (priv->bHwRadioOff) {printk (KERN_INFO "================>%s(): hwradio off\n" , __func__);return 0 ;
@@ -552,7 +552,7 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,if (!priv->up)return -ENETDOWN ; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;
@@ -572,7 +572,7 @@ static int r8192_wx_set_essid(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);int ret; -if (priv->bHwRadioOff == true) { +if (priv->bHwRadioOff) {printk (KERN_INFO "=========>%s():hw radio off,or Rf state is " "eRfOff, return\n" , __func__);return 0 ;
@@ -638,7 +638,7 @@ static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -665,7 +665,7 @@ static int r8192_wx_set_frag(struct net_device *dev, {struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;if (wrqu->frag.disabled)
@@ -704,7 +704,7 @@ static int r8192_wx_set_wap(struct net_device *dev,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -754,7 +754,7 @@ static int r8192_wx_set_enc(struct net_device *dev, {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} };int i; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;if (!priv->up)
@@ -843,7 +843,7 @@ static int r8192_wx_set_scan_type(struct net_device *dev,int *parms = (int *)p;int mode = parms[0 ]; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ; priv->rtllib->active_scan = mode;
@@ -861,7 +861,7 @@ static int r8192_wx_set_retry(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);int err =0 ; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -944,7 +944,7 @@ static int r8192_wx_set_sens(struct net_device *dev,short err =0 ; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -971,7 +971,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);struct rtllib_device *ieee = priv->rtllib; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -1052,7 +1052,7 @@ static int r8192_wx_set_auth(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -1070,7 +1070,7 @@ static int r8192_wx_set_mlme(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
@@ -1087,7 +1087,7 @@ static int r8192_wx_set_gen_ie(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH 2/3] Staging: rtl8192e: Bool tests don't need comparisons
Quoted 3 lines · Cristina Opriceana
This patch removes comparisons to true/false values on bool variables. Warning found by coccinelle:
"WARNING: Comparison to bool".
It's orthogonal to this patch, but this patch involves a type that is uselessly defined as a typedef. There are a lot of typedefs in that header file that could be cleaned up.
julia
Quoted 199 lines
Signed-off-by Cristina Opriceana <[email protected]>--- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-)drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +20
-20@@ -67,7 +67,7 @@ static int r8192_wx_set_rate(struct net_device *dev,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -87,7 +87,7 @@ static int r8192_wx_set_rts(struct net_device *dev,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -115,7 +115,7 @@ static int r8192_wx_set_power(struct net_device *dev,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) { +if (priv->bHwRadioOff) {RT_TRACE (COMP_ERR ,"%s():Hw is Radio Off, we can't set " "Power,return\n" , __func__);return 0 ;@@ -145,7 +145,7 @@ static int r8192_wx_set_rawtx(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);int ret; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -308,7 +308,7 @@ static int r8192_wx_set_debugflag(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);u8 c = *extra; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ; printk(KERN_INFO "=====>%s(), *extra:%x, debugflag:%x\n", __func__,@@ -329,7 +329,7 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,enum rt_rf_power_state rtState;int ret; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ; rtState = priv->rtllib->eRFPowerState;down (&priv->wx_sem);@@ -470,7 +470,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,return 0 ; } -if (priv->bHwRadioOff == true) { +if (priv->bHwRadioOff) {printk (KERN_INFO "================>%s(): hwradio off\n" , __func__);return 0 ;@@ -552,7 +552,7 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,if (!priv->up)return -ENETDOWN ; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;@@ -572,7 +572,7 @@ static int r8192_wx_set_essid(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);int ret; -if (priv->bHwRadioOff == true) { +if (priv->bHwRadioOff) {printk (KERN_INFO "=========>%s():hw radio off,or Rf state is " "eRfOff, return\n" , __func__);return 0 ;@@ -638,7 +638,7 @@ static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -665,7 +665,7 @@ static int r8192_wx_set_frag(struct net_device *dev, {struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;if (wrqu->frag.disabled)@@ -704,7 +704,7 @@ static int r8192_wx_set_wap(struct net_device *dev,int ret;struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -754,7 +754,7 @@ static int r8192_wx_set_enc(struct net_device *dev, {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} };int i; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;if (!priv->up)@@ -843,7 +843,7 @@ static int r8192_wx_set_scan_type(struct net_device *dev,int *parms = (int *)p;int mode = parms[0 ]; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ; priv->rtllib->active_scan = mode;@@ -861,7 +861,7 @@ static int r8192_wx_set_retry(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);int err =0 ; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -944,7 +944,7 @@ static int r8192_wx_set_sens(struct net_device *dev,short err =0 ; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -971,7 +971,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);struct rtllib_device *ieee = priv->rtllib; -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -1052,7 +1052,7 @@ static int r8192_wx_set_auth(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -1070,7 +1070,7 @@ static int r8192_wx_set_mlme(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);@@ -1087,7 +1087,7 @@ static int r8192_wx_set_gen_ie(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev); -if (priv->bHwRadioOff == true) +if (priv->bHwRadioOff)return 0 ;down (&priv->wx_sem);Signature · 8 lines
1.9.1 -- You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/0b95bd2fba788a4bb9d9cdbb942bebc6e388aa18.1426273386.git.cristina.opriceana%40gmail.com. For more options, visit https://groups.google.com/d/optout.
PATCH 3/3 Staging: rtl8192u: Bool tests don't need comparisons
In reply to Cristina OpriceanaThis patch removes explicit true/false comparations to bool variables. Warning found by coccinelle:
"WARNING: Comparison to bool"
--- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 5 ++--- drivers/staging/rtl8192u/r8192U_core.c | 2 +- drivers/staging/rtl8192u/r819xU_firmware.c | 6 +++--- drivers/staging/rtl8192u/r819xU_phy.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-)
drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +2 -3
@@ -288,7 +288,7 @@ static PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee,//for(dir = DIR_UP; dir <= DIR_BI_DIR; dir++) for (dir =0 ; dir <=DIR_BI_DIR ; dir++) { -if (search_dir[dir] ==false ) +if (!search_dir[dir])continue ;list_for_each_entry (pRet, psearch_list, List){// IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection);
@@ -400,8 +400,7 @@ bool GetTs( }else { -if (bAddNewTs == false) - { +if (!bAddNewTs) {IEEE80211_DEBUG (IEEE80211_DL_TS ,"add new TS failed(tid:%d)\n" ,UP );return false; }
drivers/staging/rtl8192u/r8192U_core.c +1 -1
@@ -2824,7 +2824,7 @@ static bool rtl8192_adapter_start(struct net_device *dev) }dm_initialize_txpower_tracking (dev); -if (priv->bDcut == true) { +if (priv->bDcut) {u32 i, TempCCk;u32 tmpRegA =rtl8192_QueryBBReg (dev, rOFDM0_XATxIQImbalance, bMaskDWord);for (i =0 ; i < TxBBGainTableLength; i++) {
drivers/staging/rtl8192u/r819xU_firmware.c +3 -3
@@ -281,7 +281,7 @@ bool init_firmware(struct net_device *dev)if (rst_opt ==OPT_SYSTEM_RESET )release_firmware (fw_entry); -if (rt_status != true) +if (!rt_status) goto download_firmware_fail;switch (init_step) {
@@ -304,7 +304,7 @@ bool init_firmware(struct net_device *dev)/* Check Put Code OK and Turn On CPU */ rt_status =CPUcheck_maincodeok_turnonCPU (dev); -if (rt_status != true) { +if (!rt_status) {RT_TRACE (COMP_ERR ,"CPUcheck_maincodeok_turnonCPU fail!\n" ); goto download_firmware_fail; }
@@ -318,7 +318,7 @@ bool init_firmware(struct net_device *dev)mdelay (1 ); rt_status =CPUcheck_firmware_ready (dev); -if (rt_status != true) { +if (!rt_status) {RT_TRACE (COMP_ERR ,"CPUcheck_firmware_ready fail(%d)!\n" ,rt_status); goto download_firmware_fail; }
drivers/staging/rtl8192u/r819xU_phy.c +1 -1
@@ -1099,7 +1099,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev,if (eRFPowerState == priv->ieee80211->eRFPowerState)return false; -if (priv->SetRFPowerStateInProgress == true) +if (priv->SetRFPowerStateInProgress)return false; priv->SetRFPowerStateInProgress = true;
Signature · 1 line
1.9.1
Quoted 8 lines · Cristina Opriceana
This patchset removes explicit comparisons involving bool variables. Warnings detected by coccinelle.
Cristina Opriceana (3):
Staging: rtl8188eu: Bool tests don't need comparisons
Staging: rtl8192e: Bool tests don't need comparisons
Staging: rtl8192u: Bool tests don't need comparisons
Quoted 8 lines
drivers/staging/rtl8188eu/hal/rf_cfg.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 40 +++++++++++----------- .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 5 ++- drivers/staging/rtl8192u/r8192U_core.c | 2 +- drivers/staging/rtl8192u/r819xU_firmware.c | 6 ++-- drivers/staging/rtl8192u/r819xU_phy.c | 2 +- 6 files changed, 28 insertions(+), 29 deletions(-)
The patches looks fine, and so do the commit messages.
In general when patching different drivers, I prefer to have different patch sets posted for it, as it allows the individual driver maintainers to process them.
Cheers,
Jes