Skip to contentSkip to conversation

staging: rtl8723au : remove goto & return error directly

PATCH NAK Gujulan Elango, Hari Prasath (H.) 4 participants 10 messages May 7, 2015 – May 12, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723au : remove goto & return error directly

Remove the goto and return error directly thereby removing a variable

---
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +2 -5
index b139ed4..a979048 100644
@@ -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,
Signature · 1 line
1.9.1
#1 lore raw
Quoted 6 lines · Hari Prasath (H.)

Remove the goto and return error directly thereby removing a variable

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

Quoted 30 lines
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +2 -5
index b139ed4..a979048 100644
@@ -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,
#2 lore raw
Quoted 9 lines · Jes Sorensen
Quoted 6 lines · Hari Prasath (H.)

Remove the goto and return error directly thereby removing a variable

---
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

NACK!

SHOUTING!

Quoted 3 lines

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

#3 lore raw
Quoted 14 lines · Dan Carpenter
Quoted 9 lines · Jes Sorensen
Quoted 6 lines · Hari Prasath (H.)

Remove the goto and return error directly thereby removing a variable

---
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

NACK!

SHOUTING!

Quoted 1 line
Quoted 9 lines
Quoted 2 lines

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.

#4 lore raw
Quoted 21 lines · Hari Prasath (H.)
Quoted 20 lines · Dan Carpenter
Quoted 9 lines · Jes Sorensen
Quoted 6 lines · Hari Prasath (H.)

Remove the goto and return error directly thereby removing a variable

---
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

NACK!

SHOUTING!

Quoted 3 lines

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.

Quoted 8 lines
Quoted 3 lines

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

#5 lore raw
Quoted 31 lines · Jes Sorensen
Quoted 21 lines · Hari Prasath (H.)
Quoted 20 lines · Dan Carpenter
Quoted 9 lines · Jes Sorensen
Quoted 6 lines · Hari Prasath (H.)

Remove the goto and return error directly thereby removing a variable

---
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

NACK!

SHOUTING!

Quoted 3 lines

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.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 7 lines

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

#6 lore raw
Quoted 38 lines · Hari Prasath (H.)
Quoted 37 lines · Jes Sorensen
Quoted 21 lines · Hari Prasath (H.)
Quoted 20 lines · Dan Carpenter
Quoted 9 lines · Jes Sorensen
Quoted 6 lines · Hari Prasath (H.)

Remove the goto and return error directly thereby removing a variable

---
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

NACK!

SHOUTING!

Quoted 3 lines

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.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 8 lines
Quoted 1 line

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

#7 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter
Quoted 3 lines · Jes Sorensen
Quoted 2 lines · Hari Prasath (H.)

Remove the goto and return error directly thereby removing a variable

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
---
 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

Quoted 7 lines
Quoted 4 lines

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

#8 lore raw
Quoted 5 lines · Jes Sorensen
Quoted 3 lines · Dan Carpenter
Quoted 1 line · Jes Sorensen

NACK!

SHOUTING!

It's normal to write NACK in upper case

Not with an exclamation point.

#9 lore raw
Quoted 8 lines · Joe Perches
Quoted 5 lines · Jes Sorensen
Quoted 3 lines · Dan Carpenter
Quoted 1 line · Jes Sorensen

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!