diff options
author | Joe Perches <joe@perches.com> | 2012-05-08 14:56:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-05-09 20:49:17 -0400 |
commit | 53a2b3a18d7ec8fc026bbcb59ed722f780b5abcc (patch) | |
tree | 636cab4d31a12602919e41796e13d6e729eb45ba /net/8021q | |
parent | 28b29801b95de20405b2a11945cb6dfc7c6c84f9 (diff) |
8021q: Convert compare_ether_addr to ether_addr_equal
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Done via cocci script:
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q')
-rw-r--r-- | net/8021q/vlan.c | 10 | ||||
-rw-r--r-- | net/8021q/vlan_core.c | 3 | ||||
-rw-r--r-- | net/8021q/vlan_dev.c | 10 |
3 files changed, 11 insertions, 12 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index efea35b02e7f..6089f0cf23b4 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -266,19 +266,19 @@ static void vlan_sync_address(struct net_device *dev, | |||
266 | struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev); | 266 | struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev); |
267 | 267 | ||
268 | /* May be called without an actual change */ | 268 | /* May be called without an actual change */ |
269 | if (!compare_ether_addr(vlan->real_dev_addr, dev->dev_addr)) | 269 | if (ether_addr_equal(vlan->real_dev_addr, dev->dev_addr)) |
270 | return; | 270 | return; |
271 | 271 | ||
272 | /* vlan address was different from the old address and is equal to | 272 | /* vlan address was different from the old address and is equal to |
273 | * the new address */ | 273 | * the new address */ |
274 | if (compare_ether_addr(vlandev->dev_addr, vlan->real_dev_addr) && | 274 | if (!ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) && |
275 | !compare_ether_addr(vlandev->dev_addr, dev->dev_addr)) | 275 | ether_addr_equal(vlandev->dev_addr, dev->dev_addr)) |
276 | dev_uc_del(dev, vlandev->dev_addr); | 276 | dev_uc_del(dev, vlandev->dev_addr); |
277 | 277 | ||
278 | /* vlan address was equal to the old address and is different from | 278 | /* vlan address was equal to the old address and is different from |
279 | * the new address */ | 279 | * the new address */ |
280 | if (!compare_ether_addr(vlandev->dev_addr, vlan->real_dev_addr) && | 280 | if (ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) && |
281 | compare_ether_addr(vlandev->dev_addr, dev->dev_addr)) | 281 | !ether_addr_equal(vlandev->dev_addr, dev->dev_addr)) |
282 | dev_uc_add(dev, vlandev->dev_addr); | 282 | dev_uc_add(dev, vlandev->dev_addr); |
283 | 283 | ||
284 | memcpy(vlan->real_dev_addr, dev->dev_addr, ETH_ALEN); | 284 | memcpy(vlan->real_dev_addr, dev->dev_addr, ETH_ALEN); |
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 4d39d802be2c..8ca533c95de0 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c | |||
@@ -31,8 +31,7 @@ bool vlan_do_receive(struct sk_buff **skbp, bool last_handler) | |||
31 | /* Our lower layer thinks this is not local, let's make sure. | 31 | /* Our lower layer thinks this is not local, let's make sure. |
32 | * This allows the VLAN to have a different MAC than the | 32 | * This allows the VLAN to have a different MAC than the |
33 | * underlying device, and still route correctly. */ | 33 | * underlying device, and still route correctly. */ |
34 | if (!compare_ether_addr(eth_hdr(skb)->h_dest, | 34 | if (ether_addr_equal(eth_hdr(skb)->h_dest, vlan_dev->dev_addr)) |
35 | vlan_dev->dev_addr)) | ||
36 | skb->pkt_type = PACKET_HOST; | 35 | skb->pkt_type = PACKET_HOST; |
37 | } | 36 | } |
38 | 37 | ||
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 9988d4abb372..eaf5f21b0ef7 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -277,7 +277,7 @@ static int vlan_dev_open(struct net_device *dev) | |||
277 | !(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) | 277 | !(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) |
278 | return -ENETDOWN; | 278 | return -ENETDOWN; |
279 | 279 | ||
280 | if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr)) { | 280 | if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr)) { |
281 | err = dev_uc_add(real_dev, dev->dev_addr); | 281 | err = dev_uc_add(real_dev, dev->dev_addr); |
282 | if (err < 0) | 282 | if (err < 0) |
283 | goto out; | 283 | goto out; |
@@ -307,7 +307,7 @@ clear_allmulti: | |||
307 | if (dev->flags & IFF_ALLMULTI) | 307 | if (dev->flags & IFF_ALLMULTI) |
308 | dev_set_allmulti(real_dev, -1); | 308 | dev_set_allmulti(real_dev, -1); |
309 | del_unicast: | 309 | del_unicast: |
310 | if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr)) | 310 | if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr)) |
311 | dev_uc_del(real_dev, dev->dev_addr); | 311 | dev_uc_del(real_dev, dev->dev_addr); |
312 | out: | 312 | out: |
313 | netif_carrier_off(dev); | 313 | netif_carrier_off(dev); |
@@ -326,7 +326,7 @@ static int vlan_dev_stop(struct net_device *dev) | |||
326 | if (dev->flags & IFF_PROMISC) | 326 | if (dev->flags & IFF_PROMISC) |
327 | dev_set_promiscuity(real_dev, -1); | 327 | dev_set_promiscuity(real_dev, -1); |
328 | 328 | ||
329 | if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr)) | 329 | if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr)) |
330 | dev_uc_del(real_dev, dev->dev_addr); | 330 | dev_uc_del(real_dev, dev->dev_addr); |
331 | 331 | ||
332 | netif_carrier_off(dev); | 332 | netif_carrier_off(dev); |
@@ -345,13 +345,13 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p) | |||
345 | if (!(dev->flags & IFF_UP)) | 345 | if (!(dev->flags & IFF_UP)) |
346 | goto out; | 346 | goto out; |
347 | 347 | ||
348 | if (compare_ether_addr(addr->sa_data, real_dev->dev_addr)) { | 348 | if (!ether_addr_equal(addr->sa_data, real_dev->dev_addr)) { |
349 | err = dev_uc_add(real_dev, addr->sa_data); | 349 | err = dev_uc_add(real_dev, addr->sa_data); |
350 | if (err < 0) | 350 | if (err < 0) |
351 | return err; | 351 | return err; |
352 | } | 352 | } |
353 | 353 | ||
354 | if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr)) | 354 | if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr)) |
355 | dev_uc_del(real_dev, dev->dev_addr); | 355 | dev_uc_del(real_dev, dev->dev_addr); |
356 | 356 | ||
357 | out: | 357 | out: |