Skip to contentSkip to conversation

drivers: net: ethernet: 3com: fix return value

PATCH Superseded Thomas Preisner 4 participants 18 messages Dec 23, 2016 – Dec 30, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: net: ethernet: 3com: fix return value

In a few cases the err-variable is not set to a negative error code if a function call fails and thus 0 is returned instead.
It may be better to set err to the proper negative error code before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

---
 drivers/net/ethernet/3com/typhoon.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/3com/typhoon.c +3 -0
index a0cacbe..9a3ab58 100644
@@ -2404,6 +2404,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(!is_valid_ether_addr(dev->dev_addr)) {
 		err_msg = "Could not obtain valid ethernet address, aborting";
+		err = -EIO;
 		goto error_out_reset;
 	}
 
@@ -2413,6 +2414,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
 	if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
 		err_msg = "Could not get Sleep Image version";
+		err = -EIO;
 		goto error_out_reset;
 	}
 
@@ -2455,6 +2457,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(register_netdev(dev) < 0) {
 		err_msg = "unable to register netdev";
+		err = -EIO;
 		goto error_out_reset;
 	}
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw

drivers/net/ethernet/3com/typhoon.c typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2408

Quoted 10 lines · Thomas Preisner
drivers/net/ethernet/3com/typhoon.c +1 -0
index a0cacbe..9a3ab58 100644
@@ -2404,6 +2404,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(!is_valid_ether_addr(dev->dev_addr)) {
 		err_msg = "Could not obtain valid ethernet address, aborting";
+		err = -EIO;
 		goto error_out_reset;

The change above is fine, but the other two should use the return value from the failing function call.

Quoted 16 lines
drivers/net/ethernet/3com/typhoon.c +2 -0
@@ -2413,6 +2414,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
 	if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
 		err_msg = "Could not get Sleep Image version";
+		err = -EIO;
 		goto error_out_reset;
 	}
 
@@ -2455,6 +2457,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(register_netdev(dev) < 0) {
 		err_msg = "unable to register netdev";
+		err = -EIO;
 		goto error_out_reset;
 	}
 
#2 lore raw
Quoted 24 lines · David Dillow

drivers/net/ethernet/3com/typhoon.c typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2408

Quoted 10 lines · Thomas Preisner
drivers/net/ethernet/3com/typhoon.c +1 -0
index a0cacbe..9a3ab58 100644
@@ -2404,6 +2404,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(!is_valid_ether_addr(dev->dev_addr)) {
 		err_msg = "Could not obtain valid ethernet address, aborting";
+		err = -EIO;
 		goto error_out_reset;

The change above is fine, but the other two should use the return value from the failing function call.

Quoted 8 lines
drivers/net/ethernet/3com/typhoon.c +1 -0
@@ -2413,6 +2414,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
 	if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
 		err_msg = "Could not get Sleep Image version";
+		err = -EIO;
 		goto error_out_reset;
 	}
 
Quoted 8 lines

drivers/net/ethernet/3com/typhoon.c typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2463

Quoted 8 lines
drivers/net/ethernet/3com/typhoon.c +1 -0
@@ -2455,6 +2457,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(register_netdev(dev) < 0) {
 		err_msg = "unable to register netdev";
+		err = -EIO;
 		goto error_out_reset;
 	}
 

You are of course right. After you mentioning this we've looked into it a bit further and realized that the return values of failing function calls are not being used in various occasions inside of typhoon_init_one(). That's why we've created a second patch to fix this misbehavior (if it is one). In case this was intended, feel free to ignore the second patch.

Patch 1:
Makes the function typhoon_init_one() return a negative error code instead of 0.

Patch 2 [Optional]:
Makes the function typhoon_init_one() return the return value of the corresponding failing function calls instead of a "fixed" negative error code.

With regards (and merry christmas),
Milan and Thomas

#3 lore raw

PATCH v2 1/2 drivers: net: ethernet: 3com: fix return value

In a few cases the err-variable is not set to a negative error code if a function call fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

---
 drivers/net/ethernet/3com/typhoon.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/3com/typhoon.c +5 -2
index a0cacbe..c88b88a 100644
@@ -2404,6 +2404,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(!is_valid_ether_addr(dev->dev_addr)) {
 		err_msg = "Could not obtain valid ethernet address, aborting";
+		err = -EIO;
 		goto error_out_reset;
 	}
 
@@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * later when we print out the version reported.
 	 */
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
-	if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
+	err = typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp);
+	if(err < 0) {
 		err_msg = "Could not get Sleep Image version";
 		goto error_out_reset;
 	}
@@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	dev->features = dev->hw_features |
 		NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
 
-	if(register_netdev(dev) < 0) {
+	err = register_netdev(dev);
+	if(err < 0) {
 		err_msg = "unable to register netdev";
 		goto error_out_reset;
 	}
Signature · 1 line
2.7.4
#4 lore raw

Hello!

Quoted 18 lines · Thomas Preisner

In a few cases the err-variable is not set to a negative error code if a function call fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

---
 drivers/net/ethernet/3com/typhoon.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/3com/typhoon.c +0 -0
index a0cacbe..c88b88a 100644

[...]

drivers/net/ethernet/3com/typhoon.c typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2416

Quoted 7 lines
drivers/net/ethernet/3com/typhoon.c +2 -1
@@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * later when we print out the version reported.
 	 */
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
-	if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
+	err = typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp);
+	if(err < 0) {

Need a space between *if* and (. Run your patches thru
scripts/checkpatch.pl before posting, please.

drivers/net/ethernet/3com/typhoon.c typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2459

Quoted 10 lines
drivers/net/ethernet/3com/typhoon.c +2 -1
 		err_msg = "Could not get Sleep Image version";
 		goto error_out_reset;
 	}
@@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	dev->features = dev->hw_features |
 		NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
 
-	if(register_netdev(dev) < 0) {
+	err = register_netdev(dev);
+	if(err < 0) {

Same here.

[...]

MBR, Sergei

#5 lore raw

Hello.

Quoted 23 lines · Sergei Shtylyov

Hello!

Quoted 18 lines · Thomas Preisner

In a few cases the err-variable is not set to a negative error code if a function call fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

---
 drivers/net/ethernet/3com/typhoon.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/3com/typhoon.c +0 -0
index a0cacbe..c88b88a 100644

[...]

Quoted 10 lines

drivers/net/ethernet/3com/typhoon.c typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2416

Quoted 7 lines
drivers/net/ethernet/3com/typhoon.c +2 -1
@@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * later when we print out the version reported.
 	 */
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
-	if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
+	err = typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp);
+	if(err < 0) {

Need a space between *if* and (. Run your patches thru
scripts/checkpatch.pl before posting, please.

Those spaces were actually left out purposely: The file in question (typhoon.c) is missing those spaces between the statements (if, for, while) and the following opening bracket pretty much always (except 2-3 times) and we figured that it might be better to keep the coding style consistent since this might aswell have been intended by the original author.

Quoted 14 lines

drivers/net/ethernet/3com/typhoon.c typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2459

Quoted 11 lines
drivers/net/ethernet/3com/typhoon.c +2 -1
 		err_msg = "Could not get Sleep Image version";
 		goto error_out_reset;
 	}
@@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	dev->features = dev->hw_features |
 		NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
 
-	if(register_netdev(dev) < 0) {
+	err = register_netdev(dev);
+	if(err < 0) {

Same here.

Quoted 3 lines

[...]

MBR, Sergei

But of course we can provide you with a patchset including those spaces.

With Regards,
Milan and Thomas

#6 lore raw

PATCH v3 1/2 drivers: net: ethernet: 3com: fix return value

In a few cases the err-variable is not set to a negative error code if a function call fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

---
 drivers/net/ethernet/3com/typhoon.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/3com/typhoon.c +6 -3
index a0cacbe..c88b88a 100644
@@ -2404,6 +2404,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
-	if(!is_valid_ether_addr(dev->dev_addr)) {
+	if (!is_valid_ether_addr(dev->dev_addr)) {
 		err_msg = "Could not obtain valid ethernet address, aborting";
+		err = -EIO;
 		goto error_out_reset;
 	}
 
@@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * later when we print out the version reported.
 	 */
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
-	if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
+	err = typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp);
+	if (err < 0) {
 		err_msg = "Could not get Sleep Image version";
 		goto error_out_reset;
 	}
@@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	dev->features = dev->hw_features |
 		NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
 
-	if(register_netdev(dev) < 0) {
+	err = register_netdev(dev);
+	if (err < 0) {
 		err_msg = "unable to register netdev";
 		goto error_out_reset;
 	}
Signature · 1 line
2.7.4
maintainer
#7 lore raw

It is never, ever, appropriate to use the same exact Subject: line text for two different changes.

Someone looking at "git shortlog" has no way to know what is different between the two changes.

You must put care and time into constructing Subject: lines because this text is critical for data mining and analysis done by both humans and machines.

#8 lore raw

PATCH v3 2/2 drivers: net: ethernet: 3com: fix return value

In reply to Thomas Preisner

In some cases the return value of a failing function is not being used and the function typhoon_init_one() returns another negative error code instead.

---
 drivers/net/ethernet/3com/typhoon.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/3com/typhoon.c +8 -8
index c88b88a..8821a24 100644
@@ -2370,9 +2370,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * 4) Get the hardware address.
 	 * 5) Put the card to sleep.
 	 */
-	if (typhoon_reset(ioaddr, WaitSleep) < 0) {
+	err = typhoon_reset(ioaddr, WaitSleep);
+	if (err < 0) {
 		err_msg = "could not reset 3XP";
-		err = -EIO;
 		goto error_out_dma;
 	}
 
@@ -2386,16 +2386,16 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	typhoon_init_interface(tp);
 	typhoon_init_rings(tp);
 
-	if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) {
+	err = typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST);
+	if (err < 0) {
 		err_msg = "cannot boot 3XP sleep image";
-		err = -EIO;
 		goto error_out_reset;
 	}
 
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_MAC_ADDRESS);
-	if(typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp) < 0) {
+	err = typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp);
+	if (err < 0) {
 		err_msg = "cannot read MAC address";
-		err = -EIO;
 		goto error_out_reset;
 	}
 
@@ -2430,9 +2430,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if(xp_resp[0].numDesc != 0)
 		tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET;
 
-	if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) {
+	err = typhoon_sleep(tp, PCI_D3hot, 0);
+	if (err < 0) {
 		err_msg = "cannot put adapter to sleep";
-		err = -EIO;
 		goto error_out_reset;
 	}
 
Signature · 1 line
2.7.4
#9 lore raw

Hello!

Quoted 9 lines · Thomas Preisner

In some cases the return value of a failing function is not being used and the function typhoon_init_one() returns another negative error code instead.

---
 drivers/net/ethernet/3com/typhoon.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

In addition to what DaveM said, your choise of the subject prefixes is too
wide -- it would seem that you're fixing all 3com drivers, while you're only fixing typhoon. That "typhoon:" alone would have been an appropriate prefix.

MBR, Sergei

maintainer
#10 lore raw
In reply to Thomas Preisner
Quoted 3 lines · Thomas Preisner

In some cases the return value of a failing function is not being used and the function typhoon_init_one() returns another negative error code instead.

I'm not sure these changes are especially valuable, since we'll need to look at the dmesg log anyways to figure out what went wrong, but again I don't feel strongly.

Fix up the subject issues and I'm happy to ack them.

#11 lore raw
Quoted 10 lines · David Dillow
Quoted 3 lines · Thomas Preisner

In some cases the return value of a failing function is not being used and the function typhoon_init_one() returns another negative error code instead.

I'm not sure these changes are especially valuable, since we'll need to look at the dmesg log anyways to figure out what went wrong, but again I don't feel strongly.

Fix up the subject issues and I'm happy to ack them.

As requested, here are the patchsets with the fixed subjects. The subjects aswell as the subject prefixes are more precise now. Hopefully that's ok.

Patch 1:
Makes the function typhoon_init_one() return a negative error code instead of 0.

Patch 2 [Optional]:
Makes the function typhoon_init_one() return the return value of the corresponding failing function calls instead of a "fixed" negative error code.

With Regards,
Milan and Thomas

#12 lore raw

PATCH v4 1/2 net: 3com: typhoon: typhoon_init_one: fix incorrect return values

In a few cases the err-variable is not set to a negative error code if a function call in typhoon_init_one() fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

---
 drivers/net/ethernet/3com/typhoon.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/3com/typhoon.c +6 -3
index 9fe3990..25f2e92 100644
@@ -2402,8 +2402,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	*(__be16 *)&dev->dev_addr[0] = htons(le16_to_cpu(xp_resp[0].parm1));
 	*(__be32 *)&dev->dev_addr[2] = htonl(le32_to_cpu(xp_resp[0].parm2));
 
-	if(!is_valid_ether_addr(dev->dev_addr)) {
+	if (!is_valid_ether_addr(dev->dev_addr)) {
 		err_msg = "Could not obtain valid ethernet address, aborting";
+		err = -EIO;
 		goto error_out_reset;
 	}
 
@@ -2411,7 +2412,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * later when we print out the version reported.
 	 */
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
-	if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
+	err = typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp);
+	if (err < 0) {
 		err_msg = "Could not get Sleep Image version";
 		goto error_out_reset;
 	}
@@ -2453,7 +2455,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	dev->features = dev->hw_features |
 		NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
 
-	if(register_netdev(dev) < 0) {
+	err = register_netdev(dev);
+	if (err < 0) {
 		err_msg = "unable to register netdev";
 		goto error_out_reset;
 	}
Signature · 1 line
2.7.4
maintainer Applied
#13 lore raw

Re: [PATCH v4 1/2] net: 3com: typhoon: typhoon_init_one: fix incorrect return values

From: Thomas Preisner <[email protected]>
Date: Fri, 30 Dec 2016 03:37:53 +0100

Quoted 11 lines

In a few cases the err-variable is not set to a negative error code if a function call in typhoon_init_one() fails and thus 0 is returned instead.
It may be better to set err to the appropriate negative error code before returning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188841

Applied to net-next.

#14 lore raw

PATCH v4 2/2 net: 3com: typhoon: typhoon_init_one: make return values more specific

In reply to Thomas Preisner

In some cases the return value of a failing function is not being used and the function typhoon_init_one() returns another negative error code instead.

---
 drivers/net/ethernet/3com/typhoon.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/3com/typhoon.c +8 -8
index 25f2e92..1986ad1 100644
@@ -2370,9 +2370,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * 4) Get the hardware address.
 	 * 5) Put the card to sleep.
 	 */
-	if (typhoon_reset(ioaddr, WaitSleep) < 0) {
+	err = typhoon_reset(ioaddr, WaitSleep);
+	if (err < 0) {
 		err_msg = "could not reset 3XP";
-		err = -EIO;
 		goto error_out_dma;
 	}
 
@@ -2386,16 +2386,16 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	typhoon_init_interface(tp);
 	typhoon_init_rings(tp);
 
-	if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) {
+	err = typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST);
+	if (err < 0) {
 		err_msg = "cannot boot 3XP sleep image";
-		err = -EIO;
 		goto error_out_reset;
 	}
 
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_MAC_ADDRESS);
-	if(typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp) < 0) {
+	err = typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp);
+	if (err < 0) {
 		err_msg = "cannot read MAC address";
-		err = -EIO;
 		goto error_out_reset;
 	}
 
@@ -2430,9 +2430,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if(xp_resp[0].numDesc != 0)
 		tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET;
 
-	if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) {
+	err = typhoon_sleep(tp, PCI_D3hot, 0);
+	if (err < 0) {
 		err_msg = "cannot put adapter to sleep";
-		err = -EIO;
 		goto error_out_reset;
 	}
 
Signature · 1 line
2.7.4
maintainer Applied
#15 lore raw

Re: [PATCH v4 2/2] net: 3com: typhoon: typhoon_init_one: make return values more specific

From: Thomas Preisner <[email protected]>
Date: Fri, 30 Dec 2016 03:37:54 +0100

Quoted 6 lines

In some cases the return value of a failing function is not being used and the function typhoon_init_one() returns another negative error code instead.

Applied to net-next.

maintainer
#16 lore raw
In reply to Thomas Preisner
Quoted 5 lines · Thomas Preisner

Those spaces were actually left out purposely: The file in question (typhoon.c) is missing those spaces between the statements (if, for, while) and the following opening bracket pretty much always (except 2-3 times) and we figured that it might be better to keep the coding style consistent since this might aswell have been intended by the original author.

I'm not sure if we had the rule back then, or if I just missed it. Either way, we should follow the rules for new code if we can.

I'm not sure it's worth fixing all of the instances -- usually formatting-only changes are not worth the churn -- but I don't have a strong opinion on the matter.

#17 lore raw

PATCH v2 2/2 drivers: net: ethernet: 3com: fix return value

In reply to Thomas Preisner

In some cases the return value of a failing function is not being used and the function typhoon_init_one() returns another negative error code instead.

---
 drivers/net/ethernet/3com/typhoon.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/3com/typhoon.c +8 -8
index c88b88a..8821a24 100644
@@ -2370,9 +2370,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * 4) Get the hardware address.
 	 * 5) Put the card to sleep.
 	 */
-	if (typhoon_reset(ioaddr, WaitSleep) < 0) {
+	err = typhoon_reset(ioaddr, WaitSleep);
+	if (err < 0) {
 		err_msg = "could not reset 3XP";
-		err = -EIO;
 		goto error_out_dma;
 	}
 
@@ -2386,16 +2386,16 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	typhoon_init_interface(tp);
 	typhoon_init_rings(tp);
 
-	if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) {
+	err = typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST);
+	if(err < 0) {
 		err_msg = "cannot boot 3XP sleep image";
-		err = -EIO;
 		goto error_out_reset;
 	}
 
 	INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_MAC_ADDRESS);
-	if(typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp) < 0) {
+	err = typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp);
+	if(err < 0) {
 		err_msg = "cannot read MAC address";
-		err = -EIO;
 		goto error_out_reset;
 	}
 
@@ -2430,9 +2430,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if(xp_resp[0].numDesc != 0)
 		tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET;
 
-	if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) {
+	err = typhoon_sleep(tp, PCI_D3hot, 0);
+	if(err < 0) {
 		err_msg = "cannot put adapter to sleep";
-		err = -EIO;
 		goto error_out_reset;
 	}
 
Signature · 1 line
2.7.4