Skip to contentSkip to conversation

Remove unnecessary functions and return

PATCH In review Nishka Dasgupta 3 participants 9 messages Mar 22, 2019 – Mar 24, 2019 Staging

lore
Share & tools
lore
#0 lore raw

v2 cover Remove unnecessary functions and return

Remove unnecessary functions and return variables in the driver rtl8723bs. Issues found while using ret.cocci and Coccinelle.

Nishka Dasgupta (5):
staging; rtl8723bs: Remove unnecessary function rtw_init_mlme_priv()
staging: rtl8723bs: core: Change datatype from sint to int
staging: rtl8723bs: core: Remove parentheses
staging: rtl8723bs: Remove function rtw_alloc_network()
staging: rtl8723bs: core: Remove return variable in rtw_io.c

 drivers/staging/rtl8723bs/core/rtw_cmd.c     |  2 +-
 drivers/staging/rtl8723bs/core/rtw_io.c      |  3 +-
 drivers/staging/rtl8723bs/core/rtw_mlme.c    | 39 ++++++--------------
 drivers/staging/rtl8723bs/include/rtw_mlme.h |  4 +-
 4 files changed, 14 insertions(+), 34 deletions(-)
Signature · 6 lines
Changes in v2:
- Drop Patches 1 and 2 from series as they have already been accepted.
- Remove functions that now consist of only one return statement.
- Remove trailing whitespace.
- Change function datatypes and names.
2.19.1
#1 lore raw

PATCH v2 1/5 staging; rtl8723bs: Remove unnecessary function rtw_init_mlme_priv()

Remove function rtw_init_mlme_priv() as all it does is call _rtw_init_mlme_priv().
Change the name of _rtw_init_mlme_priv() to rtw_init_mlme_priv() and its return type to int.
Remove references to _rtw_init_mlme_priv() from the corresponding header file.
Suggestion to delete return variable from rtw_init_mlme_priv() put forward by Coccinelle using ret.cocci.

---
Changes in v2:
- Remove rtw_init_mlme_priv entirely, now that it has been whittled down to a single return statement.
- Make the other changes listed above.

 drivers/staging/rtl8723bs/core/rtw_mlme.c    | 13 ++-----------
 drivers/staging/rtl8723bs/include/rtw_mlme.h |  2 --
 2 files changed, 2 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +2 -11
index 79adc6f1e53a..8f1defdd47f0 100644
@@ -13,13 +13,13 @@
 
 extern u8 rtw_do_join(struct adapter *padapter);
 
-sint	_rtw_init_mlme_priv(struct adapter *padapter)
+int	rtw_init_mlme_priv(struct adapter *padapter)
 {
 	sint	i;
 	u8 *pbuf;
 	struct wlan_network	*pnetwork;
 	struct mlme_priv 	*pmlmepriv = &padapter->mlmepriv;
-	sint	res = _SUCCESS;
+	int	res = _SUCCESS;
 
 	pmlmepriv->nic_hdl = (u8 *)padapter;
 
@@ -350,15 +350,6 @@ u8 *rtw_get_beacon_interval_from_ie(u8 *ie)
 	return (ie + 8);
 }
 
-
-int	rtw_init_mlme_priv(struct adapter *padapter)/* struct	mlme_priv *pmlmepriv) */
-{
-	int	res;
-
-	res = _rtw_init_mlme_priv(padapter);/*  (pmlmepriv); */
-	return res;
-}
-
 void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 {
 	RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv\n"));
drivers/staging/rtl8723bs/include/rtw_mlme.h +0 -2
index ed59f16c26c4..82f378c6789e 100644
@@ -592,8 +592,6 @@ void rtw_clear_scan_deny(struct adapter *adapter);
 void rtw_set_scan_deny_timer_hdl(struct adapter *adapter);
 void rtw_set_scan_deny(struct adapter *adapter, u32 ms);
 
-extern int _rtw_init_mlme_priv(struct adapter *padapter);
-
 void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
 
 extern void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
Signature · 1 line
2.19.1
#2 lore raw

PATCH v2 2/5 staging: rtl8723bs: core: Change datatype from sint to int

In reply to Nishka Dasgupta

Change datatype of local variable from sint to int.

---
Changes in v2:
- Add this patch to the patch series.

 drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +1 -1
index 8f1defdd47f0..599958819d2d 100644
@@ -15,7 +15,7 @@ extern u8 rtw_do_join(struct adapter *padapter);
 
 int	rtw_init_mlme_priv(struct adapter *padapter)
 {
-	sint	i;
+	int	i;
 	u8 *pbuf;
 	struct wlan_network	*pnetwork;
 	struct mlme_priv 	*pmlmepriv = &padapter->mlmepriv;
Signature · 1 line
2.19.1
#3 lore raw

PATCH v2 3/5 staging: rtl8723bs: core: Remove parentheses

In reply to Nishka Dasgupta

Remove unnecessary parentheses around variables. Issue found with Checkpatch.

---
Changes in v2:
- Add this patch to the series.

 drivers/staging/rtl8723bs/core/rtw_mlme.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +5 -5
index 599958819d2d..8b3a095f0c4c 100644
@@ -29,9 +29,9 @@ int	rtw_init_mlme_priv(struct adapter *padapter)
 	pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown;
 	pmlmepriv->scan_mode = SCAN_ACTIVE;/*  1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */
 
-	spin_lock_init(&(pmlmepriv->lock));
-	_rtw_init_queue(&(pmlmepriv->free_bss_pool));
-	_rtw_init_queue(&(pmlmepriv->scanned_queue));
+	spin_lock_init(&pmlmepriv->lock);
+	_rtw_init_queue(&pmlmepriv->free_bss_pool);
+	_rtw_init_queue(&pmlmepriv->scanned_queue);
 
 	set_scanned_network_val(pmlmepriv, 0);
 
@@ -48,9 +48,9 @@ int	rtw_init_mlme_priv(struct adapter *padapter)
 	pnetwork = (struct wlan_network *)pbuf;
 
 	for (i = 0; i < MAX_BSS_CNT; i++) {
-		INIT_LIST_HEAD(&(pnetwork->list));
+		INIT_LIST_HEAD(&pnetwork->list);
 
-		list_add_tail(&(pnetwork->list), &(pmlmepriv->free_bss_pool.queue));
+		list_add_tail(&pnetwork->list, &pmlmepriv->free_bss_pool.queue);
 
 		pnetwork++;
 	}
Signature · 1 line
2.19.1
#4 lore raw

PATCH v2 4/5 staging: rtl8723bs: Remove function rtw_alloc_network()

In reply to Nishka Dasgupta

Remove function rtw_alloc_network() as all it does is call _rtw_alloc_network().
Rename _rtw_alloc_network() to rtw_alloc_network(). Change references to _rtw_alloc_network() to refer to rtw_alloc_network().
Issue first noticed while using Coccinelle and ret.cocci.

---
Changes in v2:
- Delete rtw_alloc_network() entirely, now that it was only a return statement.
- Make changes listed above.

 drivers/staging/rtl8723bs/core/rtw_cmd.c     |  2 +-
 drivers/staging/rtl8723bs/core/rtw_mlme.c    | 14 +++-----------
 drivers/staging/rtl8723bs/include/rtw_mlme.h |  2 +-
 3 files changed, 5 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -1
index 04c6927dab8b..ecaa769f12e6 100644
@@ -2100,7 +2100,7 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
 
 		rtw_indicate_connect(padapter);
 	} else {
-		pwlan = _rtw_alloc_network(pmlmepriv);
+		pwlan = rtw_alloc_network(pmlmepriv);
 		spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
 		if (pwlan == NULL) {
 			pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue);
drivers/staging/rtl8723bs/core/rtw_mlme.c +3 -11
index 8b3a095f0c4c..552df9e3cd14 100644
@@ -143,7 +143,7 @@ struct	wlan_network *_rtw_dequeue_network(struct __queue *queue)
 }
 */
 
-struct	wlan_network *_rtw_alloc_network(struct	mlme_priv *pmlmepriv)/* _queue *free_queue) */
+struct	wlan_network *rtw_alloc_network(struct	mlme_priv *pmlmepriv)
 {
 	struct	wlan_network	*pnetwork;
 	struct __queue *free_queue = &pmlmepriv->free_bss_pool;
@@ -161,7 +161,8 @@ struct	wlan_network *_rtw_alloc_network(struct	mlme_priv *pmlmepriv)/* _queue *f
 
 	list_del_init(&pnetwork->list);
 
-	RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("_rtw_alloc_network: ptr =%p\n", plist));
+	RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
+		 ("rtw_alloc_network: ptr =%p\n", plist));
 	pnetwork->network_type = 0;
 	pnetwork->fixed = false;
 	pnetwork->last_scanned = jiffies;
@@ -366,15 +367,6 @@ static struct	wlan_network *rtw_dequeue_network(struct __queue *queue)
 }
 */
 
-struct	wlan_network *rtw_alloc_network(struct	mlme_priv *pmlmepriv);
-struct	wlan_network *rtw_alloc_network(struct	mlme_priv *pmlmepriv)/* _queue	*free_queue) */
-{
-	struct	wlan_network	*pnetwork;
-
-	pnetwork = _rtw_alloc_network(pmlmepriv);
-	return pnetwork;
-}
-
 void rtw_free_network_nolock(struct adapter *padapter, struct wlan_network *pnetwork);
 void rtw_free_network_nolock(struct adapter *padapter, struct wlan_network *pnetwork)
 {
drivers/staging/rtl8723bs/include/rtw_mlme.h +1 -1
index 82f378c6789e..2693b554f414 100644
@@ -598,7 +598,7 @@ extern void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
 
 /* extern struct wlan_network* _rtw_dequeue_network(struct __queue *queue); */
 
-extern struct wlan_network* _rtw_alloc_network(struct mlme_priv *pmlmepriv);
+extern struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv);
 
 
 extern void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall);
Signature · 1 line
2.19.1
#5 lore raw

PATCH v2 5/5 staging: rtl8723bs: core: Remove return variable in rtw_io.c

In reply to Nishka Dasgupta

Remove unnecessary local return variable in rtw_io.c. Issue found with Coccinelle using ret.cocci.

---
Changes in v2:
- Remove trailing whitespace.

 drivers/staging/rtl8723bs/core/rtw_io.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_io.c +1 -2
index d341069097e2..985eaa49ad3c 100644
@@ -45,8 +45,7 @@ u8 _rtw_read8(struct adapter *adapter, u32 addr)
 
 	_read8 = pintfhdl->io_ops._read8;
 
-	r_val = _read8(pintfhdl, addr);
-	return r_val;
+	return _read8(pintfhdl, addr);
 }
 
 u16 _rtw_read16(struct adapter *adapter, u32 addr)
Signature · 1 line
2.19.1
maintainer
#6 lore raw

Re: [PATCH v2 5/5] staging: rtl8723bs: core: Remove return variable in rtw_io.c

Quoted 16 lines · Nishka Dasgupta

Remove unnecessary local return variable in rtw_io.c. Issue found with Coccinelle using ret.cocci.

---
Changes in v2:
- Remove trailing whitespace.

 drivers/staging/rtl8723bs/core/rtw_io.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_io.c +0 -0
index d341069097e2..985eaa49ad3c 100644

drivers/staging/rtl8723bs/core/rtw_io.c u8 _rtw_read8(struct adapter *adapter, u32 addr) · line 48

Quoted 6 lines
drivers/staging/rtl8723bs/core/rtw_io.c +1 -2
@@ -45,8 +45,7 @@ u8 _rtw_read8(struct adapter *adapter, u32 addr)
 
 	_read8 = pintfhdl->io_ops._read8;
 
-	r_val = _read8(pintfhdl, addr);
-	return r_val;
+	return _read8(pintfhdl, addr);

This did not give you a build warning when you applied it? Odd, let me check...

maintainer
#7 lore raw

Re: [PATCH v2 5/5] staging: rtl8723bs: core: Remove return variable in rtw_io.c

Quoted 18 lines · Greg KH
Quoted 17 lines · Nishka Dasgupta

Remove unnecessary local return variable in rtw_io.c. Issue found with Coccinelle using ret.cocci.

---
Changes in v2:
- Remove trailing whitespace.

 drivers/staging/rtl8723bs/core/rtw_io.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_io.c +0 -0
index d341069097e2..985eaa49ad3c 100644
@@ -45,8 +45,7 @@ u8 _rtw_read8(struct adapter *adapter, u32 addr)
 
Quoted 8 lines

drivers/staging/rtl8723bs/core/rtw_io.c u8 _rtw_read8(struct adapter *adapter, u32 addr) · line 48

Quoted 5 lines
drivers/staging/rtl8723bs/core/rtw_io.c +1 -2
 	_read8 = pintfhdl->io_ops._read8;
 
-	r_val = _read8(pintfhdl, addr);
-	return r_val;
+	return _read8(pintfhdl, addr);

This did not give you a build warning when you applied it? Odd, let me check...

Yes, this adds a build warning, so I can not take this patch.

Always test-build your patches.

thanks,

greg k-h

#8 lore raw

Re: [Outreachy kernel] Re: [PATCH v2 5/5] staging: rtl8723bs: core: Remove return variable in rtw_io.c

Quoted 29 lines · Greg KH
Quoted 18 lines · Greg KH
Quoted 17 lines · Nishka Dasgupta

Remove unnecessary local return variable in rtw_io.c. Issue found with Coccinelle using ret.cocci.

---
Changes in v2:
- Remove trailing whitespace.

 drivers/staging/rtl8723bs/core/rtw_io.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_io.c +0 -0
index d341069097e2..985eaa49ad3c 100644
@@ -45,8 +45,7 @@ u8 _rtw_read8(struct adapter *adapter, u32 addr)
 
Quoted 8 lines

drivers/staging/rtl8723bs/core/rtw_io.c u8 _rtw_read8(struct adapter *adapter, u32 addr) · line 48

Quoted 5 lines
drivers/staging/rtl8723bs/core/rtw_io.c +1 -2
    _read8 = pintfhdl->io_ops._read8;
 
-   r_val = _read8(pintfhdl, addr);
-   return r_val;
+   return _read8(pintfhdl, addr);

This did not give you a build warning when you applied it? Odd, let me check...

Quoted 3 lines

Yes, this adds a build warning, so I can not take this patch.

Always test-build your patches.

Sorry about that! I'll take another look at this.
- Nishka

Quoted 10 lines

thanks,

greg k-h

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190324085328.GA21171%40kroah.com.
For more options, visit https://groups.google.com/d/optout.