Skip to contentSkip to conversation

usb gadget ether: Fix warning in is_eth_addr_valid()

PATCH New Tom Rini 2 participants 3 messages Oct 31, 2012 – Nov 4, 2012 USB

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 usb gadget ether: Fix warning in is_eth_addr_valid()

The gadget ethernet driver needs to keep copies of the MAC address (at both endpoints) as strings so it needs a custom function for validation of the MAC. It was not however performing a totally correct check and also was emitting a warning about a set but unused variable. The solution to both is that after checking the string contents we use the standard test for a valid MAC.

Cc Joe Hershberger <[email protected]>
Cc Marek Vasut <[email protected]>
---
 drivers/usb/gadget/ether.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/ether.c +2 -2
index 6f7e4cd..7444c1e 100644
@@ -1968,8 +1968,8 @@ static int is_eth_addr_valid(char *str)
 			p = q;
 		}
 
-		if (i == 6) /* it looks ok */
-			return 1;
+		/* Now check the contents. */
+		return is_valid_ether_addr(ea);
 	}
 	return 0;
 }
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 usb gadget ether: Fix warning in is_eth_addr_valid()

Hi Tom,

Quoted 11 lines · Tom Rini

The gadget ethernet driver needs to keep copies of the MAC address (at both endpoints) as strings so it needs a custom function for validation of the MAC. It was not however performing a totally correct check and also was emitting a warning about a set but unused variable. The solution to both is that after checking the string contents we use the standard test for a valid MAC.

Cc Joe Hershberger <[email protected]>
Cc Marek Vasut <[email protected]>

---

author
#2 lore raw

PATCH 1/1 usb gadget ether: Fix warning in is_eth_addr_valid()

Quoted 10 lines · Joe Hershberger

Hi Tom,

Quoted 7 lines · Tom Rini

The gadget ethernet driver needs to keep copies of the MAC address (at both endpoints) as strings so it needs a custom function for validation of the MAC. It was not however performing a totally correct check and also was emitting a warning about a set but unused variable. The solution to both is that after checking the string contents we use the standard test for a valid MAC.

Quoted 6 lines
Quoted 4 lines
Cc Joe Hershberger <[email protected]>
Cc Marek Vasut <[email protected]>

---

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121104/c138ec11/attachment.pgp>