All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723au : remove goto & return error directly
@ 2015-05-07 11:22 Gujulan Elango, Hari Prasath (H.)
  2015-05-07 12:03 ` Jes Sorensen
  0 siblings, 1 reply; 10+ messages in thread
From: Gujulan Elango, Hari Prasath (H.) @ 2015-05-07 11:22 UTC (permalink / raw)
  To: devel, gregkh; +Cc: Larry.Finger, Jes.Sorensen, linux-wireless

Remove the goto and return error directly thereby removing a variable

Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
---
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
index b139ed4..a979048 100644
--- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
@@ -1209,7 +1209,6 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
 	struct rtw_adapter *padapter = wiphy_to_adapter(wiphy);
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct wireless_dev *rtw_wdev = wiphy_to_wdev(wiphy);
-	int ret = 0;
 
 	DBG_8723A("%s(%s): call netdev_open23a\n", __func__, ndev->name);
 
@@ -1238,14 +1237,12 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
 
 	if (cfg80211_infrastructure_mode(padapter, type) != _SUCCESS) {
 		rtw_wdev->iftype = old_type;
-		ret = -EPERM;
-		goto exit;
+		return -EPERM;
 	}
 
 	rtw_setopmode_cmd23a(padapter, type);
 
-exit:
-	return ret;
+	return 0;
 }
 
 void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv,
-- 
1.9.1

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

* Re: [PATCH] staging: rtl8723au : remove goto & return error directly
  2015-05-07 11:22 [PATCH] staging: rtl8723au : remove goto & return error directly Gujulan Elango, Hari Prasath (H.)
@ 2015-05-07 12:03 ` Jes Sorensen
  2015-05-07 12:19   ` Dan Carpenter
  0 siblings, 1 reply; 10+ messages in thread
From: Jes Sorensen @ 2015-05-07 12:03 UTC (permalink / raw)
  To: Gujulan Elango, Hari Prasath (H.)
  Cc: devel, gregkh, Larry.Finger, linux-wireless

"Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
> Remove the goto and return error directly thereby removing a variable
>
> Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
> ---
>  drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)

NACK!

The goto is cleaner and more consistent, rather than hiding a return in
the middle of the code.

Jes

>
> diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
> index b139ed4..a979048 100644
> --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
> +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
> @@ -1209,7 +1209,6 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
>  	struct rtw_adapter *padapter = wiphy_to_adapter(wiphy);
>  	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
>  	struct wireless_dev *rtw_wdev = wiphy_to_wdev(wiphy);
> -	int ret = 0;
>  
>  	DBG_8723A("%s(%s): call netdev_open23a\n", __func__, ndev->name);
>  
> @@ -1238,14 +1237,12 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
>  
>  	if (cfg80211_infrastructure_mode(padapter, type) != _SUCCESS) {
>  		rtw_wdev->iftype = old_type;
> -		ret = -EPERM;
> -		goto exit;
> +		return -EPERM;
>  	}
>  
>  	rtw_setopmode_cmd23a(padapter, type);
>  
> -exit:
> -	return ret;
> +	return 0;
>  }
>  
>  void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv,

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

* Re: [PATCH] staging: rtl8723au : remove goto & return error directly
  2015-05-07 12:03 ` Jes Sorensen
@ 2015-05-07 12:19   ` Dan Carpenter
  2015-05-07 13:49     ` Gujulan Elango, Hari Prasath (H.)
  2015-05-07 14:08     ` Jes Sorensen
  0 siblings, 2 replies; 10+ messages in thread
From: Dan Carpenter @ 2015-05-07 12:19 UTC (permalink / raw)
  To: Jes Sorensen
  Cc: Gujulan Elango, Hari Prasath (H.),
	devel, gregkh, linux-wireless, Larry.Finger

On Thu, May 07, 2015 at 08:03:06AM -0400, Jes Sorensen wrote:
> "Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
> > Remove the goto and return error directly thereby removing a variable
> >
> > Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
> > ---
> >  drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> NACK!

SHOUTING!

> 
> The goto is cleaner and more consistent, rather than hiding a return in
> the middle of the code.

More consistent with what?  There are already returns earlier in the
function.  Do-nothing gotos are pointless and annoying.

regards,
dan carpenter


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

* Re: [PATCH] staging: rtl8723au : remove goto & return error directly
  2015-05-07 12:19   ` Dan Carpenter
@ 2015-05-07 13:49     ` Gujulan Elango, Hari Prasath (H.)
  2015-05-07 14:09       ` Jes Sorensen
  2015-05-07 14:08     ` Jes Sorensen
  1 sibling, 1 reply; 10+ messages in thread
From: Gujulan Elango, Hari Prasath (H.) @ 2015-05-07 13:49 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jes Sorensen, devel, gregkh, linux-wireless, Larry.Finger, Babu,
	Viswanathan (V.)

On Thu, May 07, 2015 at 03:19:34PM +0300, Dan Carpenter wrote:
> On Thu, May 07, 2015 at 08:03:06AM -0400, Jes Sorensen wrote:
> > "Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
> > > Remove the goto and return error directly thereby removing a variable
> > >
> > > Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
> > > ---
> > >  drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
> > >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > NACK!
> 
> SHOUTING!
> 
> > 
> > The goto is cleaner and more consistent, rather than hiding a return in
> > the middle of the code.
> 
> More consistent with what?  There are already returns earlier in the
> function.  Do-nothing gotos are pointless and annoying.
> 
> regards,
> dan carpenter
> 

I sent this patch  because goto & return was mixed up in this function.
There was a return as well as goto used. And i guess goto is not 
encouraged anywhere. In this case especially,I couldn't see any 
significant cleanup being done in the goto label.

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

* Re: [PATCH] staging: rtl8723au : remove goto & return error directly
  2015-05-07 12:19   ` Dan Carpenter
  2015-05-07 13:49     ` Gujulan Elango, Hari Prasath (H.)
@ 2015-05-07 14:08     ` Jes Sorensen
  2015-05-07 14:29       ` Joe Perches
  1 sibling, 1 reply; 10+ messages in thread
From: Jes Sorensen @ 2015-05-07 14:08 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Gujulan Elango, Hari Prasath (H.),
	devel, gregkh, linux-wireless, Larry.Finger

Dan Carpenter <dan.carpenter@oracle.com> writes:
> On Thu, May 07, 2015 at 08:03:06AM -0400, Jes Sorensen wrote:
>> "Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
>> > Remove the goto and return error directly thereby removing a variable
>> >
>> > Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
>> > ---
>> >  drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
>> >  1 file changed, 2 insertions(+), 5 deletions(-)
>> 
>> NACK!
>
> SHOUTING!

It's normal to write NACK in upper case
>
>> 
>> The goto is cleaner and more consistent, rather than hiding a return in
>> the middle of the code.
>
> More consistent with what?  There are already returns earlier in the
> function.  Do-nothing gotos are pointless and annoying.

That is *your* preference!

Having returns scattered randomly throughout the code is annoying and
hard to catch when reading the code!

This case is *not* a bug, so it comes down to personal preference of the
maintainer. For code you maintain, feel free to do as you like, I will
*not* never bother you for this kind of preference issues, I will tell
you if I spot an actual bug.

This is one of the problems with checkpatch style tools, they have
become harassment tools, for some people to impose their personal
preferences onto others.

It would be so much more valuable if they just focused on real bugs!

Jes

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

* Re: [PATCH] staging: rtl8723au : remove goto & return error directly
  2015-05-07 13:49     ` Gujulan Elango, Hari Prasath (H.)
@ 2015-05-07 14:09       ` Jes Sorensen
  2015-05-12 10:37         ` Gujulan Elango, Hari Prasath (H.)
  0 siblings, 1 reply; 10+ messages in thread
From: Jes Sorensen @ 2015-05-07 14:09 UTC (permalink / raw)
  To: Gujulan Elango, Hari Prasath (H.)
  Cc: Dan Carpenter, devel, gregkh, linux-wireless, Larry.Finger, Babu,
	Viswanathan (V.)

"Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
> On Thu, May 07, 2015 at 03:19:34PM +0300, Dan Carpenter wrote:
>> On Thu, May 07, 2015 at 08:03:06AM -0400, Jes Sorensen wrote:
>> > "Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
>> > > Remove the goto and return error directly thereby removing a variable
>> > >
>> > > Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
>> > > ---
>> > >  drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
>> > >  1 file changed, 2 insertions(+), 5 deletions(-)
>> > 
>> > NACK!
>> 
>> SHOUTING!
>> 
>> > 
>> > The goto is cleaner and more consistent, rather than hiding a return in
>> > the middle of the code.
>> 
>> More consistent with what?  There are already returns earlier in the
>> function.  Do-nothing gotos are pointless and annoying.
>> 
>> regards,
>> dan carpenter
>> 
>
> I sent this patch  because goto & return was mixed up in this function.
> There was a return as well as goto used. And i guess goto is not 
> encouraged anywhere. In this case especially,I couldn't see any 
> significant cleanup being done in the goto label.

I will accept a patch to remove the returns in the middle of the
function, if you wish to submit that.

A return at the very beginning of a function is OK, but in the middle of
a larger function they make it harder to catch when code exists.

Jes

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

* Re: [PATCH] staging: rtl8723au : remove goto & return error directly
  2015-05-07 14:08     ` Jes Sorensen
@ 2015-05-07 14:29       ` Joe Perches
  2015-05-07 14:44         ` Jes Sorensen
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2015-05-07 14:29 UTC (permalink / raw)
  To: Jes Sorensen
  Cc: Dan Carpenter, Gujulan Elango, Hari Prasath (H.),
	devel, gregkh, linux-wireless, Larry.Finger

On Thu, 2015-05-07 at 10:08 -0400, Jes Sorensen wrote:
> Dan Carpenter <dan.carpenter@oracle.com> writes:
> > On Thu, May 07, 2015 at 08:03:06AM -0400, Jes Sorensen wrote:
> >> NACK!
> > SHOUTING!
> It's normal to write NACK in upper case

Not with an exclamation point.



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

* Re: [PATCH] staging: rtl8723au : remove goto & return error directly
  2015-05-07 14:29       ` Joe Perches
@ 2015-05-07 14:44         ` Jes Sorensen
  0 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2015-05-07 14:44 UTC (permalink / raw)
  To: Joe Perches
  Cc: Dan Carpenter, Gujulan Elango, Hari Prasath (H.),
	devel, gregkh, linux-wireless, Larry.Finger

Joe Perches <joe@perches.com> writes:
> On Thu, 2015-05-07 at 10:08 -0400, Jes Sorensen wrote:
>> Dan Carpenter <dan.carpenter@oracle.com> writes:
>> > On Thu, May 07, 2015 at 08:03:06AM -0400, Jes Sorensen wrote:
>> >> NACK!
>> > SHOUTING!
>> It's normal to write NACK in upper case
>
> Not with an exclamation point.

I would add a <blink> tag if ascii email allowed that!

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

* Re: [PATCH] staging: rtl8723au : remove goto & return error directly
  2015-05-07 14:09       ` Jes Sorensen
@ 2015-05-12 10:37         ` Gujulan Elango, Hari Prasath (H.)
  2015-05-12 11:16           ` Jes Sorensen
  0 siblings, 1 reply; 10+ messages in thread
From: Gujulan Elango, Hari Prasath (H.) @ 2015-05-12 10:37 UTC (permalink / raw)
  To: Jes Sorensen
  Cc: Dan Carpenter, devel, gregkh, linux-wireless, Larry.Finger, Babu,
	Viswanathan (V.)

On Thu, May 07, 2015 at 10:09:59AM -0400, Jes Sorensen wrote:
> "Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
> > On Thu, May 07, 2015 at 03:19:34PM +0300, Dan Carpenter wrote:
> >> On Thu, May 07, 2015 at 08:03:06AM -0400, Jes Sorensen wrote:
> >> > "Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
> >> > > Remove the goto and return error directly thereby removing a variable
> >> > >
> >> > > Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
> >> > > ---
> >> > >  drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
> >> > >  1 file changed, 2 insertions(+), 5 deletions(-)
> >> > 
> >> > NACK!
> >> 
> >> SHOUTING!
> >> 
> >> > 
> >> > The goto is cleaner and more consistent, rather than hiding a return in
> >> > the middle of the code.
> >> 
> >> More consistent with what?  There are already returns earlier in the
> >> function.  Do-nothing gotos are pointless and annoying.
> >> 
> >> regards,
> >> dan carpenter
> >> 
> >
> > I sent this patch  because goto & return was mixed up in this function.
> > There was a return as well as goto used. And i guess goto is not 
> > encouraged anywhere. In this case especially,I couldn't see any 
> > significant cleanup being done in the goto label.
> 
> I will accept a patch to remove the returns in the middle of the
> function, if you wish to submit that.
> 
> A return at the very beginning of a function is OK, but in the middle of
> a larger function they make it harder to catch when code exists.
> 
> Jes

Is this accepted as it is or should I send v2 with the goto retained but
the return in the middle of the function also converted to goto for
consistency.I agree that goto's are used at many places in the kernel
but this is really a small function where it doesn't seem to help
much.Also there is no signficant cleanup being done in the definition of
the label.

regards
Hari

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

* Re: [PATCH] staging: rtl8723au : remove goto & return error directly
  2015-05-12 10:37         ` Gujulan Elango, Hari Prasath (H.)
@ 2015-05-12 11:16           ` Jes Sorensen
  0 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2015-05-12 11:16 UTC (permalink / raw)
  To: Gujulan Elango, Hari Prasath (H.)
  Cc: Dan Carpenter, devel, gregkh, linux-wireless, Larry.Finger, Babu,
	Viswanathan (V.)

"Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
> On Thu, May 07, 2015 at 10:09:59AM -0400, Jes Sorensen wrote:
>> "Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
>> > On Thu, May 07, 2015 at 03:19:34PM +0300, Dan Carpenter wrote:
>> >> On Thu, May 07, 2015 at 08:03:06AM -0400, Jes Sorensen wrote:
>> >> > "Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com> writes:
>> >> > > Remove the goto and return error directly thereby removing a variable
>> >> > >
>> >> > > Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
>> >> > > ---
>> >> > >  drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
>> >> > >  1 file changed, 2 insertions(+), 5 deletions(-)
>> >> > 
>> >> > NACK!
>> >> 
>> >> SHOUTING!
>> >> 
>> >> > 
>> >> > The goto is cleaner and more consistent, rather than hiding a return in
>> >> > the middle of the code.
>> >> 
>> >> More consistent with what?  There are already returns earlier in the
>> >> function.  Do-nothing gotos are pointless and annoying.
>> >> 
>> >> regards,
>> >> dan carpenter
>> >> 
>> >
>> > I sent this patch  because goto & return was mixed up in this function.
>> > There was a return as well as goto used. And i guess goto is not 
>> > encouraged anywhere. In this case especially,I couldn't see any 
>> > significant cleanup being done in the goto label.
>> 
>> I will accept a patch to remove the returns in the middle of the
>> function, if you wish to submit that.
>> 
>> A return at the very beginning of a function is OK, but in the middle of
>> a larger function they make it harder to catch when code exists.
>> 
>> Jes
>
> Is this accepted as it is or should I send v2 with the goto retained but
> the return in the middle of the function also converted to goto for
> consistency.I agree that goto's are used at many places in the kernel
> but this is really a small function where it doesn't seem to help
> much.Also there is no signficant cleanup being done in the definition of
> the label.

As I stated previously, this is not accepted.

Jes

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

end of thread, other threads:[~2015-05-12 11:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-07 11:22 [PATCH] staging: rtl8723au : remove goto & return error directly Gujulan Elango, Hari Prasath (H.)
2015-05-07 12:03 ` Jes Sorensen
2015-05-07 12:19   ` Dan Carpenter
2015-05-07 13:49     ` Gujulan Elango, Hari Prasath (H.)
2015-05-07 14:09       ` Jes Sorensen
2015-05-12 10:37         ` Gujulan Elango, Hari Prasath (H.)
2015-05-12 11:16           ` Jes Sorensen
2015-05-07 14:08     ` Jes Sorensen
2015-05-07 14:29       ` Joe Perches
2015-05-07 14:44         ` Jes Sorensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.