lkml.org 
[lkml]   [2021]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [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 <kushalkothari285@gmail.com>
> ---
> 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

\
 
 \ /
  Last update: 2021-11-02 14:49    [W:0.066 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site