All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp()
@ 2020-08-03  2:00 Huang Guobin
  2020-08-03 13:51 ` Ying Xue
  2020-08-03 23:22 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Huang Guobin @ 2020-08-03  2:00 UTC (permalink / raw)
  To: jmaloy, ying.xue, davem, kuba; +Cc: netdev, tipc-discussion, linux-kernel

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 <huangguobin4@huawei.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp()
  2020-08-03  2:00 [PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp() Huang Guobin
@ 2020-08-03 13:51 ` Ying Xue
  2020-08-03 23:22 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Ying Xue @ 2020-08-03 13:51 UTC (permalink / raw)
  To: Huang Guobin, jmaloy, davem, kuba; +Cc: netdev, tipc-discussion, linux-kernel

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 <huangguobin4@huawei.com>

Acked-by: Ying Xue <ying.xue@windriver.com>

> ---
>  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;
>  }
>  
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp()
  2020-08-03  2:00 [PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp() Huang Guobin
  2020-08-03 13:51 ` Ying Xue
@ 2020-08-03 23:22 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-08-03 23:22 UTC (permalink / raw)
  To: huangguobin4
  Cc: jmaloy, ying.xue, kuba, netdev, tipc-discussion, linux-kernel

From: Huang Guobin <huangguobin4@huawei.com>
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 <huangguobin4@huawei.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-03 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-03  2:00 [PATCH net-next] tipc: Use is_broadcast_ether_addr() instead of memcmp() Huang Guobin
2020-08-03 13:51 ` Ying Xue
2020-08-03 23:22 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.