Skip to contentSkip to conversation

Remove return variables in multiple functions

PATCH Superseded Nishka Dasgupta 2 participants 12 messages Mar 19, 2019 – Mar 20, 2019 Staging

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Remove return variables in multiple functions

The following patches remove the return variable in multiple functions and return the required values directly. These issues were suggested by Coccinelle using ret.cocci.

Nishka Dasgupta (5):
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable

 drivers/staging/wilc1000/host_interface.c | 11 +++--------
 drivers/staging/wilc1000/wilc_spi.c       |  6 ++----
 2 files changed, 5 insertions(+), 12 deletions(-)
Signature · 1 line
2.19.1
#1 lore raw

PATCH 1/5 staging: wilc1000: Remove return variable

Remove return variable. Issue found with Coccinelle using ret.cocci.

---
 drivers/staging/wilc1000/host_interface.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/wilc1000/host_interface.c +1 -3
index 56d8ed29fff9..cd4d9bd789fd 100644
@@ -1365,10 +1365,8 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid)
 	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)
Signature · 1 line
2.19.1
#2 lore raw

Re: [Outreachy kernel] [PATCH 1/5] staging: wilc1000: Remove return variable

Quoted 12 lines · Nishka Dasgupta' via outreachy-kernel

Remove return variable. Issue found with Coccinelle using ret.cocci.

---
 drivers/staging/wilc1000/host_interface.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/wilc1000/host_interface.c +0 -0
index 56d8ed29fff9..cd4d9bd789fd 100644

drivers/staging/wilc1000/host_interface.c int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid) · line 1369

Quoted 6 lines
drivers/staging/wilc1000/host_interface.c +1 -1
@@ -1365,10 +1365,8 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid)
 	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 should be lined up with the (. But you can check if it would now fit on the previous line.

julia

Quoted 15 lines
drivers/staging/wilc1000/host_interface.c +0 -3
-
-	return result;
 }
 
 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
--

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 [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/7ee75b6e103796fc5c536be85aa5763c691b885c.1553025265.git.nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw

PATCH 2/5 staging: wilc1000: Remove return variable

In reply to Nishka Dasgupta

Remove return variable. Issue found with Coccinelle using ret.cocci.

---
 drivers/staging/wilc1000/host_interface.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/host_interface.c +1 -2
index cd4d9bd789fd..9b9997e3ecf9 100644
@@ -1401,8 +1401,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;
 		}
 	}
 
Signature · 1 line
2.19.1
Acked-by on v1 2/5
#4 lore raw

Re: [Outreachy kernel] [PATCH 2/5] staging: wilc1000: Remove return variable

Quoted 3 lines · Nishka Dasgupta' via outreachy-kernel

Remove return variable. Issue found with Coccinelle using ret.cocci.

This one is particularly nice :)

Quoted 28 lines
---
 drivers/staging/wilc1000/host_interface.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/host_interface.c +1 -3
index cd4d9bd789fd..9b9997e3ecf9 100644
@@ -1401,8 +1401,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;
 		}
 	}
 
--

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 [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/10fe1f5ac83e327337735300199b81a9b1230423.1553025265.git.nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.

#5 lore raw

PATCH 3/5 staging: wilc1000: Remove return variable

In reply to Nishka Dasgupta

Remove return variable. Issue found with Coccinelle using ret.cocci.

---
 drivers/staging/wilc1000/host_interface.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/wilc1000/host_interface.c +1 -3
index 9b9997e3ecf9..fdad1928c4f7 100644
@@ -1598,10 +1598,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)
Signature · 1 line
2.19.1
#6 lore raw

PATCH 4/5 staging: wilc1000: Remove return variable

In reply to Nishka Dasgupta

Remove return variable and return required value directly. Issue found with Coccinelle using ret.cocci.

---
 drivers/staging/wilc1000/wilc_spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +1 -2
index 4a1be9e60d74..28fdfa269192 100644
@@ -934,9 +934,8 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 	int k = IRG_FLAGS_OFFSET + 5;
 
 	if (spi_priv->has_thrpt_enh) {
-		ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
+		return spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
 					int_status);
-		return ret;
 	}
 	ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE, &byte_cnt);
 	if (!ret) {
Signature · 1 line
2.19.1
#7 lore raw

PATCH 5/5 staging: wilc1000: Remove return variable

In reply to Nishka Dasgupta

Remove return variable and return required value directly. Issue found with Coccinelle using ret.cocci.

---
 drivers/staging/wilc1000/wilc_spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +1 -2
index 28fdfa269192..9959a794edc7 100644
@@ -981,9 +981,8 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val)
 	u32 tbl_ctl;
 
 	if (spi_priv->has_thrpt_enh) {
-		ret = spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE,
+		return spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE,
 					 val);
-		return ret;
 	}
 
 	flags = val & (BIT(MAX_NUM_INT) - 1);
Signature · 1 line
2.19.1
#8 lore raw

Re: [Outreachy kernel] [PATCH 5/5] staging: wilc1000: Remove return variable

Quoted 13 lines · Nishka Dasgupta' via outreachy-kernel

Remove return variable and return required value directly. Issue found with Coccinelle using ret.cocci.

---
 drivers/staging/wilc1000/wilc_spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +0 -0
index 28fdfa269192..9959a794edc7 100644

drivers/staging/wilc1000/wilc_spi.c static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val) · line 985

Quoted 6 lines
drivers/staging/wilc1000/wilc_spi.c +1 -1
@@ -981,9 +981,8 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val)
 	u32 tbl_ctl;
 
 	if (spi_priv->has_thrpt_enh) {
-		ret = spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE,
+		return spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE,
 					 val);

You need to adjust the position of val. You can check if it would fit on the previous line.

julia

Quoted 14 lines
drivers/staging/wilc1000/wilc_spi.c +0 -2
-		return ret;
 	}
 
 	flags = val & (BIT(MAX_NUM_INT) - 1);
--

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 [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/030f11edadf6ee01ffbe7d239f8352b8034427af.1553025265.git.nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.

#9 lore raw
In reply to Nishka Dasgupta
Quoted 10 lines · Nishka Dasgupta' via outreachy-kernel

The following patches remove the return variable in multiple functions and return the required values directly. These issues were suggested by Coccinelle using ret.cocci.

Nishka Dasgupta (5):
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable

I haven't received the other patches in this series, but just from the above there is a problem. Every patch should have a subject line that is unique. On solution would be to incorporate the file name, but it seems that you have only two files. If the changes are not too voluminous, you could send a single patch for all of the changes in a given file.

julia

Quoted 15 lines
 drivers/staging/wilc1000/host_interface.c | 11 +++--------
 drivers/staging/wilc1000/wilc_spi.c       |  6 ++----
 2 files changed, 5 insertions(+), 12 deletions(-)

--
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 [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/cover.1553025265.git.nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.

#10 lore raw
Quoted 15 lines · Julia Lawall
Quoted 10 lines · Nishka Dasgupta' via outreachy-kernel

The following patches remove the return variable in multiple functions and return the required values directly. These issues were suggested by Coccinelle using ret.cocci.

Nishka Dasgupta (5):
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable

Quoted 5 lines

I haven't received the other patches in this series, but just from the above there is a problem. Every patch should have a subject line that is unique. On solution would be to incorporate the file name, but it seems that you have only two files. If the changes are not too voluminous, you could send a single patch for all of the changes in a given file.

Since you've acked one or two of them, should I send a version 2 of the entire patchset or just the ones that need adjustments? Thanking you,
Nishka

Quoted 17 lines

julia

Quoted 15 lines
  drivers/staging/wilc1000/host_interface.c | 11 +++--------
  drivers/staging/wilc1000/wilc_spi.c       |  6 ++----
  2 files changed, 5 insertions(+), 12 deletions(-)

--
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 [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/cover.1553025265.git.nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.

#11 lore raw
Quoted 18 lines · NIshka Dasgupta' via outreachy-kernel
Quoted 15 lines · Julia Lawall
Quoted 10 lines · Nishka Dasgupta' via outreachy-kernel

The following patches remove the return variable in multiple functions and return the required values directly. These issues were suggested by Coccinelle using ret.cocci.

Nishka Dasgupta (5):
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable
staging: wilc1000: Remove return variable

Quoted 8 lines
Quoted 5 lines

I haven't received the other patches in this series, but just from the above there is a problem. Every patch should have a subject line that is unique. On solution would be to incorporate the file name, but it seems that you have only two files. If the changes are not too voluminous, you could send a single patch for all of the changes in a given file.

Since you've acked one or two of them, should I send a version 2 of the entire patchset or just the ones that need adjustments?

Send a version 2 of the whole patch set. If I've acked some, then you can keep the ack in the v2.

julia

Quoted 34 lines

Thanking you,
Nishka

Quoted 20 lines

julia

Quoted 18 lines
  drivers/staging/wilc1000/host_interface.c | 11 +++--------
  drivers/staging/wilc1000/wilc_spi.c       |  6 ++----
  2 files changed, 5 insertions(+), 12 deletions(-)

--
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 [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/cover.1553025265.git.nishka.dasgupta%40yahoo.com.
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/0310644f-84f3-2aca-1a90-5463b2dc37b3%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.