linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: avoid use of goto statement
@ 2021-10-25  4:58 Saurav Girepunje
  2021-10-25  6:57 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Saurav Girepunje @ 2021-10-25  4:58 UTC (permalink / raw)
  To: Larry.Finger, phil, gregkh, straube.linux, linux-staging, linux-kernel
  Cc: saurav.girepunje

Remove the goto statement from _rtw_init_cmd_priv(). In this function
goto statement can be replace by return statement. By replacing the
goto statement with return statement local variable "res" is also
not required.As on goto label exit, function only return it is not
performing any cleanup.Avoiding goto will simplify the function.

Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
---
 drivers/staging/r8188eu/core/rtw_cmd.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
index e17332677daa..22046bd5cf82 100644
--- a/drivers/staging/r8188eu/core/rtw_cmd.c
+++ b/drivers/staging/r8188eu/core/rtw_cmd.c
@@ -19,7 +19,6 @@ No irqsave is necessary.

 static int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
 {
-	int res = _SUCCESS;

 	sema_init(&pcmdpriv->cmd_queue_sema, 0);
 	/* sema_init(&(pcmdpriv->cmd_done_sema), 0); */
@@ -34,28 +33,23 @@ static int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
 	pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ,
 					      GFP_KERNEL);

-	if (!pcmdpriv->cmd_allocated_buf) {
-		res = _FAIL;
-		goto exit;
-	}
+	if (!pcmdpriv->cmd_allocated_buf)
+		return _FAIL;

 	pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf  +  CMDBUFF_ALIGN_SZ - ((size_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ - 1));

 	pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_KERNEL);

-	if (!pcmdpriv->rsp_allocated_buf) {
-		res = _FAIL;
-		goto exit;
-	}
+	if (!pcmdpriv->rsp_allocated_buf)
+		return _FAIL;

 	pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf  +  4 - ((size_t)(pcmdpriv->rsp_allocated_buf) & 3);

 	pcmdpriv->cmd_issued_cnt = 0;
 	pcmdpriv->cmd_done_cnt = 0;
 	pcmdpriv->rsp_cnt = 0;
-exit:

-	return res;
+	return _SUCCESS;
 }

 static void c2h_wk_callback(struct work_struct *work);
--
2.33.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: r8188eu: avoid use of goto statement
  2021-10-25  4:58 [PATCH] staging: r8188eu: avoid use of goto statement Saurav Girepunje
@ 2021-10-25  6:57 ` Greg KH
  2021-10-25 14:39   ` Saurav Girepunje
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2021-10-25  6:57 UTC (permalink / raw)
  To: Saurav Girepunje
  Cc: Larry.Finger, phil, straube.linux, linux-staging, linux-kernel,
	saurav.girepunje

On Mon, Oct 25, 2021 at 10:28:54AM +0530, Saurav Girepunje wrote:
> Remove the goto statement from _rtw_init_cmd_priv(). In this function
> goto statement can be replace by return statement. By replacing the
> goto statement with return statement local variable "res" is also
> not required.As on goto label exit, function only return it is not

You need a ' ' after the '.' here please.

> performing any cleanup.Avoiding goto will simplify the function.

Same here.

> Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
> ---
>  drivers/staging/r8188eu/core/rtw_cmd.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
> index e17332677daa..22046bd5cf82 100644
> --- a/drivers/staging/r8188eu/core/rtw_cmd.c
> +++ b/drivers/staging/r8188eu/core/rtw_cmd.c
> @@ -19,7 +19,6 @@ No irqsave is necessary.
> 
>  static int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
>  {
> -	int res = _SUCCESS;
> 

Please also remove the extra blank line.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: r8188eu: avoid use of goto statement
  2021-10-25  6:57 ` Greg KH
@ 2021-10-25 14:39   ` Saurav Girepunje
  0 siblings, 0 replies; 3+ messages in thread
From: Saurav Girepunje @ 2021-10-25 14:39 UTC (permalink / raw)
  To: Greg KH
  Cc: Larry.Finger, phil, straube.linux, linux-staging, linux-kernel,
	saurav.girepunje



On 25/10/21 12:27 pm, Greg KH wrote:
> On Mon, Oct 25, 2021 at 10:28:54AM +0530, Saurav Girepunje wrote:
>> Remove the goto statement from _rtw_init_cmd_priv(). In this function
>> goto statement can be replace by return statement. By replacing the
>> goto statement with return statement local variable "res" is also
>> not required.As on goto label exit, function only return it is not
> 
> You need a ' ' after the '.' here please.
> 
>> performing any cleanup.Avoiding goto will simplify the function.
> 
> Same here.
> 
>> Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
>> ---
>>  drivers/staging/r8188eu/core/rtw_cmd.c | 16 +++++-----------
>>  1 file changed, 5 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
>> index e17332677daa..22046bd5cf82 100644
>> --- a/drivers/staging/r8188eu/core/rtw_cmd.c
>> +++ b/drivers/staging/r8188eu/core/rtw_cmd.c
>> @@ -19,7 +19,6 @@ No irqsave is necessary.
>>
>>  static int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
>>  {
>> -	int res = _SUCCESS;
>>
> 
> Please also remove the extra blank line.
> 
> thanks,
> 
> greg k-h
> 

Thanks greg for review. I have updated the patch and sent v2.

Regards,
Saurav Girepunje 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-25 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25  4:58 [PATCH] staging: r8188eu: avoid use of goto statement Saurav Girepunje
2021-10-25  6:57 ` Greg KH
2021-10-25 14:39   ` Saurav Girepunje

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).