public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Saurav Girepunje <saurav.girepunje@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Larry.Finger@lwfinger.net, phil@philpotter.co.uk,
	straube.linux@gmail.com, martin@kaiser.cx,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	saurav.girepunje@hotmail.com
Subject: Re: [PATCH] staging: r8188eu: os_dep: remove the goto statement
Date: Tue, 2 Nov 2021 22:00:06 +0530	[thread overview]
Message-ID: <9bbc97e2-ab20-efb4-d055-ebce021b7c97@gmail.com> (raw)
In-Reply-To: <YX/lJMEfqXqlserL@kroah.com>



On 01/11/21 6:31 pm, Greg KH wrote:
> On Sun, Oct 31, 2021 at 11:40:18PM +0530, Saurav Girepunje wrote:
>> Remove the goto statement from rtw_init_drv_sw(). In this function goto
>> can be replace by return statement. As on goto label exit, function
>> only return it is not performing any cleanup. Avoiding goto will
>> improve the function readability.
>>
>> Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
>> ---
>>  drivers/staging/r8188eu/os_dep/os_intfs.c | 39 +++++++----------------
>>  1 file changed, 12 insertions(+), 27 deletions(-)
>>
>> diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
>> index 1418c9c4916c..4b409479108e 100644
>> --- a/drivers/staging/r8188eu/os_dep/os_intfs.c
>> +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
>> @@ -480,48 +480,34 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
>>  {
>>  	u8	ret8 = _SUCCESS;
>>
>> -	if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) {
>> -		ret8 = _FAIL;
>> -		goto exit;
>> -	}
>> +	if (!rtw_init_cmd_priv(&padapter->cmdpriv))
>> +		return _FAIL;
>>
>>  	padapter->cmdpriv.padapter = padapter;
>>
>> -	if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) {
>> -		ret8 = _FAIL;
>> -		goto exit;
>> -	}
>> -
>> -	if (rtw_init_mlme_priv(padapter) == _FAIL) {
>> -		ret8 = _FAIL;
>> -		goto exit;
>> -	}
>> +	if (!rtw_init_evt_priv(&padapter->evtpriv) || !rtw_init_mlme_priv(padapter))
>> +		return _FAIL;
> 
> These are functions that are being called so keeping them separate as
> the code you removed did makes it "obvious" what is happening here.
> 
> So can you keep it that way please?
> 
I will make them separate as they were.

> But my larger question is do these functions create state or allocate
> memory that needs to be unwound properly if an error does happen?  Right
> now the function seems to not be doing that at all, but that does not
> mean it is correct as-is...
> 
> thanks,
> 
> greg k-h
> Regards,
Saurav


      reply	other threads:[~2021-11-02 16:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-31 18:10 [PATCH] staging: r8188eu: os_dep: remove the goto statement Saurav Girepunje
2021-10-31 18:43 ` Pavel Skripkin
2021-10-31 19:17   ` Joe Perches
2021-11-01  4:28     ` Saurav Girepunje
2021-11-01  4:31       ` Joe Perches
2021-10-31 19:17   ` Saurav Girepunje
2021-10-31 19:24     ` Pavel Skripkin
2021-10-31 19:27       ` Pavel Skripkin
2021-11-02 16:40         ` Saurav Girepunje
2021-11-02 20:20           ` Pavel Skripkin
2021-11-01 13:01 ` Greg KH
2021-11-02 16:30   ` Saurav Girepunje [this message]

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=9bbc97e2-ab20-efb4-d055-ebce021b7c97@gmail.com \
    --to=saurav.girepunje@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=martin@kaiser.cx \
    --cc=phil@philpotter.co.uk \
    --cc=saurav.girepunje@hotmail.com \
    --cc=straube.linux@gmail.com \
    /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