All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Remove NULL comparisons and return variables
@ 2019-03-21 20:13 Nishka Dasgupta
  2019-03-21 20:13 ` [PATCH 1/4] staging: rtl8723bs: core: Change NULL comparisons to Boolean negation Nishka Dasgupta
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Nishka Dasgupta @ 2019-03-21 20:13 UTC (permalink / raw)
  To: gregkh, outreachy-kernel; +Cc: Nishka Dasgupta

Remove local return variables and change NULL comparisons to Boolean
negation in multiple files in staging/rtl8723bs/core. Issues found with
Coccinelle using ret.cocci and matchnull.cocci.

Nishka Dasgupta (4):
  staging: rtl8723bs: core: Change NULL comparisons to Boolean negation
  staging: rtl8723bs: core: Remove return variables in rtw_mlme_ext.c
  staging: rtl8723bs: core: Remove return variables in rtw_mlme.c
  staging: rtl8723bs: core: Remove return variables in rtw_io.c

 drivers/staging/rtl8723bs/core/rtw_io.c       |  9 ++-------
 drivers/staging/rtl8723bs/core/rtw_mlme.c     | 10 ++--------
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 11 ++++-------
 3 files changed, 8 insertions(+), 22 deletions(-)

-- 
2.19.1



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

* [PATCH 1/4] staging: rtl8723bs: core: Change NULL comparisons to Boolean negation
  2019-03-21 20:13 [PATCH 0/4] Remove NULL comparisons and return variables Nishka Dasgupta
@ 2019-03-21 20:13 ` Nishka Dasgupta
  2019-03-21 20:13 ` [PATCH 2/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme_ext.c Nishka Dasgupta
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Nishka Dasgupta @ 2019-03-21 20:13 UTC (permalink / raw)
  To: gregkh, outreachy-kernel; +Cc: Nishka Dasgupta

Change NULL comparisons to Boolean negations. Issue found with
Coccinelle using matchnull.cocci.

Signed-off-by: Nishka Dasgupta <nishka.dasgupta@yahoo.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index b2813eb3d9d2..c2884c35c460 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -3512,7 +3512,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow
 
 
 	/* da == NULL, assum it's null data for sta to ap*/
-	if (da == NULL)
+	if (!da)
 		da = get_my_bssid(&(pmlmeinfo->network));
 
 	psta = rtw_get_stainfo(&padapter->stapriv, da);
@@ -3578,7 +3578,7 @@ s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da)
 	pmlmeinfo = &pmlmeext->mlmext_info;
 
 	/* da == NULL, assum it's null data for sta to ap*/
-	if (da == NULL)
+	if (!da)
 		da = get_my_bssid(&(pmlmeinfo->network));
 
 	ret = _issue_nulldata(padapter, da, 0, false);
@@ -3675,7 +3675,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int
 	struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
 
 	/* da == NULL, assum it's null data for sta to ap*/
-	if (da == NULL)
+	if (!da)
 		da = get_my_bssid(&(pmlmeinfo->network));
 
 	do {
-- 
2.19.1



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

* [PATCH 2/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme_ext.c
  2019-03-21 20:13 [PATCH 0/4] Remove NULL comparisons and return variables Nishka Dasgupta
  2019-03-21 20:13 ` [PATCH 1/4] staging: rtl8723bs: core: Change NULL comparisons to Boolean negation Nishka Dasgupta
@ 2019-03-21 20:13 ` Nishka Dasgupta
  2019-03-21 20:13 ` [PATCH 3/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme.c Nishka Dasgupta
  2019-03-21 20:13 ` [PATCH 4/4] staging: rtl8723bs: core: Remove return variables in rtw_io.c Nishka Dasgupta
  3 siblings, 0 replies; 7+ messages in thread
From: Nishka Dasgupta @ 2019-03-21 20:13 UTC (permalink / raw)
  To: gregkh, outreachy-kernel; +Cc: Nishka Dasgupta

Remove unnecessary local return variables in rtw_mlme_ext.c. Issue found
with Coccinelle using ret.cocci.

Signed-off-by: Nishka Dasgupta <nishka.dasgupta@yahoo.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index c2884c35c460..d97c1e6d5c01 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -3569,7 +3569,6 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow
  */
 s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da)
 {
-	int ret;
 	struct mlme_ext_priv *pmlmeext;
 	struct mlme_ext_info *pmlmeinfo;
 
@@ -3581,9 +3580,7 @@ s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da)
 	if (!da)
 		da = get_my_bssid(&(pmlmeinfo->network));
 
-	ret = _issue_nulldata(padapter, da, 0, false);
-
-	return ret;
+	return _issue_nulldata(padapter, da, 0, false);
 }
 
 /* when wait_ack is ture, this function shoule be called at process context */
-- 
2.19.1



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

* [PATCH 3/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme.c
  2019-03-21 20:13 [PATCH 0/4] Remove NULL comparisons and return variables Nishka Dasgupta
  2019-03-21 20:13 ` [PATCH 1/4] staging: rtl8723bs: core: Change NULL comparisons to Boolean negation Nishka Dasgupta
  2019-03-21 20:13 ` [PATCH 2/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme_ext.c Nishka Dasgupta
@ 2019-03-21 20:13 ` Nishka Dasgupta
  2019-03-21 20:46   ` [Outreachy kernel] " Julia Lawall
  2019-03-21 20:13 ` [PATCH 4/4] staging: rtl8723bs: core: Remove return variables in rtw_io.c Nishka Dasgupta
  3 siblings, 1 reply; 7+ messages in thread
From: Nishka Dasgupta @ 2019-03-21 20:13 UTC (permalink / raw)
  To: gregkh, outreachy-kernel; +Cc: Nishka Dasgupta

Remove unnecessary local return variables in rtw_mlme.c. Issue found
with Coccinelle using ret.cocci.

Signed-off-by: Nishka Dasgupta <nishka.dasgupta@yahoo.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 79adc6f1e53a..68c2b2f198d8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -353,10 +353,7 @@ u8 *rtw_get_beacon_interval_from_ie(u8 *ie)
 
 int	rtw_init_mlme_priv(struct adapter *padapter)/* struct	mlme_priv *pmlmepriv) */
 {
-	int	res;
-
-	res = _rtw_init_mlme_priv(padapter);/*  (pmlmepriv); */
-	return res;
+	return _rtw_init_mlme_priv(padapter);/*  (pmlmepriv); */
 }
 
 void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
@@ -378,10 +375,7 @@ 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;
+	return _rtw_alloc_network(pmlmepriv);
 }
 
 void rtw_free_network_nolock(struct adapter *padapter, struct wlan_network *pnetwork);
-- 
2.19.1



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

* [PATCH 4/4] staging: rtl8723bs: core: Remove return variables in rtw_io.c
  2019-03-21 20:13 [PATCH 0/4] Remove NULL comparisons and return variables Nishka Dasgupta
                   ` (2 preceding siblings ...)
  2019-03-21 20:13 ` [PATCH 3/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme.c Nishka Dasgupta
@ 2019-03-21 20:13 ` Nishka Dasgupta
  2019-03-22 14:16   ` Greg KH
  3 siblings, 1 reply; 7+ messages in thread
From: Nishka Dasgupta @ 2019-03-21 20:13 UTC (permalink / raw)
  To: gregkh, outreachy-kernel; +Cc: Nishka Dasgupta

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

Signed-off-by: Nishka Dasgupta <nishka.dasgupta@yahoo.com>
---
 drivers/staging/rtl8723bs/core/rtw_io.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index d341069097e2..60347349efd1 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -37,7 +37,6 @@ jackson@realtek.com.tw
 
 u8 _rtw_read8(struct adapter *adapter, u32 addr)
 {
-	u8 r_val;
 	/* struct	io_queue	*pio_queue = (struct io_queue *)adapter->pio_queue; */
 	struct io_priv *pio_priv = &adapter->iopriv;
 	struct	intf_hdl		*pintfhdl = &(pio_priv->intf);
@@ -45,8 +44,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)
@@ -142,13 +140,10 @@ u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
 	u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
 	struct io_priv *pio_priv = &adapter->iopriv;
 	struct	intf_hdl		*pintfhdl = &(pio_priv->intf);
-	u32 ret = _SUCCESS;
 
 	_write_port = pintfhdl->io_ops._write_port;
 
-	ret = _write_port(pintfhdl, addr, cnt, pmem);
-
-	return ret;
+	return _write_port(pintfhdl, addr, cnt, pmem);
 }
 
 int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct adapter *padapter, struct _io_ops *pops))
-- 
2.19.1



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

* Re: [Outreachy kernel] [PATCH 3/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme.c
  2019-03-21 20:13 ` [PATCH 3/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme.c Nishka Dasgupta
@ 2019-03-21 20:46   ` Julia Lawall
  0 siblings, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2019-03-21 20:46 UTC (permalink / raw)
  To: Nishka Dasgupta; +Cc: gregkh, outreachy-kernel



On Fri, 22 Mar 2019, 'Nishka Dasgupta' via outreachy-kernel wrote:

> Remove unnecessary local return variables in rtw_mlme.c. Issue found
> with Coccinelle using ret.cocci.
>
> Signed-off-by: Nishka Dasgupta <nishka.dasgupta@yahoo.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_mlme.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c
> index 79adc6f1e53a..68c2b2f198d8 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
> @@ -353,10 +353,7 @@ u8 *rtw_get_beacon_interval_from_ie(u8 *ie)
>
>  int	rtw_init_mlme_priv(struct adapter *padapter)/* struct	mlme_priv *pmlmepriv) */
>  {
> -	int	res;
> -
> -	res = _rtw_init_mlme_priv(padapter);/*  (pmlmepriv); */
> -	return res;
> +	return _rtw_init_mlme_priv(padapter);/*  (pmlmepriv); */
>  }
>
>  void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
> @@ -378,10 +375,7 @@ 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;
> +	return _rtw_alloc_network(pmlmepriv);

This looks like another instance of what Madhumitha has worked on
recently.  These functions do nothing but call another function that has
the same argument and almost the same name.  You can get rid of these
functions and drop the _ in front of the name of the called function.
There are some sint's floating around that can be changed to int.  and you
can drop the p's at the beginning of all of the pointer-typed variable
names.

Another question is whether the variable pbuf is really needed in the
function _rtw_init_mlme_priv.

julia

>  }
>
>  void rtw_free_network_nolock(struct adapter *padapter, struct wlan_network *pnetwork);
> --
> 2.19.1
>
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190321201359.5948-6-nishka.dasgupta%40yahoo.com.
> For more options, visit https://groups.google.com/d/optout.
>


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

* Re: [PATCH 4/4] staging: rtl8723bs: core: Remove return variables in rtw_io.c
  2019-03-21 20:13 ` [PATCH 4/4] staging: rtl8723bs: core: Remove return variables in rtw_io.c Nishka Dasgupta
@ 2019-03-22 14:16   ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2019-03-22 14:16 UTC (permalink / raw)
  To: Nishka Dasgupta; +Cc: outreachy-kernel

On Fri, Mar 22, 2019 at 01:43:59AM +0530, Nishka Dasgupta wrote:
> Remove unnecessary return variables in rtw_io.c. Issue found with
> Coccinelle using ret.cocci.
> 
> Signed-off-by: Nishka Dasgupta <nishka.dasgupta@yahoo.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_io.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
> index d341069097e2..60347349efd1 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_io.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_io.c
> @@ -37,7 +37,6 @@ jackson@realtek.com.tw
>  
>  u8 _rtw_read8(struct adapter *adapter, u32 addr)
>  {
> -	u8 r_val;
>  	/* struct	io_queue	*pio_queue = (struct io_queue *)adapter->pio_queue; */
>  	struct io_priv *pio_priv = &adapter->iopriv;
>  	struct	intf_hdl		*pintfhdl = &(pio_priv->intf);
> @@ -45,8 +44,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);

One too many spaces there :(

Please fix up and resend.

thanks,

greg k-h


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

end of thread, other threads:[~2019-03-22 14:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21 20:13 [PATCH 0/4] Remove NULL comparisons and return variables Nishka Dasgupta
2019-03-21 20:13 ` [PATCH 1/4] staging: rtl8723bs: core: Change NULL comparisons to Boolean negation Nishka Dasgupta
2019-03-21 20:13 ` [PATCH 2/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme_ext.c Nishka Dasgupta
2019-03-21 20:13 ` [PATCH 3/4] staging: rtl8723bs: core: Remove return variables in rtw_mlme.c Nishka Dasgupta
2019-03-21 20:46   ` [Outreachy kernel] " Julia Lawall
2019-03-21 20:13 ` [PATCH 4/4] staging: rtl8723bs: core: Remove return variables in rtw_io.c Nishka Dasgupta
2019-03-22 14:16   ` Greg KH

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.