linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: os_dep: remove multiple return
@ 2021-04-18 17:32 Saurav Girepunje
  2021-04-20 11:03 ` Dan Carpenter
  2021-04-20 11:06 ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Saurav Girepunje @ 2021-04-18 17:32 UTC (permalink / raw)
  To: gregkh, fabioaiuto83, hello, hdegoede, saurav.girepunje,
	john.oldman, linux-staging, linux-kernel
  Cc: saurav.girepunje

on sdio_intf.c rtw_sdio_suspend call we have multiple
return which can replace by goto exit. As in all the places
return value is 0.

Signed-off-by: Saurav Girepunje <saurav.girepunje@google.com>
---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index a9a9631dd23c..3e566cf97f6e 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -445,14 +445,17 @@ static int rtw_sdio_suspend(struct device *dev)
 	struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
 
 	if (padapter->bDriverStopped)
-		return 0;
+		goto exit;
 
 	if (pwrpriv->bInSuspend) {
 		pdbgpriv->dbg_suspend_error_cnt++;
-		return 0;
+		goto exit;
 	}
 
-	return rtw_suspend_common(padapter);
+	rtw_suspend_common(padapter);
+exit:
+
+	return 0;
 }
 
 static int rtw_resume_process(struct adapter *padapter)
-- 
2.25.1


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

* Re: [PATCH] staging: rtl8723bs: os_dep: remove multiple return
  2021-04-18 17:32 [PATCH] staging: rtl8723bs: os_dep: remove multiple return Saurav Girepunje
@ 2021-04-20 11:03 ` Dan Carpenter
  2021-04-20 11:06 ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-04-20 11:03 UTC (permalink / raw)
  To: Saurav Girepunje
  Cc: gregkh, fabioaiuto83, hello, hdegoede, saurav.girepunje,
	john.oldman, linux-staging, linux-kernel, saurav.girepunje

On Sun, Apr 18, 2021 at 11:02:33PM +0530, Saurav Girepunje wrote:
> on sdio_intf.c rtw_sdio_suspend call we have multiple
> return which can replace by goto exit. As in all the places
> return value is 0.
> 

Why?

Do nothing gotos just make the code harder to read and introduce forgot
to set the error code bugs.

regards,
dan carpenter


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

* Re: [PATCH] staging: rtl8723bs: os_dep: remove multiple return
  2021-04-18 17:32 [PATCH] staging: rtl8723bs: os_dep: remove multiple return Saurav Girepunje
  2021-04-20 11:03 ` Dan Carpenter
@ 2021-04-20 11:06 ` Dan Carpenter
  2021-04-27 19:45   ` SAURAV GIREPUNJE
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2021-04-20 11:06 UTC (permalink / raw)
  To: Saurav Girepunje
  Cc: gregkh, fabioaiuto83, hello, hdegoede, saurav.girepunje,
	john.oldman, linux-staging, linux-kernel, saurav.girepunje

On Sun, Apr 18, 2021 at 11:02:33PM +0530, Saurav Girepunje wrote:
> on sdio_intf.c rtw_sdio_suspend call we have multiple
> return which can replace by goto exit. As in all the places
> return value is 0.
> 
> Signed-off-by: Saurav Girepunje <saurav.girepunje@google.com>
> ---
>  drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> index a9a9631dd23c..3e566cf97f6e 100644
> --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> @@ -445,14 +445,17 @@ static int rtw_sdio_suspend(struct device *dev)
>  	struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
>  
>  	if (padapter->bDriverStopped)
> -		return 0;
> +		goto exit;
>  
>  	if (pwrpriv->bInSuspend) {
>  		pdbgpriv->dbg_suspend_error_cnt++;
> -		return 0;
> +		goto exit;
>  	}
>  
> -	return rtw_suspend_common(padapter);
> +	rtw_suspend_common(padapter);

Also it's weird that your previous patch made rtw_suspend_common()
return zero unconditionally.  But now we're modifying the only caller to
not check the return.  Just make rtw_suspend_common() void and change
this to:

	rtw_suspend_common(padapter);

	return 0;

regards,
dan carpenter


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

* Re: [PATCH] staging: rtl8723bs: os_dep: remove multiple return
  2021-04-20 11:06 ` Dan Carpenter
@ 2021-04-27 19:45   ` SAURAV GIREPUNJE
  0 siblings, 0 replies; 4+ messages in thread
From: SAURAV GIREPUNJE @ 2021-04-27 19:45 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: gregkh, fabioaiuto83, hello, hdegoede, saurav.girepunje,
	john.oldman, linux-staging, linux-kernel, saurav.girepunje

On Tue, Apr 20, 2021 at 02:06:09PM +0300, Dan Carpenter wrote:
> On Sun, Apr 18, 2021 at 11:02:33PM +0530, Saurav Girepunje wrote:
> > on sdio_intf.c rtw_sdio_suspend call we have multiple
> > return which can replace by goto exit. As in all the places
> > return value is 0.
> > 
> > Signed-off-by: Saurav Girepunje <saurav.girepunje@google.com>
> > ---
> >  drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> > index a9a9631dd23c..3e566cf97f6e 100644
> > --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> > +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> > @@ -445,14 +445,17 @@ static int rtw_sdio_suspend(struct device *dev)
> >  	struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
> >  
> >  	if (padapter->bDriverStopped)
> > -		return 0;
> > +		goto exit;
> >  
> >  	if (pwrpriv->bInSuspend) {
> >  		pdbgpriv->dbg_suspend_error_cnt++;
> > -		return 0;
> > +		goto exit;
> >  	}
> >  
> > -	return rtw_suspend_common(padapter);
> > +	rtw_suspend_common(padapter);
> 
> Also it's weird that your previous patch made rtw_suspend_common()
> return zero unconditionally.  But now we're modifying the only caller to
> not check the return.  Just make rtw_suspend_common() void and change
> this to:
> 
> 	rtw_suspend_common(padapter);
> 
> 	return 0;
> 
> regards,
> dan carpenter
>

Sure, rtw_suspend_common always return 0. It should be void.
I will merge and resend the patch.

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

end of thread, other threads:[~2021-04-27 19:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-18 17:32 [PATCH] staging: rtl8723bs: os_dep: remove multiple return Saurav Girepunje
2021-04-20 11:03 ` Dan Carpenter
2021-04-20 11:06 ` Dan Carpenter
2021-04-27 19:45   ` 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).