Skip to contentSkip to conversation

wireless: Remove unneeded variable

PATCH In review zhong jiang 2 participants 8 messages Sep 12, 2019 – Sep 16, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover wireless: Remove unneeded variable

With the help of Coccinelle, I find some place to use redundant variable to store the return value, It is unnecessary. Just remove it and make the funtion to be void.

zhong jiang (3):
brcmsmac: Remove unneeded variable and make function to be void
wlegacy: Remove unneeded variable and make function to be void
libertas: Remove unneeded variable and make function to be void

 drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 5 +----
 drivers/net/wireless/intel/iwlegacy/4965-mac.c          | 8 ++------
 drivers/net/wireless/marvell/libertas/cmd.h             | 2 +-
 drivers/net/wireless/marvell/libertas/cmdresp.c         | 5 +----
 4 files changed, 5 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.12.4
#1 lore raw

PATCH 1/3 brcmsmac: Remove unneeded variable and make function to be void

brcms_c_set_mac do not need return value to cope with different cases. And change functon return type to void.

---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +1 -4
index 080e829..ddc4d47 100644
@@ -3776,17 +3776,14 @@ static void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc)
  * Write this BSS config's MAC address to core.
  * Updates RXE match engine.
  */
-static int brcms_c_set_mac(struct brcms_bss_cfg *bsscfg)
+static void brcms_c_set_mac(struct brcms_bss_cfg *bsscfg)
 {
-	int err = 0;
 	struct brcms_c_info *wlc = bsscfg->wlc;
 
 	/* enter the MAC addr into the RXE match registers */
 	brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr);
 
 	brcms_c_ampdu_macaddr_upd(wlc);
-
-	return err;
 }
 
 /* Write the BSS config's BSSID address to core (set_bssid in d11procs.tcl).
Signature · 1 line
1.7.12.4
#2 lore raw

Re: [PATCH 1/3] brcmsmac: Remove unneeded variable and make function to be void

Quoted 4 lines · zhong jiang

brcms_c_set_mac do not need return value to cope with different cases. And change functon return type to void.

I just don't see the benefit from changing the function to return void. And if we ever add error handling to the function we need to change it back to return int again, which is extra work.

Patch set to Rejected.

Signature · 3 lines
https://patchwork.kernel.org/patch/11143403/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#3 lore raw

PATCH 2/3 wlegacy: Remove unneeded variable and make function to be void

In reply to zhong jiang

il4965_set_tkip_dynamic_key_info do not need return value to cope with different ases. And change functon return type to void.

---
 drivers/net/wireless/intel/iwlegacy/4965-mac.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/wireless/intel/iwlegacy/4965-mac.c +2 -6
index ffb705b..a7bbfe2 100644
@@ -3326,12 +3326,11 @@ struct il_mod_params il4965_mod_params = {
 	return il_send_add_sta(il, &sta_cmd, CMD_SYNC);
 }
 
-static int
+static void
 il4965_set_tkip_dynamic_key_info(struct il_priv *il,
 				 struct ieee80211_key_conf *keyconf, u8 sta_id)
 {
 	unsigned long flags;
-	int ret = 0;
 	__le16 key_flags = 0;
 
 	key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
@@ -3367,8 +3366,6 @@ struct il_mod_params il4965_mod_params = {
 	memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16);
 
 	spin_unlock_irqrestore(&il->sta_lock, flags);
-
-	return ret;
 }
 
 void
@@ -3483,8 +3480,7 @@ struct il_mod_params il4965_mod_params = {
 		    il4965_set_ccmp_dynamic_key_info(il, keyconf, sta_id);
 		break;
 	case WLAN_CIPHER_SUITE_TKIP:
-		ret =
-		    il4965_set_tkip_dynamic_key_info(il, keyconf, sta_id);
+		il4965_set_tkip_dynamic_key_info(il, keyconf, sta_id);
 		break;
 	case WLAN_CIPHER_SUITE_WEP40:
 	case WLAN_CIPHER_SUITE_WEP104:
Signature · 1 line
1.7.12.4
#4 lore raw

Re: [PATCH 2/3] wlegacy: Remove unneeded variable and make function to be void

Quoted 36 lines · zhong jiang

il4965_set_tkip_dynamic_key_info do not need return value to cope with different ases. And change functon return type to void.

---
 drivers/net/wireless/intel/iwlegacy/4965-mac.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/wireless/intel/iwlegacy/4965-mac.c +1 -4
index ffb705b..a7bbfe2 100644
@@ -3326,12 +3326,11 @@ struct il_mod_params il4965_mod_params = {
 	return il_send_add_sta(il, &sta_cmd, CMD_SYNC);
 }
 
-static int
+static void
 il4965_set_tkip_dynamic_key_info(struct il_priv *il,
 				 struct ieee80211_key_conf *keyconf, u8 sta_id)
 {
 	unsigned long flags;
-	int ret = 0;
 	__le16 key_flags = 0;
 
 	key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
@@ -3367,8 +3366,6 @@ struct il_mod_params il4965_mod_params = {
 	memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16);
 
 	spin_unlock_irqrestore(&il->sta_lock, flags);
-
-	return ret;
 }
 
 void

drivers/net/wireless/intel/iwlegacy/4965-mac.c struct il_mod_params il4965_mod_params = { · line 3486

Quoted 9 lines
drivers/net/wireless/intel/iwlegacy/4965-mac.c +1 -2
@@ -3483,8 +3480,7 @@ struct il_mod_params il4965_mod_params = {
 		    il4965_set_ccmp_dynamic_key_info(il, keyconf, sta_id);
 		break;
 	case WLAN_CIPHER_SUITE_TKIP:
-		ret =
-		    il4965_set_tkip_dynamic_key_info(il, keyconf, sta_id);
+		il4965_set_tkip_dynamic_key_info(il, keyconf, sta_id);
 		break;
 	case WLAN_CIPHER_SUITE_WEP40:
 	case WLAN_CIPHER_SUITE_WEP104:

To me this looks inconsistent with the rest of the cases in the switch statement. And won't we then return the ret variable uninitalised?

Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#5 lore raw

Re: [PATCH 2/3] wlegacy: Remove unneeded variable and make function to be void

Quoted 36 lines · Kalle Valo
Quoted 34 lines · zhong jiang

il4965_set_tkip_dynamic_key_info do not need return value to cope with different ases. And change functon return type to void.

---
 drivers/net/wireless/intel/iwlegacy/4965-mac.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/wireless/intel/iwlegacy/4965-mac.c +1 -4
index ffb705b..a7bbfe2 100644
@@ -3326,12 +3326,11 @@ struct il_mod_params il4965_mod_params = {
 	return il_send_add_sta(il, &sta_cmd, CMD_SYNC);
 }
 
-static int
+static void
 il4965_set_tkip_dynamic_key_info(struct il_priv *il,
 				 struct ieee80211_key_conf *keyconf, u8 sta_id)
 {
 	unsigned long flags;
-	int ret = 0;
 	__le16 key_flags = 0;
 
 	key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
@@ -3367,8 +3366,6 @@ struct il_mod_params il4965_mod_params = {
 	memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16);
 
 	spin_unlock_irqrestore(&il->sta_lock, flags);
-
-	return ret;
 }
 
Quoted 13 lines

drivers/net/wireless/intel/iwlegacy/4965-mac.c struct il_mod_params il4965_mod_params = { · line 3486

Quoted 11 lines
drivers/net/wireless/intel/iwlegacy/4965-mac.c +1 -2
 void
@@ -3483,8 +3480,7 @@ struct il_mod_params il4965_mod_params = {
 		    il4965_set_ccmp_dynamic_key_info(il, keyconf, sta_id);
 		break;
 	case WLAN_CIPHER_SUITE_TKIP:
-		ret =
-		    il4965_set_tkip_dynamic_key_info(il, keyconf, sta_id);
+		il4965_set_tkip_dynamic_key_info(il, keyconf, sta_id);
 		break;
 	case WLAN_CIPHER_SUITE_WEP40:
 	case WLAN_CIPHER_SUITE_WEP104:

To me this looks inconsistent with the rest of the cases in the switch statement. And won't we then return the ret variable uninitalised?

Yep, I miss that. please ignore the patch. Thanks,

Sincerely,
zhong jiang

#6 lore raw

PATCH 3/3 libertas: Remove unneeded variable and make function to be void

In reply to zhong jiang

lbs_process_event do not need return value to cope with different cases. And change functon return type to void.

---
 drivers/net/wireless/marvell/libertas/cmd.h     | 2 +-
 drivers/net/wireless/marvell/libertas/cmdresp.c | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/marvell/libertas/cmd.h +1 -1
index 8087856..3c19307 100644
@@ -76,7 +76,7 @@ void lbs_mac_event_disconnected(struct lbs_private *priv,
 
 /* Events */
 
-int lbs_process_event(struct lbs_private *priv, u32 event);
+void lbs_process_event(struct lbs_private *priv, u32 event);
 
 
 /* Actual commands */
drivers/net/wireless/marvell/libertas/cmdresp.c +1 -4
index b73d083..cb515c5 100644
@@ -220,9 +220,8 @@ int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
 	return ret;
 }
 
-int lbs_process_event(struct lbs_private *priv, u32 event)
+void lbs_process_event(struct lbs_private *priv, u32 event)
 {
-	int ret = 0;
 	struct cmd_header cmd;
 
 	switch (event) {
@@ -351,6 +350,4 @@ int lbs_process_event(struct lbs_private *priv, u32 event)
 		netdev_alert(priv->dev, "EVENT: unknown event id %d\n", event);
 		break;
 	}
-
-	return ret;
 }
Signature · 1 line
1.7.12.4
#7 lore raw

Re: [PATCH 3/3] libertas: Remove unneeded variable and make function to be void

Quoted 4 lines · zhong jiang

lbs_process_event do not need return value to cope with different cases. And change functon return type to void.

Same here, I just don't see the benefit.

Patch set to Rejected.

Signature · 3 lines
https://patchwork.kernel.org/patch/11143397/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches