Skip to contentSkip to conversation

staging: rtlwifi: Remove return variable.

PATCH Superseded Sanjana Sanikommu 2 participants 6 messages Mar 28, 2019 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: rtlwifi: Remove return variable.

This patch series does the following in phy.c.
1. Remove return variable using ret.cocci
2. Remove unnecessary variable

Sanjana Sanikommu (2):
staging: rtlwifi: Remove return variable
staging: rtlwifi: Remove unused variable.

 drivers/staging/rtlwifi/rtl8822be/phy.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 staging: rtlwifi: Remove return variable

Remove return variable and return "return" value directly. Issue found by Coccinelle using ret.cocci.

---
 drivers/staging/rtlwifi/rtl8822be/phy.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/staging/rtlwifi/rtl8822be/phy.c +4 -10
index 048904d783fc..aed315143cbb 100644
@@ -219,10 +219,8 @@ bool rtl8822be_halmac_cb_init_bb_rf_register(struct rtl_priv *rtlpriv)
 	txpath = RF_MASK_A | RF_MASK_B;
 	rxpath = RF_MASK_A | RF_MASK_B;
 	tx2path = false;
-	ret = rtlpriv->phydm.ops->phydm_trx_mode(rtlpriv, txpath, rxpath,
+	return rtlpriv->phydm.ops->phydm_trx_mode(rtlpriv, txpath, rxpath,
 						 tx2path);
-
-	return ret;
 }
 
 static void _rtl8822be_phy_init_tx_power_by_rate(struct ieee80211_hw *hw)
@@ -1580,11 +1578,9 @@ _rtl8822be_phy_get_txpower_by_rate(struct ieee80211_hw *hw, u8 band, u8 path,
 	else
 		tx_num = RF_1TX;
 
-	tx_pwr_diff = (char)(rtlphy->tx_power_by_rate_offset[band][path][tx_num]
+	return (char)(rtlphy->tx_power_by_rate_offset[band][path][tx_num]
 							    [rate] &
 			     0xff);
-
-	return tx_pwr_diff;
 }
 
 u8 rtl8822be_get_txpower_index(struct ieee80211_hw *hw, u8 path, u8 rate,
@@ -1858,8 +1854,7 @@ static long _rtl8822be_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw,
 		offset = -8;
 		break;
 	}
-	pwrout_dbm = txpwridx / 2 + offset;
-	return pwrout_dbm;
+	return txpwridx / 2 + offset;
 }
 
 void rtl8822be_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
@@ -2218,6 +2213,5 @@ bool rtl8822be_phy_set_rf_power_state(struct ieee80211_hw *hw,
 
 	if (rfpwr_state == ppsc->rfpwr_state)
 		return bresult;
-	bresult = _rtl8822be_phy_set_rf_power_state(hw, rfpwr_state);
-	return bresult;
+	return _rtl8822be_phy_set_rf_power_state(hw, rfpwr_state);
 }
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 staging: rtlwifi: Remove unused variable.

In reply to Sanjana Sanikommu

Remove unused variable. This variable is
created unnecessarily for return type whose
use is removed using ret.cocci.

---
 drivers/staging/rtlwifi/rtl8822be/phy.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/rtlwifi/rtl8822be/phy.c +0 -1
index aed315143cbb..ececfed7b35a 100644
@@ -1840,7 +1840,6 @@ static long _rtl8822be_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw,
 					    u8 txpwridx)
 {
 	long offset;
-	long pwrout_dbm;
 
 	switch (wirelessmode) {
 	case WIRELESS_MODE_B:
Signature · 1 line
2.17.1
maintainer
#3 lore raw

Re: [PATCH 2/2] staging: rtlwifi: Remove unused variable.

Quoted 14 lines · Sanjana Sanikommu

Remove unused variable. This variable is
created unnecessarily for return type whose
use is removed using ret.cocci.

---
 drivers/staging/rtlwifi/rtl8822be/phy.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/rtlwifi/rtl8822be/phy.c +0 -0
index aed315143cbb..ececfed7b35a 100644

drivers/staging/rtlwifi/rtl8822be/phy.c static long _rtl8822be_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw, · line 1843

Quoted 4 lines
drivers/staging/rtlwifi/rtl8822be/phy.c +0 -1
@@ -1840,7 +1840,6 @@ static long _rtl8822be_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw,
 					    u8 txpwridx)
 {
 	long offset;
-	long pwrout_dbm;

Did you just cause this warning to happen with patch 1/2? That's not ok, please put this together with that patch, you can not have any commit break the build, or add new build warnings.

thanks,

greg k-h

#4 lore raw

Re: [PATCH 2/2] staging: rtlwifi: Remove unused variable.

Quoted 17 lines · On Thu, 28 Mar 2019, 21:38 Greg KH, <[email protected]> wrote:

Review

Quoted 10 lines · Sanjana Sanikommu

Remove unused variable. This variable is
created unnecessarily for return type whose
use is removed using ret.cocci.

---
 drivers/staging/rtlwifi/rtl8822be/phy.c | 1 -
 1 file changed, 1 deletion(-)
(quoted diff) +0 -0

b/drivers/staging/rtlwifi/rtl8822be/phy.c

drivers/staging/rtlwifi/rtl8822be/phy.c static long _rtl8822be_phy_txpwr_idx_to_dbm(struct

Quoted 4 lines

index aed315143cbb..ececfed7b35a 100644

drivers/staging/rtlwifi/rtl8822be/phy.c +0 -0
@@ -1840,7 +1840,6 @@ static long _rtl8822be_phy_txpwr_idx_to_dbm(struct

ieee80211_hw *hw,

Quoted 9 lines

drivers/staging/rtlwifi/rtl8822be/phy.c static long _rtl8822be_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw, · line 1843

Quoted 4 lines
drivers/staging/rtlwifi/rtl8822be/phy.c +0 -1
                                          u8 txpwridx)
 {
      long offset;
-     long pwrout_dbm;

Did you just cause this warning to happen with patch 1/2? That's not ok, please put this together with that patch, you can not have any commit break the build, or add new build warnings.

I will put them together in one patch and send as v2
Sanjana

Quoted 5 lines

thanks,

greg k-h

#5 lore raw

PATCH v2 1/1 staging: rtlwifi: Remove return variable.

In reply to Sanjana Sanikommu

Remove return variable and return "return" value directly. Issue found by Coccinelle using ret.cocci.

---
Changes in v2:
Merge 2 patches to one i.e remove unnecessary
variable is merged to [PATCH 1/2].
Remove patch series.

 drivers/staging/rtlwifi/rtl8822be/phy.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/staging/rtlwifi/rtl8822be/phy.c +4 -11
index 048904d783fc..ececfed7b35a 100644
@@ -219,10 +219,8 @@ bool rtl8822be_halmac_cb_init_bb_rf_register(struct rtl_priv *rtlpriv)
 	txpath = RF_MASK_A | RF_MASK_B;
 	rxpath = RF_MASK_A | RF_MASK_B;
 	tx2path = false;
-	ret = rtlpriv->phydm.ops->phydm_trx_mode(rtlpriv, txpath, rxpath,
+	return rtlpriv->phydm.ops->phydm_trx_mode(rtlpriv, txpath, rxpath,
 						 tx2path);
-
-	return ret;
 }
 
 static void _rtl8822be_phy_init_tx_power_by_rate(struct ieee80211_hw *hw)
@@ -1580,11 +1578,9 @@ _rtl8822be_phy_get_txpower_by_rate(struct ieee80211_hw *hw, u8 band, u8 path,
 	else
 		tx_num = RF_1TX;
 
-	tx_pwr_diff = (char)(rtlphy->tx_power_by_rate_offset[band][path][tx_num]
+	return (char)(rtlphy->tx_power_by_rate_offset[band][path][tx_num]
 							    [rate] &
 			     0xff);
-
-	return tx_pwr_diff;
 }
 
 u8 rtl8822be_get_txpower_index(struct ieee80211_hw *hw, u8 path, u8 rate,
@@ -1844,7 +1840,6 @@ static long _rtl8822be_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw,
 					    u8 txpwridx)
 {
 	long offset;
-	long pwrout_dbm;
 
 	switch (wirelessmode) {
 	case WIRELESS_MODE_B:
@@ -1858,8 +1853,7 @@ static long _rtl8822be_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw,
 		offset = -8;
 		break;
 	}
-	pwrout_dbm = txpwridx / 2 + offset;
-	return pwrout_dbm;
+	return txpwridx / 2 + offset;
 }
 
 void rtl8822be_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
@@ -2218,6 +2212,5 @@ bool rtl8822be_phy_set_rf_power_state(struct ieee80211_hw *hw,
 
 	if (rfpwr_state == ppsc->rfpwr_state)
 		return bresult;
-	bresult = _rtl8822be_phy_set_rf_power_state(hw, rfpwr_state);
-	return bresult;
+	return _rtl8822be_phy_set_rf_power_state(hw, rfpwr_state);
 }
Signature · 1 line
2.17.1