linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Jaehee Park <jhpark1013@gmail.com>
Cc: Larry.Finger@lwfinger.net, phil@philpotter.co.uk,
	gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org, outreachy@lists.linux.dev,
	jhpark1013@gmail.com
Subject: Re: [PATCH v4 1/7] staging: r8188eu: remove unnecessary braces in single statement block
Date: Fri, 22 Apr 2022 01:20:29 +0200	[thread overview]
Message-ID: <3485895.R56niFO833@leap> (raw)
In-Reply-To: <16185752.0ZKypZ73Fx@leap>

On giovedì 21 aprile 2022 21:52:14 CEST Fabio M. De Francesco wrote:
> On giovedì 21 aprile 2022 21:20:26 CEST Jaehee Park wrote:
> > Remove braces for single statement block to minimize the number of
> > empty lines, without loss of readability. Issue found with checkpatch.
> > WARNING: braces {} are not necessary for single statement blocks
> > 
> > Signed-off-by: Jaehee Park <jhpark1013@gmail.com>
> > ---
> >  drivers/staging/r8188eu/core/rtw_mlme.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/
> r8188eu/core/rtw_mlme.c
> > index 3e9882f89f76..d3f4d7cdfa08 100644
> > --- a/drivers/staging/r8188eu/core/rtw_mlme.c
> > +++ b/drivers/staging/r8188eu/core/rtw_mlme.c
> > @@ -112,9 +112,8 @@ void _rtw_free_mlme_priv(struct mlme_priv 
*pmlmepriv)
> >  
> >  	rtw_free_mlme_priv_ie_data(pmlmepriv);
> >  
> > -	if (pmlmepriv) {
> > +	if (pmlmepriv)
> >  		vfree(pmlmepriv->free_bss_buf);
> > -	}
> >  
> >  }
> >  
> > -- 
> > 2.25.1
> > 
> 
> Hi Jaehee,
> 
> If you just want to remove the braces, your patch is good.
> 
> But... Did you ask yourself why this code needs to test if "pmlmepriv" is 
> valid before calling vfree() on it? Actually, the code doesn't need this 
> test, it just needs to call "vfree(pmlmepriv)" unconditionally.

When copy-pasting I overlooked a couple of things... However the argument 
is the same: the code doesn't need that 'if' statement before vfree().

I wanted to write "[] it just needs to call "vfree(pmlmepriv-
>free_bss_buf)" unconditionally".

I apologize for not reading twice before sending my email too soon after 
writing and moving sentences around.

> OK, I know that this is not directly related to your patch or any other 
> that is explicitly made just for removing unnecessary braces... 

"pmlmepriv" is valid because we know it from the previous call to 
rtw_free_mlme_priv_ie_data(). Therefore the code can dereference 
"pmlmepriv".

Furthermore, even if "free_bss_buf" were NULL it wouldn't matter because 
"vfree(pmlmepriv->free_bss_buf)" would be a no-op.

Sorry if this inaccurate wording might have confused you about what I was 
trying to say.

Thanks,

Fabio 



  reply	other threads:[~2022-04-21 23:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 19:20 [PATCH v4 0/7] staging: r8188eu: fix warnings reported by checkpatch Jaehee Park
2022-04-21 19:20 ` [PATCH v4 1/7] staging: r8188eu: remove unnecessary braces in single statement block Jaehee Park
2022-04-21 19:52   ` Fabio M. De Francesco
2022-04-21 23:20     ` Fabio M. De Francesco [this message]
2022-04-21 19:20 ` [PATCH v4 2/7] staging: r8188eu: remove spaces before tabs Jaehee Park
2022-04-21 19:20 ` [PATCH v4 3/7] staging: r8188eu: remove 'added by' author comments Jaehee Park
2022-04-21 19:20 ` [PATCH v4 4/7] staging: r8188eu: place constants on the right side of tests Jaehee Park
2022-04-21 19:20 ` [PATCH v4 5/7] staging: r8188eu: replace spaces with tabs Jaehee Park
2022-04-21 19:20 ` [PATCH v4 6/7] staging: r8188eu: correct typo in comments Jaehee Park
2022-04-21 19:20 ` [PATCH v4 7/7] staging: r8188eu: remove unused else condition Jaehee Park
2022-04-22 14:45   ` Greg KH
2022-04-27 15:37     ` Jaehee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3485895.R56niFO833@leap \
    --to=fmdefrancesco@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jhpark1013@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=outreachy@lists.linux.dev \
    --cc=phil@philpotter.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).