Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net, drivers/net: Convert compare_ether_addr_64bits to ether_addr_equal_64bits

Use the new bool function ether_addr_equal_64bits to add
some clarity and reduce the likelihood for misuse of
compare_ether_addr_64bits for sorting.

Done via cocci script:

$ cat compare_ether_addr_64bits.cocci
@@
expression a,b;
@@
- !compare_ether_addr_64bits(a, b)
+ ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- compare_ether_addr_64bits(a, b)
+ !ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- !ether_addr_equal_64bits(a, b) == 0
+ ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- !ether_addr_equal_64bits(a, b) != 0
+ !ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- ether_addr_equal_64bits(a, b) == 0
+ !ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- ether_addr_equal_64bits(a, b) != 0
+ ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- !!ether_addr_equal_64bits(a, b)
+ ether_addr_equal_64bits(a, b)

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Joe Perches and committed by
David S. Miller
a6700db1 baf523c9

+35 -35
+29 -29
drivers/net/bonding/bond_alb.c
··· 332 332 if ((client_info->assigned) && 333 333 (client_info->ip_src == arp->ip_dst) && 334 334 (client_info->ip_dst == arp->ip_src) && 335 - (compare_ether_addr_64bits(client_info->mac_dst, arp->mac_src))) { 335 + (!ether_addr_equal_64bits(client_info->mac_dst, arp->mac_src))) { 336 336 /* update the clients MAC address */ 337 337 memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN); 338 338 client_info->ntt = 1; ··· 448 448 449 449 if (assigned_slave) { 450 450 rx_hash_table[index].slave = assigned_slave; 451 - if (compare_ether_addr_64bits(rx_hash_table[index].mac_dst, 452 - mac_bcast)) { 451 + if (!ether_addr_equal_64bits(rx_hash_table[index].mac_dst, 452 + mac_bcast)) { 453 453 bond_info->rx_hashtbl[index].ntt = 1; 454 454 bond_info->rx_ntt = 1; 455 455 /* A slave has been removed from the ··· 561 561 client_info = &(bond_info->rx_hashtbl[hash_index]); 562 562 563 563 if ((client_info->slave == slave) && 564 - compare_ether_addr_64bits(client_info->mac_dst, mac_bcast)) { 564 + !ether_addr_equal_64bits(client_info->mac_dst, mac_bcast)) { 565 565 client_info->ntt = 1; 566 566 ntt = 1; 567 567 } ··· 600 600 * unicast mac address. 601 601 */ 602 602 if ((client_info->ip_src == src_ip) && 603 - compare_ether_addr_64bits(client_info->slave->dev->dev_addr, 604 - bond->dev->dev_addr) && 605 - compare_ether_addr_64bits(client_info->mac_dst, mac_bcast)) { 603 + !ether_addr_equal_64bits(client_info->slave->dev->dev_addr, 604 + bond->dev->dev_addr) && 605 + !ether_addr_equal_64bits(client_info->mac_dst, mac_bcast)) { 606 606 client_info->ntt = 1; 607 607 bond_info->rx_ntt = 1; 608 608 } ··· 629 629 if ((client_info->ip_src == arp->ip_src) && 630 630 (client_info->ip_dst == arp->ip_dst)) { 631 631 /* the entry is already assigned to this client */ 632 - if (compare_ether_addr_64bits(arp->mac_dst, mac_bcast)) { 632 + if (!ether_addr_equal_64bits(arp->mac_dst, mac_bcast)) { 633 633 /* update mac address from arp */ 634 634 memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN); 635 635 } ··· 664 664 memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN); 665 665 client_info->slave = assigned_slave; 666 666 667 - if (compare_ether_addr_64bits(client_info->mac_dst, mac_bcast)) { 667 + if (!ether_addr_equal_64bits(client_info->mac_dst, mac_bcast)) { 668 668 client_info->ntt = 1; 669 669 bond->alb_info.rx_ntt = 1; 670 670 } else { ··· 1009 1009 int perm_curr_diff; 1010 1010 int perm_bond_diff; 1011 1011 1012 - perm_curr_diff = compare_ether_addr_64bits(slave->perm_hwaddr, 1013 - slave->dev->dev_addr); 1014 - perm_bond_diff = compare_ether_addr_64bits(slave->perm_hwaddr, 1015 - bond->dev->dev_addr); 1012 + perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, 1013 + slave->dev->dev_addr); 1014 + perm_bond_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, 1015 + bond->dev->dev_addr); 1016 1016 1017 1017 if (perm_curr_diff && perm_bond_diff) { 1018 1018 struct slave *tmp_slave; 1019 1019 int i, found = 0; 1020 1020 1021 1021 bond_for_each_slave(bond, tmp_slave, i) { 1022 - if (!compare_ether_addr_64bits(slave->perm_hwaddr, 1023 - tmp_slave->dev->dev_addr)) { 1022 + if (ether_addr_equal_64bits(slave->perm_hwaddr, 1023 + tmp_slave->dev->dev_addr)) { 1024 1024 found = 1; 1025 1025 break; 1026 1026 } ··· 1074 1074 * check uniqueness of slave's mac address against the other 1075 1075 * slaves in the bond. 1076 1076 */ 1077 - if (compare_ether_addr_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) { 1077 + if (!ether_addr_equal_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) { 1078 1078 bond_for_each_slave(bond, tmp_slave1, i) { 1079 - if (!compare_ether_addr_64bits(tmp_slave1->dev->dev_addr, 1080 - slave->dev->dev_addr)) { 1079 + if (ether_addr_equal_64bits(tmp_slave1->dev->dev_addr, 1080 + slave->dev->dev_addr)) { 1081 1081 found = 1; 1082 1082 break; 1083 1083 } ··· 1099 1099 bond_for_each_slave(bond, tmp_slave1, i) { 1100 1100 found = 0; 1101 1101 bond_for_each_slave(bond, tmp_slave2, j) { 1102 - if (!compare_ether_addr_64bits(tmp_slave1->perm_hwaddr, 1103 - tmp_slave2->dev->dev_addr)) { 1102 + if (ether_addr_equal_64bits(tmp_slave1->perm_hwaddr, 1103 + tmp_slave2->dev->dev_addr)) { 1104 1104 found = 1; 1105 1105 break; 1106 1106 } ··· 1115 1115 } 1116 1116 1117 1117 if (!has_bond_addr) { 1118 - if (!compare_ether_addr_64bits(tmp_slave1->dev->dev_addr, 1119 - bond->dev->dev_addr)) { 1118 + if (ether_addr_equal_64bits(tmp_slave1->dev->dev_addr, 1119 + bond->dev->dev_addr)) { 1120 1120 1121 1121 has_bond_addr = tmp_slave1; 1122 1122 } ··· 1257 1257 case ETH_P_IP: { 1258 1258 const struct iphdr *iph = ip_hdr(skb); 1259 1259 1260 - if (!compare_ether_addr_64bits(eth_data->h_dest, mac_bcast) || 1260 + if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast) || 1261 1261 (iph->daddr == ip_bcast) || 1262 1262 (iph->protocol == IPPROTO_IGMP)) { 1263 1263 do_tx_balance = 0; ··· 1271 1271 /* IPv6 doesn't really use broadcast mac address, but leave 1272 1272 * that here just in case. 1273 1273 */ 1274 - if (!compare_ether_addr_64bits(eth_data->h_dest, mac_bcast)) { 1274 + if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast)) { 1275 1275 do_tx_balance = 0; 1276 1276 break; 1277 1277 } ··· 1279 1279 /* IPv6 uses all-nodes multicast as an equivalent to 1280 1280 * broadcasts in IPv4. 1281 1281 */ 1282 - if (!compare_ether_addr_64bits(eth_data->h_dest, mac_v6_allmcast)) { 1282 + if (ether_addr_equal_64bits(eth_data->h_dest, mac_v6_allmcast)) { 1283 1283 do_tx_balance = 0; 1284 1284 break; 1285 1285 } ··· 1603 1603 struct slave *tmp_slave; 1604 1604 /* find slave that is holding the bond's mac address */ 1605 1605 bond_for_each_slave(bond, tmp_slave, i) { 1606 - if (!compare_ether_addr_64bits(tmp_slave->dev->dev_addr, 1607 - bond->dev->dev_addr)) { 1606 + if (ether_addr_equal_64bits(tmp_slave->dev->dev_addr, 1607 + bond->dev->dev_addr)) { 1608 1608 swap_slave = tmp_slave; 1609 1609 break; 1610 1610 } ··· 1681 1681 swap_slave = NULL; 1682 1682 1683 1683 bond_for_each_slave(bond, slave, i) { 1684 - if (!compare_ether_addr_64bits(slave->dev->dev_addr, 1685 - bond_dev->dev_addr)) { 1684 + if (ether_addr_equal_64bits(slave->dev->dev_addr, 1685 + bond_dev->dev_addr)) { 1686 1686 swap_slave = slave; 1687 1687 break; 1688 1688 }
+3 -4
drivers/net/macvlan.c
··· 57 57 struct hlist_node *n; 58 58 59 59 hlist_for_each_entry_rcu(vlan, n, &port->vlan_hash[addr[5]], hlist) { 60 - if (!compare_ether_addr_64bits(vlan->dev->dev_addr, addr)) 60 + if (ether_addr_equal_64bits(vlan->dev->dev_addr, addr)) 61 61 return vlan; 62 62 } 63 63 return NULL; ··· 96 96 * currently in use by the underlying device or 97 97 * another macvlan. 98 98 */ 99 - if (!compare_ether_addr_64bits(port->dev->dev_addr, addr)) 99 + if (ether_addr_equal_64bits(port->dev->dev_addr, addr)) 100 100 return 1; 101 101 102 102 if (macvlan_hash_lookup(port, addr)) ··· 118 118 return vlan->forward(dev, skb); 119 119 120 120 skb->dev = dev; 121 - if (!compare_ether_addr_64bits(eth->h_dest, 122 - dev->broadcast)) 121 + if (ether_addr_equal_64bits(eth->h_dest, dev->broadcast)) 123 122 skb->pkt_type = PACKET_BROADCAST; 124 123 else 125 124 skb->pkt_type = PACKET_MULTICAST;
+3 -2
net/ethernet/eth.c
··· 164 164 eth = eth_hdr(skb); 165 165 166 166 if (unlikely(is_multicast_ether_addr(eth->h_dest))) { 167 - if (!compare_ether_addr_64bits(eth->h_dest, dev->broadcast)) 167 + if (ether_addr_equal_64bits(eth->h_dest, dev->broadcast)) 168 168 skb->pkt_type = PACKET_BROADCAST; 169 169 else 170 170 skb->pkt_type = PACKET_MULTICAST; ··· 179 179 */ 180 180 181 181 else if (1 /*dev->flags&IFF_PROMISC */ ) { 182 - if (unlikely(compare_ether_addr_64bits(eth->h_dest, dev->dev_addr))) 182 + if (unlikely(!ether_addr_equal_64bits(eth->h_dest, 183 + dev->dev_addr))) 183 184 skb->pkt_type = PACKET_OTHERHOST; 184 185 } 185 186