Skip to contentSkip to conversation

staging: wilc1000: host_interface.c: Modify return statement.

PATCH In review Sanjana Sanikommu 2 participants 3 messages Mar 28, 2019 – Mar 29, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: wilc1000: host_interface.c: Modify return statement.

Challenge suggested by coccinelle.
Remove return variable and directly return the value Issue found using ret.cocci

---
 drivers/staging/wilc1000/host_interface.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)
drivers/staging/wilc1000/host_interface.c +5 -18
index 4dd9a20f6a0b..a10c31bce07f 100644
@@ -1358,17 +1358,14 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
 int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid)
 {
 	struct wid wid;
-	int result;
 
 	wid.id = WID_PMKID_INFO;
 	wid.type = WID_STR;
 	wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1;
 	wid.val = (u8 *)pmkid;
 
-	result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+	return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
 				      wilc_get_vif_idx(vif));
-
-	return result;
 }
 
 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
@@ -1403,8 +1400,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
 		conn_info->req_ies_len = ies_len;
 		conn_info->req_ies = kmemdup(ies, ies_len, GFP_KERNEL);
 		if (!conn_info->req_ies) {
-			result = -ENOMEM;
-			return result;
+			return -ENOMEM;
 		}
 	}
 
@@ -1570,7 +1566,6 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param)
 {
 	struct wid wid_list[4];
 	int i = 0;
-	int result;
 
 	if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) {
 		wid_list[i].id = WID_SHORT_RETRY_LIMIT;
@@ -1601,10 +1596,8 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param)
 		i++;
 	}
 
-	result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
+	return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
 				      i, wilc_get_vif_idx(vif));
-
-	return result;
 }
 
 static void get_periodic_rssi(struct timer_list *t)
@@ -2121,7 +2114,6 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
 
 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
 {
-	int ret;
 	struct wid wid;
 
 	wid.id = WID_TX_POWER;
@@ -2129,15 +2121,12 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
 	wid.val = &tx_power;
 	wid.size = sizeof(char);
 
-	ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+	return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
 				   wilc_get_vif_idx(vif));
-
-	return ret;
 }
 
 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
 {
-	int ret;
 	struct wid wid;
 
 	wid.id = WID_TX_POWER;
@@ -2145,8 +2134,6 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
 	wid.val = tx_power;
 	wid.size = sizeof(char);
 
-	ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
+	return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
 				   wilc_get_vif_idx(vif));
-
-	return ret;
 }
Signature · 1 line
2.17.1
#1 lore raw
Quoted 17 lines · Sanjana Sanikommu

Challenge suggested by coccinelle.
Remove return variable and directly return the value Issue found using ret.cocci

---
 drivers/staging/wilc1000/host_interface.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)
drivers/staging/wilc1000/host_interface.c +0 -0
index 4dd9a20f6a0b..a10c31bce07f 100644
@@ -1358,17 +1358,14 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
 int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid)
 {
 	struct wid wid;

drivers/staging/wilc1000/host_interface.c int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, · line 1368

Quoted 10 lines
drivers/staging/wilc1000/host_interface.c +1 -2
-	int result;
 
 	wid.id = WID_PMKID_INFO;
 	wid.type = WID_STR;
 	wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1;
 	wid.val = (u8 *)pmkid;
 
-	result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+	return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
 				      wilc_get_vif_idx(vif));

The last argument needs to be moved. Please check the other cases for the same issue.

julia

Quoted 80 lines
drivers/staging/wilc1000/host_interface.c +4 -17
-
-	return result;
 }
 
 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
@@ -1403,8 +1400,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
 		conn_info->req_ies_len = ies_len;
 		conn_info->req_ies = kmemdup(ies, ies_len, GFP_KERNEL);
 		if (!conn_info->req_ies) {
-			result = -ENOMEM;
-			return result;
+			return -ENOMEM;
 		}
 	}
 
@@ -1570,7 +1566,6 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param)
 {
 	struct wid wid_list[4];
 	int i = 0;
-	int result;
 
 	if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) {
 		wid_list[i].id = WID_SHORT_RETRY_LIMIT;
@@ -1601,10 +1596,8 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param)
 		i++;
 	}
 
-	result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
+	return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
 				      i, wilc_get_vif_idx(vif));
-
-	return result;
 }
 
 static void get_periodic_rssi(struct timer_list *t)
@@ -2121,7 +2114,6 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
 
 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
 {
-	int ret;
 	struct wid wid;
 
 	wid.id = WID_TX_POWER;
@@ -2129,15 +2121,12 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
 	wid.val = &tx_power;
 	wid.size = sizeof(char);
 
-	ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+	return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
 				   wilc_get_vif_idx(vif));
-
-	return ret;
 }
 
 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
 {
-	int ret;
 	struct wid wid;
 
 	wid.id = WID_TX_POWER;
@@ -2145,8 +2134,6 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
 	wid.val = tx_power;
 	wid.size = sizeof(char);
 
-	ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
+	return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
 				   wilc_get_vif_idx(vif));
-
-	return ret;
 }
--

2.17.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 [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/20190328175622.27971-1-sanjana99reddy99%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 31 lines · On Fri, 29 Mar 2019, 00:20 Julia Lawall, <[email protected]> wrote:

Review

Quoted 10 lines · Sanjana Sanikommu

Challenge suggested by coccinelle.
Remove return variable and directly return the value Issue found using ret.cocci

---
 drivers/staging/wilc1000/host_interface.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/wilc1000/host_interface.c

drivers/staging/wilc1000/host_interface.c int wilc_add_rx_gtk(struct wilc_vif *vif, const

Quoted 4 lines

index 4dd9a20f6a0b..a10c31bce07f 100644

drivers/staging/wilc1000/host_interface.c +0 -0
@@ -1358,17 +1358,14 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const

u8 *rx_gtk, u8 gtk_key_len,

drivers/staging/wilc1000/host_interface.c int wilc_add_rx_gtk(struct wilc_vif *vif, const · line 1358

Quoted 1 line
drivers/staging/wilc1000/host_interface.c +0 -0
 int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr

*pmkid)

Quoted 9 lines
drivers/staging/wilc1000/host_interface.c +0 -1
 {
      struct wid wid;
-     int result;
 
      wid.id = WID_PMKID_INFO;
      wid.type = WID_STR;
      wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1;
      wid.val = (u8 *)pmkid;
 
Quoted 7 lines

drivers/staging/wilc1000/host_interface.c int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, · line 1368

Quoted 3 lines
drivers/staging/wilc1000/host_interface.c +1 -1
-     result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+     return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
                                    wilc_get_vif_idx(vif));

The last argument needs to be moved. Please check the other cases for the same issue.

I will adjust the spaces.

Sanjana

Quoted 105 lines

julia

drivers/staging/wilc1000/host_interface.c int wilc_set_join_req(struct wilc_vif *vif, u8

Quoted 6 lines
drivers/staging/wilc1000/host_interface.c +0 -2
-
-     return result;
 }
 
 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
@@ -1403,8 +1400,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8

*bssid, const u8 *ies,

drivers/staging/wilc1000/host_interface.c int wilc_hif_set_cfg(struct wilc_vif *vif, struct

Quoted 10 lines
drivers/staging/wilc1000/host_interface.c +1 -2
              conn_info->req_ies_len = ies_len;
              conn_info->req_ies = kmemdup(ies, ies_len, GFP_KERNEL);
              if (!conn_info->req_ies) {
-                     result = -ENOMEM;
-                     return result;
+                     return -ENOMEM;
              }
      }
 
@@ -1570,7 +1566,6 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, struct

cfg_param_attr *param)

drivers/staging/wilc1000/host_interface.c int wilc_hif_set_cfg(struct wilc_vif *vif, struct

Quoted 8 lines
drivers/staging/wilc1000/host_interface.c +0 -1
 {
      struct wid wid_list[4];
      int i = 0;
-     int result;
 
      if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) {
              wid_list[i].id = WID_SHORT_RETRY_LIMIT;
@@ -1601,10 +1596,8 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, struct

cfg_param_attr *param)

drivers/staging/wilc1000/host_interface.c int wilc_setup_multicast_filter(struct wilc_vif

Quoted 12 lines
drivers/staging/wilc1000/host_interface.c +1 -3
              i++;
      }
 
-     result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
+     return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
                                    i, wilc_get_vif_idx(vif));
-
-     return result;
 }
 
 static void get_periodic_rssi(struct timer_list *t)
@@ -2121,7 +2114,6 @@ int wilc_setup_multicast_filter(struct wilc_vif

*vif, u32 enabled, u32 count,

drivers/staging/wilc1000/host_interface.c int wilc_set_tx_power(struct wilc_vif *vif, u8

Quoted 8 lines
drivers/staging/wilc1000/host_interface.c +0 -1
 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
 {
-     int ret;
      struct wid wid;
 
      wid.id = WID_TX_POWER;
@@ -2129,15 +2121,12 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8

tx_power)

drivers/staging/wilc1000/host_interface.c int wilc_get_tx_power(struct wilc_vif *vif, u8

Quoted 17 lines
drivers/staging/wilc1000/host_interface.c +1 -4
      wid.val = &tx_power;
      wid.size = sizeof(char);
 
-     ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
+     return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
                                 wilc_get_vif_idx(vif));
-
-     return ret;
 }
 
 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
 {
-     int ret;
      struct wid wid;
 
      wid.id = WID_TX_POWER;
@@ -2145,8 +2134,6 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8

*tx_power)

Quoted 12 lines
drivers/staging/wilc1000/host_interface.c +1 -4
      wid.val = tx_power;
      wid.size = sizeof(char);
 
-     ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
+     return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1,
                                 wilc_get_vif_idx(vif));
-
-     return ret;
 }
--

2.17.1

Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines

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/20190328175622.27971-1-sanjana99reddy99%40gmail.com
.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

--
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/alpine.DEB.2.21.1903281949430.2760%40hadrien
.
For more options, visit https://groups.google.com/d/optout.