* [PATCH] staging: rtl8723bs: Merge assignment with return
@ 2017-09-14 12:04 Harsha Sharma
2017-09-14 12:29 ` [Outreachy kernel] " Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Harsha Sharma @ 2017-09-14 12:04 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, outreachy-kernel, Harsha Sharma
Merge assignment with return statement to directly return the value.
Done using following coccinelle semantic patch
@@
local idexpression ret;
expression e;
@@
-ret =
+return
e;
-return ret;
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index ffbb35a..6a8f805 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -2123,12 +2123,9 @@ static int rtw_wx_set_gen_ie(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- int ret;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
- ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
-
- return ret;
+ return rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
}
static int rtw_wx_set_auth(struct net_device *dev,
@@ -3857,7 +3854,6 @@ static int rtw_hostapd_sta_flush(struct net_device *dev)
{
/* _irqL irqL; */
/* struct list_head *phead, *plist; */
- int ret = 0;
/* struct sta_info *psta = NULL; */
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
/* struct sta_priv *pstapriv = &padapter->stapriv; */
@@ -3866,9 +3862,7 @@ static int rtw_hostapd_sta_flush(struct net_device *dev)
flush_all_cam_entry(padapter); /* clear CAM */
- ret = rtw_sta_flush(padapter);
-
- return ret;
+ return rtw_sta_flush(padapter);
}
@@ -4266,7 +4260,6 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param,
static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len)
{
- int ret = 0;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
@@ -4279,15 +4272,12 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p
return -EINVAL;
}
- ret = rtw_acl_remove_sta(padapter, param->sta_addr);
-
- return ret;
+ return rtw_acl_remove_sta(padapter, param->sta_addr);
}
static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len)
{
- int ret = 0;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
@@ -4300,9 +4290,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para
return -EINVAL;
}
- ret = rtw_acl_add_sta(padapter, param->sta_addr);
-
- return ret;
+ return rtw_acl_add_sta(padapter, param->sta_addr);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Outreachy kernel] [PATCH] staging: rtl8723bs: Merge assignment with return
2017-09-14 12:04 [PATCH] staging: rtl8723bs: Merge assignment with return Harsha Sharma
@ 2017-09-14 12:29 ` Julia Lawall
0 siblings, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2017-09-14 12:29 UTC (permalink / raw)
To: Harsha Sharma; +Cc: gregkh, devel, linux-kernel, outreachy-kernel
On Thu, 14 Sep 2017, Harsha Sharma wrote:
> Merge assignment with return statement to directly return the value.
> Done using following coccinelle semantic patch
>
> @@
> local idexpression ret;
> expression e;
> @@
>
> -ret =
> +return
> e;
> -return ret;
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Many of these examples have the property that ret is assigned to 0 but
that value is never used. You could try using Coccinelle to see whether
that occurs in other cases.
julia
>
> Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
> ---
> drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 20 ++++----------------
> 1 file changed, 4 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> index ffbb35a..6a8f805 100644
> --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> @@ -2123,12 +2123,9 @@ static int rtw_wx_set_gen_ie(struct net_device *dev,
> struct iw_request_info *info,
> union iwreq_data *wrqu, char *extra)
> {
> - int ret;
> struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
>
> - ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
> -
> - return ret;
> + return rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
> }
>
> static int rtw_wx_set_auth(struct net_device *dev,
> @@ -3857,7 +3854,6 @@ static int rtw_hostapd_sta_flush(struct net_device *dev)
> {
> /* _irqL irqL; */
> /* struct list_head *phead, *plist; */
> - int ret = 0;
> /* struct sta_info *psta = NULL; */
> struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
> /* struct sta_priv *pstapriv = &padapter->stapriv; */
> @@ -3866,9 +3862,7 @@ static int rtw_hostapd_sta_flush(struct net_device *dev)
>
> flush_all_cam_entry(padapter); /* clear CAM */
>
> - ret = rtw_sta_flush(padapter);
> -
> - return ret;
> + return rtw_sta_flush(padapter);
>
> }
>
> @@ -4266,7 +4260,6 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param,
>
> static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len)
> {
> - int ret = 0;
> struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
> struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
>
> @@ -4279,15 +4272,12 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p
> return -EINVAL;
> }
>
> - ret = rtw_acl_remove_sta(padapter, param->sta_addr);
> -
> - return ret;
> + return rtw_acl_remove_sta(padapter, param->sta_addr);
>
> }
>
> static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len)
> {
> - int ret = 0;
> struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
> struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
>
> @@ -4300,9 +4290,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para
> return -EINVAL;
> }
>
> - ret = rtw_acl_add_sta(padapter, param->sta_addr);
> -
> - return ret;
> + return rtw_acl_add_sta(padapter, param->sta_addr);
>
> }
>
> --
> 1.9.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/1505390645-4461-1-git-send-email-harshasharmaiitr%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Staging: rtl8723bs: Merge assignment with return
@ 2017-12-10 22:03 Shreeya Patel
0 siblings, 0 replies; 3+ messages in thread
From: Shreeya Patel @ 2017-12-10 22:03 UTC (permalink / raw)
To: gregkh, devel, linux-kernel; +Cc: Shreeya Patel
Merge the assignment and return statements to return the value
directly. Done using the following semantic patch by coccinelle.
@@
local idexpression ret;
expression e;
@@
-ret =
+return
e;
-return ret;
Also, remove the variable declaration and some braces
that became useless after the merge.
Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
---
drivers/staging/rtl8723bs/hal/sdio_ops.c | 53 +++++++++++---------------------
1 file changed, 18 insertions(+), 35 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 9a4c248..93ac083 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -157,23 +157,20 @@ static u32 _cvrt2ftaddr(const u32 addr, u8 *pdeviceId, u16 *poffset)
static u8 sdio_read8(struct intf_hdl *pintfhdl, u32 addr)
{
u32 ftaddr;
- u8 val;
-
ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
- val = sd_read8(pintfhdl, ftaddr, NULL);
- return val;
+
+ return sd_read8(pintfhdl, ftaddr, NULL);
}
static u16 sdio_read16(struct intf_hdl *pintfhdl, u32 addr)
{
u32 ftaddr;
- u16 val;
__le16 le_tmp;
ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
sd_cmd52_read(pintfhdl, ftaddr, 2, (u8 *)&le_tmp);
- val = le16_to_cpu(le_tmp);
- return val;
+
+ return le16_to_cpu(le_tmp);
}
static u32 sdio_read32(struct intf_hdl *pintfhdl, u32 addr)
@@ -201,8 +198,7 @@ static u32 sdio_read32(struct intf_hdl *pintfhdl, u32 addr)
#ifdef SDIO_DEBUG_IO
if (!err) {
#endif
- val = le32_to_cpu(le_tmp);
- return val;
+ return le32_to_cpu(le_tmp);
#ifdef SDIO_DEBUG_IO
}
@@ -254,10 +250,8 @@ static s32 sdio_readN(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pbuf)
((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
(false == bMacPwrCtrlOn) ||
(true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
- ) {
- err = sd_cmd52_read(pintfhdl, ftaddr, cnt, pbuf);
- return err;
- }
+ )
+ return sd_cmd52_read(pintfhdl, ftaddr, cnt, pbuf);
/* 4 bytes alignment */
shift = ftaddr & 0x3;
@@ -295,14 +289,11 @@ static s32 sdio_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
static s32 sdio_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
{
u32 ftaddr;
- s32 err;
__le16 le_tmp;
ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
le_tmp = cpu_to_le16(val);
- err = sd_cmd52_write(pintfhdl, ftaddr, 2, (u8 *)&le_tmp);
-
- return err;
+ return sd_cmd52_write(pintfhdl, ftaddr, 2, (u8 *)&le_tmp);
}
static s32 sdio_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
@@ -328,8 +319,8 @@ static s32 sdio_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
(adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
) {
le_tmp = cpu_to_le32(val);
- err = sd_cmd52_write(pintfhdl, ftaddr, 4, (u8 *)&le_tmp);
- return err;
+
+ return sd_cmd52_write(pintfhdl, ftaddr, 4, (u8 *)&le_tmp);
}
/* 4 bytes alignment */
@@ -363,10 +354,8 @@ static s32 sdio_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pbuf)
((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
(false == bMacPwrCtrlOn) ||
(true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
- ) {
- err = sd_cmd52_write(pintfhdl, ftaddr, cnt, pbuf);
- return err;
- }
+ )
+ return sd_cmd52_write(pintfhdl, ftaddr, cnt, pbuf);
shift = ftaddr & 0x3;
if (shift == 0) {
@@ -588,10 +577,8 @@ static s32 _sdio_local_read(
HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn);
- if (false == bMacPwrCtrlOn) {
- err = _sd_cmd52_read(pintfhdl, addr, cnt, pbuf);
- return err;
- }
+ if (false == bMacPwrCtrlOn)
+ return _sd_cmd52_read(pintfhdl, addr, cnt, pbuf);
n = RND4(cnt);
ptmpbuf = rtw_malloc(n);
@@ -631,10 +618,8 @@ s32 sdio_local_read(
if (
(false == bMacPwrCtrlOn) ||
(true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
- ) {
- err = sd_cmd52_read(pintfhdl, addr, cnt, pbuf);
- return err;
- }
+ )
+ return sd_cmd52_read(pintfhdl, addr, cnt, pbuf);
n = RND4(cnt);
ptmpbuf = rtw_malloc(n);
@@ -679,10 +664,8 @@ s32 sdio_local_write(
if (
(false == bMacPwrCtrlOn) ||
(true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
- ) {
- err = sd_cmd52_write(pintfhdl, addr, cnt, pbuf);
- return err;
- }
+ )
+ return sd_cmd52_write(pintfhdl, addr, cnt, pbuf);
ptmpbuf = rtw_malloc(cnt);
if (!ptmpbuf)
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-10 22:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-14 12:04 [PATCH] staging: rtl8723bs: Merge assignment with return Harsha Sharma
2017-09-14 12:29 ` [Outreachy kernel] " Julia Lawall
-- strict thread matches above, loose matches on Subject: below --
2017-12-10 22:03 [PATCH] Staging: " Shreeya Patel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox