2021-10-20 09:38:06

by Kushal Kothari

[permalink] [raw]
Subject: [PATCH] staging: rtl8723bs: core: Remove true and false comparison and unnecessary parentheses

Remove comparison to true and false in if statement.
Issue found with checkpatch.pl.
CHECK: Using comparison to true is error prone
CHECK: Using comparison to false is error prone
CHECK: Unnecessary parentheses

Signed-off-by: Kushal Kothari <[email protected]>
---
drivers/staging/rtl8723bs/core/rtw_cmd.c | 50 ++++++++++++------------
1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index efc9b1974e38..3e0b910114da 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -309,8 +309,8 @@ int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan))
bAllow = true;

- if ((pcmdpriv->padapter->hw_init_completed == false && bAllow == false)
- || atomic_read(&(pcmdpriv->cmdthd_running)) == false /* com_thread not running */
+ if ((!pcmdpriv->padapter->hw_init_completed && !bAllow) ||
+ !atomic_read(&pcmdpriv->cmdthd_running) /* com_thread not running */
)
return _FAIL;

@@ -372,7 +372,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
void rtw_stop_cmd_thread(struct adapter *adapter)
{
if (adapter->cmdThread &&
- atomic_read(&(adapter->cmdpriv.cmdthd_running)) == true &&
+ atomic_read(&adapter->cmdpriv.cmdthd_running) &&
adapter->cmdpriv.stop_req == 0) {
adapter->cmdpriv.stop_req = 1;
complete(&adapter->cmdpriv.cmd_queue_comp);
@@ -388,7 +388,7 @@ int rtw_cmd_thread(void *context)
u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf);
void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd);
struct adapter *padapter = context;
- struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
struct drvextra_cmd_parm *extra_parm = NULL;

thread_enter("RTW_CMD_THREAD");
@@ -396,7 +396,7 @@ int rtw_cmd_thread(void *context)
pcmdbuf = pcmdpriv->cmd_buf;

pcmdpriv->stop_req = 0;
- atomic_set(&(pcmdpriv->cmdthd_running), true);
+ atomic_set(&pcmdpriv->cmdthd_running, true);
complete(&pcmdpriv->terminate_cmdthread_comp);

while (1) {
@@ -407,7 +407,7 @@ int rtw_cmd_thread(void *context)
break;
}

- if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
+ if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
netdev_dbg(padapter->pnetdev,
"%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
__func__, padapter->bDriverStopped,
@@ -430,7 +430,7 @@ int rtw_cmd_thread(void *context)
continue;

_next:
- if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
+ if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
netdev_dbg(padapter->pnetdev,
"%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
__func__, padapter->bDriverStopped,
@@ -472,7 +472,7 @@ int rtw_cmd_thread(void *context)

post_process:

- if (mutex_lock_interruptible(&(pcmd->padapter->cmdpriv.sctx_mutex)) == 0) {
+ if (mutex_lock_interruptible(&pcmd->padapter->cmdpriv.sctx_mutex) == 0) {
if (pcmd->sctx) {
netdev_dbg(padapter->pnetdev,
FUNC_ADPT_FMT " pcmd->sctx\n",
@@ -483,7 +483,7 @@ int rtw_cmd_thread(void *context)
else
rtw_sctx_done_err(&pcmd->sctx, RTW_SCTX_DONE_CMD_ERROR);
}
- mutex_unlock(&(pcmd->padapter->cmdpriv.sctx_mutex));
+ mutex_unlock(&pcmd->padapter->cmdpriv.sctx_mutex);
}

/* call callback function for post-processed */
@@ -523,7 +523,7 @@ int rtw_cmd_thread(void *context)
} while (1);

complete(&pcmdpriv->terminate_cmdthread_comp);
- atomic_set(&(pcmdpriv->cmdthd_running), false);
+ atomic_set(&pcmdpriv->cmdthd_running, false);

thread_exit();
}
@@ -543,7 +543,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;

- if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
+ if (check_fwstate(pmlmepriv, _FW_LINKED))
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);

ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
@@ -725,7 +725,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
enum ndis_802_11_network_infrastructure ndis_network_mode = pnetwork->network.infrastructure_mode;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
+ struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
u32 tmp_len;
u8 *ptmp = NULL;

@@ -776,7 +776,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
/* If not, we have to copy the connecting AP's MAC address to it so that */
/* the driver just has the bssid information for PMKIDList searching. */

- if (pmlmepriv->assoc_by_bssid == false)
+ if (!pmlmepriv->assoc_by_bssid)
memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.mac_address[0], ETH_ALEN);

psecnetwork->ie_length = rtw_restruct_sec_ie(padapter, &pnetwork->network.ies[0], &psecnetwork->ies[0], pnetwork->network.ie_length);
@@ -927,7 +927,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
else
GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false);

- if (unicast_key == true)
+ if (unicast_key)
memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16);
else
memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16);
@@ -1165,7 +1165,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
u8 res = _SUCCESS;

/* check if allow software config */
- if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter) == true) {
+ if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter)) {
res = _FAIL;
goto exit;
}
@@ -1251,7 +1251,7 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer)
/* */
/* Determine if our traffic is busy now */
/* */
- if ((check_fwstate(pmlmepriv, _FW_LINKED) == true)
+ if (check_fwstate(pmlmepriv, _FW_LINKED)
/*&& !MgntInitAdapterInProgress(pMgntInfo)*/) {
/* if we raise bBusyTraffic in last watchdog, using lower threshold. */
if (pmlmepriv->LinkDetectInfo.bBusyTraffic)
@@ -1283,7 +1283,7 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer)
(pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) {
bEnterPS = false;

- if (bBusyTraffic == true) {
+ if (bBusyTraffic) {
if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount <= 4)
pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 4;

@@ -1343,7 +1343,7 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter)

pmlmepriv = &(padapter->mlmepriv);

- if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
expire_timeout_chk(padapter);

/* for debug purpose */
@@ -1378,8 +1378,8 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
u8 mstatus;

- if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)
- || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
+ check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
return;
}

@@ -1387,7 +1387,7 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
case LPS_CTRL_SCAN:
hal_btcoex_ScanNotify(padapter, true);

- if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED)) {
/* connect */
LPS_Leave(padapter, "LPS_CTRL_SCAN");
}
@@ -1513,7 +1513,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim)
if (dtim <= 0 || dtim > 16)
return;

- if (hal_btcoex_IsBtControlLps(padapter) == true)
+ if (hal_btcoex_IsBtControlLps(padapter))
return;

mutex_lock(&pwrpriv->lock);
@@ -1619,7 +1619,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter)

rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);

- while (false == empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) {
+ while (!empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) {
msleep(100);
rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);
}
@@ -1841,7 +1841,7 @@ static void c2h_wk_callback(struct work_struct *work)
continue;
}

- if (ccx_id_filter(c2h_evt) == true) {
+ if (ccx_id_filter(c2h_evt)) {
/* Handle CCX report here */
rtw_hal_c2h_handler(adapter, c2h_evt);
kfree(c2h_evt);
@@ -2054,7 +2054,7 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *

spin_lock_bh(&pmlmepriv->lock);

- if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true))
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);

set_fwstate(pmlmepriv, _FW_LINKED);
--
2.25.1


2021-10-20 09:50:53

by Praveen Kumar

[permalink] [raw]
Subject: Re: [Outreachy kernel] [PATCH] staging: rtl8723bs: core: Remove true and false comparison and unnecessary parentheses

On 20-10-2021 15:04, Kushal Kothari wrote:
> Remove comparison to true and false in if statement.
> Issue found with checkpatch.pl.
> CHECK: Using comparison to true is error prone
> CHECK: Using comparison to false is error prone
> CHECK: Unnecessary parentheses
>
> Signed-off-by: Kushal Kothari <[email protected]>
> ---
> drivers/staging/rtl8723bs/core/rtw_cmd.c | 50 ++++++++++++------------
> 1 file changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> index efc9b1974e38..3e0b910114da 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> @@ -309,8 +309,8 @@ int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
> if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan))
> bAllow = true;
>
> - if ((pcmdpriv->padapter->hw_init_completed == false && bAllow == false)
> - || atomic_read(&(pcmdpriv->cmdthd_running)) == false /* com_thread not running */
> + if ((!pcmdpriv->padapter->hw_init_completed && !bAllow) ||
> + !atomic_read(&pcmdpriv->cmdthd_running) /* com_thread not running */
> )

Please move ')' something like this.

> + if ((!pcmdpriv->padapter->hw_init_completed && !bAllow) ||
> + !atomic_read(&pcmdpriv->cmdthd_running)) /* com_thread not running */



> return _FAIL;
>
> @@ -372,7 +372,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
> void rtw_stop_cmd_thread(struct adapter *adapter)
> {
> if (adapter->cmdThread &&
> - atomic_read(&(adapter->cmdpriv.cmdthd_running)) == true &&
> + atomic_read(&adapter->cmdpriv.cmdthd_running) &&
> adapter->cmdpriv.stop_req == 0) {
> adapter->cmdpriv.stop_req = 1;
> complete(&adapter->cmdpriv.cmd_queue_comp);
> @@ -388,7 +388,7 @@ int rtw_cmd_thread(void *context)
> u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf);
> void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd);
> struct adapter *padapter = context;
> - struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
> + struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
> struct drvextra_cmd_parm *extra_parm = NULL;
>
> thread_enter("RTW_CMD_THREAD");
> @@ -396,7 +396,7 @@ int rtw_cmd_thread(void *context)
> pcmdbuf = pcmdpriv->cmd_buf;
>
> pcmdpriv->stop_req = 0;
> - atomic_set(&(pcmdpriv->cmdthd_running), true);
> + atomic_set(&pcmdpriv->cmdthd_running, true);
> complete(&pcmdpriv->terminate_cmdthread_comp);
>
> while (1) {
> @@ -407,7 +407,7 @@ int rtw_cmd_thread(void *context)
> break;
> }
>
> - if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
> + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
> netdev_dbg(padapter->pnetdev,
> "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
> __func__, padapter->bDriverStopped,
> @@ -430,7 +430,7 @@ int rtw_cmd_thread(void *context)
> continue;
>
> _next:
> - if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
> + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
> netdev_dbg(padapter->pnetdev,
> "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
> __func__, padapter->bDriverStopped,
> @@ -472,7 +472,7 @@ int rtw_cmd_thread(void *context)
>
> post_process:
>
> - if (mutex_lock_interruptible(&(pcmd->padapter->cmdpriv.sctx_mutex)) == 0) {
> + if (mutex_lock_interruptible(&pcmd->padapter->cmdpriv.sctx_mutex) == 0) {

Is this change required ? This is not inline with the v1 patch summary as well.
If required, I would request to make it in a different patch.

> if (pcmd->sctx) {
> netdev_dbg(padapter->pnetdev,
> FUNC_ADPT_FMT " pcmd->sctx\n",
> @@ -483,7 +483,7 @@ int rtw_cmd_thread(void *context)
> else
> rtw_sctx_done_err(&pcmd->sctx, RTW_SCTX_DONE_CMD_ERROR);
> }
> - mutex_unlock(&(pcmd->padapter->cmdpriv.sctx_mutex));
> + mutex_unlock(&pcmd->padapter->cmdpriv.sctx_mutex);
> }
>
> /* call callback function for post-processed */
> @@ -523,7 +523,7 @@ int rtw_cmd_thread(void *context)
> } while (1);
>
> complete(&pcmdpriv->terminate_cmdthread_comp);
> - atomic_set(&(pcmdpriv->cmdthd_running), false);
> + atomic_set(&pcmdpriv->cmdthd_running, false);
>
> thread_exit();
> }
> @@ -543,7 +543,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
> struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
> struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
>
> - if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
> + if (check_fwstate(pmlmepriv, _FW_LINKED))
> rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);
>
> ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
> @@ -725,7 +725,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
> struct ht_priv *phtpriv = &pmlmepriv->htpriv;
> enum ndis_802_11_network_infrastructure ndis_network_mode = pnetwork->network.infrastructure_mode;
> struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
> - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
> + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
> u32 tmp_len;
> u8 *ptmp = NULL;
>
> @@ -776,7 +776,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
> /* If not, we have to copy the connecting AP's MAC address to it so that */
> /* the driver just has the bssid information for PMKIDList searching. */
>
> - if (pmlmepriv->assoc_by_bssid == false)
> + if (!pmlmepriv->assoc_by_bssid)
> memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.mac_address[0], ETH_ALEN);
>
> psecnetwork->ie_length = rtw_restruct_sec_ie(padapter, &pnetwork->network.ies[0], &psecnetwork->ies[0], pnetwork->network.ie_length);
> @@ -927,7 +927,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
> else
> GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false);
>
> - if (unicast_key == true)
> + if (unicast_key)
> memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16);
> else
> memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16);
> @@ -1165,7 +1165,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
> u8 res = _SUCCESS;
>
> /* check if allow software config */
> - if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter) == true) {
> + if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter)) {
> res = _FAIL;
> goto exit;
> }
> @@ -1251,7 +1251,7 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer)
> /* */
> /* Determine if our traffic is busy now */
> /* */
> - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true)
> + if (check_fwstate(pmlmepriv, _FW_LINKED)
> /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) {
> /* if we raise bBusyTraffic in last watchdog, using lower threshold. */
> if (pmlmepriv->LinkDetectInfo.bBusyTraffic)
> @@ -1283,7 +1283,7 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer)
> (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) {
> bEnterPS = false;
>
> - if (bBusyTraffic == true) {
> + if (bBusyTraffic) {
> if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount <= 4)
> pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 4;
>
> @@ -1343,7 +1343,7 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter)
>
> pmlmepriv = &(padapter->mlmepriv);
>
> - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
> + if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
> expire_timeout_chk(padapter);
>
> /* for debug purpose */
> @@ -1378,8 +1378,8 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
> struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
> u8 mstatus;
>
> - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)
> - || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
> + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
> + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
> return;
> }
>
> @@ -1387,7 +1387,7 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
> case LPS_CTRL_SCAN:
> hal_btcoex_ScanNotify(padapter, true);
>
> - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
> + if (check_fwstate(pmlmepriv, _FW_LINKED)) {
> /* connect */
> LPS_Leave(padapter, "LPS_CTRL_SCAN");
> }
> @@ -1513,7 +1513,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim)
> if (dtim <= 0 || dtim > 16)
> return;
>
> - if (hal_btcoex_IsBtControlLps(padapter) == true)
> + if (hal_btcoex_IsBtControlLps(padapter))
> return;
>
> mutex_lock(&pwrpriv->lock);
> @@ -1619,7 +1619,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter)
>
> rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);
>
> - while (false == empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) {
> + while (!empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) {
> msleep(100);
> rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);
> }
> @@ -1841,7 +1841,7 @@ static void c2h_wk_callback(struct work_struct *work)
> continue;
> }
>
> - if (ccx_id_filter(c2h_evt) == true) {
> + if (ccx_id_filter(c2h_evt)) {
> /* Handle CCX report here */
> rtw_hal_c2h_handler(adapter, c2h_evt);
> kfree(c2h_evt);
> @@ -2054,7 +2054,7 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *
>
> spin_lock_bh(&pmlmepriv->lock);
>
> - if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true))
> + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
> _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
>
> set_fwstate(pmlmepriv, _FW_LINKED);
>

Regards,

~Praveen.

2021-10-20 09:55:47

by Praveen Kumar

[permalink] [raw]
Subject: Re: [Outreachy kernel] [PATCH] staging: rtl8723bs: core: Remove true and false comparison and unnecessary parentheses

On 20-10-2021 15:04, Kushal Kothari wrote:
> Remove comparison to true and false in if statement.
> Issue found with checkpatch.pl.
> CHECK: Using comparison to true is error prone
> CHECK: Using comparison to false is error prone

Request to please document the modification / comments handled from the previous patch sent.
Also, please update [PATCH V*] in the Subject, that will help keeping track of versions. Thanks.

> CHECK: Unnecessary parentheses
>
> Signed-off-by: Kushal Kothari <[email protected]>
> ---
> drivers/staging/rtl8723bs/core/rtw_cmd.c | 50 ++++++++++++------------
> 1 file changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> index efc9b1974e38..3e0b910114da 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> @@ -309,8 +309,8 @@ int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
> if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan))
> bAllow = true;
>
> - if ((pcmdpriv->padapter->hw_init_completed == false && bAllow == false)
> - || atomic_read(&(pcmdpriv->cmdthd_running)) == false /* com_thread not running */
> + if ((!pcmdpriv->padapter->hw_init_completed && !bAllow) ||
> + !atomic_read(&pcmdpriv->cmdthd_running) /* com_thread not running */
> )
> return _FAIL;
>
> @@ -372,7 +372,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
> void rtw_stop_cmd_thread(struct adapter *adapter)
> {
> if (adapter->cmdThread &&
> - atomic_read(&(adapter->cmdpriv.cmdthd_running)) == true &&
> + atomic_read(&adapter->cmdpriv.cmdthd_running) &&
> adapter->cmdpriv.stop_req == 0) {
> adapter->cmdpriv.stop_req = 1;
> complete(&adapter->cmdpriv.cmd_queue_comp);
> @@ -388,7 +388,7 @@ int rtw_cmd_thread(void *context)
> u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf);
> void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd);
> struct adapter *padapter = context;
> - struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
> + struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
> struct drvextra_cmd_parm *extra_parm = NULL;
>
> thread_enter("RTW_CMD_THREAD");
> @@ -396,7 +396,7 @@ int rtw_cmd_thread(void *context)
> pcmdbuf = pcmdpriv->cmd_buf;
>
> pcmdpriv->stop_req = 0;
> - atomic_set(&(pcmdpriv->cmdthd_running), true);
> + atomic_set(&pcmdpriv->cmdthd_running, true);
> complete(&pcmdpriv->terminate_cmdthread_comp);
>
> while (1) {
> @@ -407,7 +407,7 @@ int rtw_cmd_thread(void *context)
> break;
> }
>
> - if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
> + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
> netdev_dbg(padapter->pnetdev,
> "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
> __func__, padapter->bDriverStopped,
> @@ -430,7 +430,7 @@ int rtw_cmd_thread(void *context)
> continue;
>
> _next:
> - if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
> + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
> netdev_dbg(padapter->pnetdev,
> "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
> __func__, padapter->bDriverStopped,
> @@ -472,7 +472,7 @@ int rtw_cmd_thread(void *context)
>
> post_process:
>
> - if (mutex_lock_interruptible(&(pcmd->padapter->cmdpriv.sctx_mutex)) == 0) {
> + if (mutex_lock_interruptible(&pcmd->padapter->cmdpriv.sctx_mutex) == 0) {
> if (pcmd->sctx) {
> netdev_dbg(padapter->pnetdev,
> FUNC_ADPT_FMT " pcmd->sctx\n",
> @@ -483,7 +483,7 @@ int rtw_cmd_thread(void *context)
> else
> rtw_sctx_done_err(&pcmd->sctx, RTW_SCTX_DONE_CMD_ERROR);
> }
> - mutex_unlock(&(pcmd->padapter->cmdpriv.sctx_mutex));
> + mutex_unlock(&pcmd->padapter->cmdpriv.sctx_mutex);
> }
>
> /* call callback function for post-processed */
> @@ -523,7 +523,7 @@ int rtw_cmd_thread(void *context)
> } while (1);
>
> complete(&pcmdpriv->terminate_cmdthread_comp);
> - atomic_set(&(pcmdpriv->cmdthd_running), false);
> + atomic_set(&pcmdpriv->cmdthd_running, false);
>
> thread_exit();
> }
> @@ -543,7 +543,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
> struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
> struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
>
> - if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
> + if (check_fwstate(pmlmepriv, _FW_LINKED))
> rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);
>
> ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
> @@ -725,7 +725,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
> struct ht_priv *phtpriv = &pmlmepriv->htpriv;
> enum ndis_802_11_network_infrastructure ndis_network_mode = pnetwork->network.infrastructure_mode;
> struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
> - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
> + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
> u32 tmp_len;
> u8 *ptmp = NULL;
>
> @@ -776,7 +776,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
> /* If not, we have to copy the connecting AP's MAC address to it so that */
> /* the driver just has the bssid information for PMKIDList searching. */
>
> - if (pmlmepriv->assoc_by_bssid == false)
> + if (!pmlmepriv->assoc_by_bssid)
> memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.mac_address[0], ETH_ALEN);
>
> psecnetwork->ie_length = rtw_restruct_sec_ie(padapter, &pnetwork->network.ies[0], &psecnetwork->ies[0], pnetwork->network.ie_length);
> @@ -927,7 +927,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
> else
> GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false);
>
> - if (unicast_key == true)
> + if (unicast_key)
> memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16);
> else
> memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16);
> @@ -1165,7 +1165,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
> u8 res = _SUCCESS;
>
> /* check if allow software config */
> - if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter) == true) {
> + if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter)) {
> res = _FAIL;
> goto exit;
> }
> @@ -1251,7 +1251,7 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer)
> /* */
> /* Determine if our traffic is busy now */
> /* */
> - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true)
> + if (check_fwstate(pmlmepriv, _FW_LINKED)
> /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) {
> /* if we raise bBusyTraffic in last watchdog, using lower threshold. */
> if (pmlmepriv->LinkDetectInfo.bBusyTraffic)
> @@ -1283,7 +1283,7 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer)
> (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) {
> bEnterPS = false;
>
> - if (bBusyTraffic == true) {
> + if (bBusyTraffic) {
> if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount <= 4)
> pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 4;
>
> @@ -1343,7 +1343,7 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter)
>
> pmlmepriv = &(padapter->mlmepriv);
>
> - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
> + if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
> expire_timeout_chk(padapter);
>
> /* for debug purpose */
> @@ -1378,8 +1378,8 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
> struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
> u8 mstatus;
>
> - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)
> - || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
> + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
> + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
> return;
> }
>
> @@ -1387,7 +1387,7 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
> case LPS_CTRL_SCAN:
> hal_btcoex_ScanNotify(padapter, true);
>
> - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
> + if (check_fwstate(pmlmepriv, _FW_LINKED)) {
> /* connect */
> LPS_Leave(padapter, "LPS_CTRL_SCAN");
> }
> @@ -1513,7 +1513,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim)
> if (dtim <= 0 || dtim > 16)
> return;
>
> - if (hal_btcoex_IsBtControlLps(padapter) == true)
> + if (hal_btcoex_IsBtControlLps(padapter))
> return;
>
> mutex_lock(&pwrpriv->lock);
> @@ -1619,7 +1619,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter)
>
> rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);
>
> - while (false == empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) {
> + while (!empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) {
> msleep(100);
> rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);
> }
> @@ -1841,7 +1841,7 @@ static void c2h_wk_callback(struct work_struct *work)
> continue;
> }
>
> - if (ccx_id_filter(c2h_evt) == true) {
> + if (ccx_id_filter(c2h_evt)) {
> /* Handle CCX report here */
> rtw_hal_c2h_handler(adapter, c2h_evt);
> kfree(c2h_evt);
> @@ -2054,7 +2054,7 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *
>
> spin_lock_bh(&pmlmepriv->lock);
>
> - if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true))
> + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
> _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
>
> set_fwstate(pmlmepriv, _FW_LINKED);
>

Regards,

~Praveen.

2021-11-02 13:50:23

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: rtl8723bs: core: Remove true and false comparison and unnecessary parentheses

This should be a v2 patch. There is a specific format for that. The
subject isn't really correct. It should just be:

Subject: [PATCH] staging: rtl8723bs: Remove true and false comparisons

Removing the unnecessary parentheses is a necessary part of removing the
comparisons but it's not its own thing. You can mention it in the
commit message if you want, but don't put it in the subject. It's not
even necessarily something I would mention because everyone understands
why you're removing the parentheses... But if you want you can add that
to the commit message: "After I removed the "== true" then I had to
remove some extra parentheses to avoid introducing a new checkpatch
warning".

On Wed, Oct 20, 2021 at 03:04:58PM +0530, Kushal Kothari wrote:
> Remove comparison to true and false in if statement.
> Issue found with checkpatch.pl.
> CHECK: Using comparison to true is error prone
> CHECK: Using comparison to false is error prone
> CHECK: Unnecessary parentheses
>
> Signed-off-by: Kushal Kothari <[email protected]>
> ---
> drivers/staging/rtl8723bs/core/rtw_cmd.c | 50 ++++++++++++------------
> 1 file changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> index efc9b1974e38..3e0b910114da 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> @@ -309,8 +309,8 @@ int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
> if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan))
> bAllow = true;
>
> - if ((pcmdpriv->padapter->hw_init_completed == false && bAllow == false)
> - || atomic_read(&(pcmdpriv->cmdthd_running)) == false /* com_thread not running */
> + if ((!pcmdpriv->padapter->hw_init_completed && !bAllow) ||
> + !atomic_read(&pcmdpriv->cmdthd_running) /* com_thread not running */
> )

In your v1 patch, you were more conservative and changed fewer things.
Once you start moving the || to the previous line, then it opens up
other questions like should you align the !atomic_read() correctly and
move the ')' character? And the answer is probably no. Just do it like
you did in v1. No one had an issue with that.

> return _FAIL;
>
> @@ -372,7 +372,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
> void rtw_stop_cmd_thread(struct adapter *adapter)
> {
> if (adapter->cmdThread &&
> - atomic_read(&(adapter->cmdpriv.cmdthd_running)) == true &&
> + atomic_read(&adapter->cmdpriv.cmdthd_running) &&

This is not related to boolean comparisons so it belongs in another
patch.

> adapter->cmdpriv.stop_req == 0) {
> adapter->cmdpriv.stop_req = 1;
> complete(&adapter->cmdpriv.cmd_queue_comp);
> @@ -388,7 +388,7 @@ int rtw_cmd_thread(void *context)
> u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf);
> void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd);
> struct adapter *padapter = context;
> - struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
> + struct cmd_priv *pcmdpriv = &padapter->cmdpriv;

Separate patch.

> struct drvextra_cmd_parm *extra_parm = NULL;
>
> thread_enter("RTW_CMD_THREAD");
> @@ -396,7 +396,7 @@ int rtw_cmd_thread(void *context)
> pcmdbuf = pcmdpriv->cmd_buf;
>
> pcmdpriv->stop_req = 0;
> - atomic_set(&(pcmdpriv->cmdthd_running), true);
> + atomic_set(&pcmdpriv->cmdthd_running, true);

Separate.

> complete(&pcmdpriv->terminate_cmdthread_comp);
>
> while (1) {
> @@ -407,7 +407,7 @@ int rtw_cmd_thread(void *context)
> break;
> }
>
> - if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
> + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {

Good.

> netdev_dbg(padapter->pnetdev,
> "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
> __func__, padapter->bDriverStopped,
> @@ -430,7 +430,7 @@ int rtw_cmd_thread(void *context)
> continue;
>
> _next:
> - if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
> + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {

Good.

> netdev_dbg(padapter->pnetdev,
> "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
> __func__, padapter->bDriverStopped,
> @@ -472,7 +472,7 @@ int rtw_cmd_thread(void *context)
>
> post_process:
>
> - if (mutex_lock_interruptible(&(pcmd->padapter->cmdpriv.sctx_mutex)) == 0) {
> + if (mutex_lock_interruptible(&pcmd->padapter->cmdpriv.sctx_mutex) == 0) {

Separate.

> if (pcmd->sctx) {
> netdev_dbg(padapter->pnetdev,
> FUNC_ADPT_FMT " pcmd->sctx\n",
> @@ -483,7 +483,7 @@ int rtw_cmd_thread(void *context)
> else
> rtw_sctx_done_err(&pcmd->sctx, RTW_SCTX_DONE_CMD_ERROR);
> }
> - mutex_unlock(&(pcmd->padapter->cmdpriv.sctx_mutex));
> + mutex_unlock(&pcmd->padapter->cmdpriv.sctx_mutex);

Separate. Etc, same thing everywhere. Don't fix parentheses check
patch warnings, but don't introduce new ones either.

regards,
dan carpenter