[PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp()

Subsystems: networking [general], the rest, tipc network layer

STALE2235d

3 messages, 3 authors, 2020-08-03 · open the first message on its own page

[PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp()

From: Huang Guobin <hidden>
Date: 2020-08-03 01:52:42

Using is_broadcast_ether_addr() instead of directly use
memcmp() to determine if the ethernet address is broadcast
address.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Huang Guobin <redacted>
---
 net/tipc/eth_media.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index 8b0bb600602d..c68019697cfe 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -62,12 +62,10 @@ static int tipc_eth_raw2addr(struct tipc_bearer *b,
 			     struct tipc_media_addr *addr,
 			     char *msg)
 {
-	char bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
 	memset(addr, 0, sizeof(*addr));
 	ether_addr_copy(addr->value, msg);
 	addr->media_id = TIPC_MEDIA_TYPE_ETH;
-	addr->broadcast = !memcmp(addr->value, bcast_mac, ETH_ALEN);
+	addr->broadcast = is_broadcast_ether_addr(addr->value);
 	return 0;
 }
 
-- 
2.17.1

Re: [PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp()

From: Ying Xue <hidden>
Date: 2020-08-03 14:08:23

On 8/3/20 10:00 AM, Huang Guobin wrote:
Using is_broadcast_ether_addr() instead of directly use
memcmp() to determine if the ethernet address is broadcast
address.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Huang Guobin <redacted>
Acked-by: Ying Xue <redacted>
quoted hunk
---
 net/tipc/eth_media.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index 8b0bb600602d..c68019697cfe 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -62,12 +62,10 @@ static int tipc_eth_raw2addr(struct tipc_bearer *b,
 			     struct tipc_media_addr *addr,
 			     char *msg)
 {
-	char bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
 	memset(addr, 0, sizeof(*addr));
 	ether_addr_copy(addr->value, msg);
 	addr->media_id = TIPC_MEDIA_TYPE_ETH;
-	addr->broadcast = !memcmp(addr->value, bcast_mac, ETH_ALEN);
+	addr->broadcast = is_broadcast_ether_addr(addr->value);
 	return 0;
 }
 

Re: [PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp()

From: David Miller <davem@davemloft.net>
Date: 2020-08-03 23:22:05

From: Huang Guobin <redacted>
Date: Sun, 2 Aug 2020 22:00:55 -0400
Using is_broadcast_ether_addr() instead of directly use
memcmp() to determine if the ethernet address is broadcast
address.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Huang Guobin <redacted>
Applied, thank you.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help