Skip to content

Commit 7367d0b

Browse files
JoePerchesdavem330
authored andcommitted
drivers/net: Convert uses of 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: (and a little typing) $ 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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c9b3745 commit 7367d0b

File tree

11 files changed

+30
-30
lines changed

11 files changed

+30
-30
lines changed

drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ static bool ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
488488
* source pruning.
489489
*/
490490
if ((skb->pkt_type & (PACKET_BROADCAST | PACKET_MULTICAST)) &&
491-
!(compare_ether_addr(adapter->netdev->dev_addr,
492-
eth_hdr(skb)->h_source))) {
491+
ether_addr_equal(adapter->netdev->dev_addr,
492+
eth_hdr(skb)->h_source)) {
493493
dev_kfree_skb_irq(skb);
494494
goto next_desc;
495495
}

drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,14 +1652,14 @@ int qlcnic_sriov_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
16521652
if (!is_valid_ether_addr(mac) || vf >= num_vfs)
16531653
return -EINVAL;
16541654

1655-
if (!compare_ether_addr(adapter->mac_addr, mac)) {
1655+
if (ether_addr_equal(adapter->mac_addr, mac)) {
16561656
netdev_err(netdev, "MAC address is already in use by the PF\n");
16571657
return -EINVAL;
16581658
}
16591659

16601660
for (i = 0; i < num_vfs; i++) {
16611661
vf_info = &sriov->vf_info[i];
1662-
if (!compare_ether_addr(vf_info->vp->mac, mac)) {
1662+
if (ether_addr_equal(vf_info->vp->mac, mac)) {
16631663
netdev_err(netdev,
16641664
"MAC address is already in use by VF %d\n",
16651665
i);

drivers/net/ethernet/tile/tilegx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static inline bool filter_packet(struct net_device *dev, void *buf)
544544
/* Filter out packets that aren't for us. */
545545
if (!(dev->flags & IFF_PROMISC) &&
546546
!is_multicast_ether_addr(buf) &&
547-
compare_ether_addr(dev->dev_addr, buf) != 0)
547+
!ether_addr_equal(dev->dev_addr, buf))
548548
return true;
549549

550550
return false;

drivers/net/usb/qmi_wwan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
323323
/* Never use the same address on both ends of the link, even
324324
* if the buggy firmware told us to.
325325
*/
326-
if (!compare_ether_addr(dev->net->dev_addr, default_modem_addr))
326+
if (ether_addr_equal(dev->net->dev_addr, default_modem_addr))
327327
eth_hw_addr_random(dev->net);
328328

329329
/* make MAC addr easily distinguishable from an IP header */

drivers/net/vxlan.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static struct vxlan_fdb *__vxlan_find_mac(struct vxlan_dev *vxlan,
478478
struct vxlan_fdb *f;
479479

480480
hlist_for_each_entry_rcu(f, head, hlist) {
481-
if (compare_ether_addr(mac, f->eth_addr) == 0)
481+
if (ether_addr_equal(mac, f->eth_addr))
482482
return f;
483483
}
484484

@@ -1049,8 +1049,7 @@ static void vxlan_rcv(struct vxlan_sock *vs,
10491049
skb->protocol = eth_type_trans(skb, vxlan->dev);
10501050

10511051
/* Ignore packet loops (and multicast echo) */
1052-
if (compare_ether_addr(eth_hdr(skb)->h_source,
1053-
vxlan->dev->dev_addr) == 0)
1052+
if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr))
10541053
goto drop;
10551054

10561055
/* Re-examine inner Ethernet packet */
@@ -1320,7 +1319,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
13201319
if (n) {
13211320
bool diff;
13221321

1323-
diff = compare_ether_addr(eth_hdr(skb)->h_dest, n->ha) != 0;
1322+
diff = !ether_addr_equal(eth_hdr(skb)->h_dest, n->ha);
13241323
if (diff) {
13251324
memcpy(eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
13261325
dev->addr_len);

drivers/net/wireless/ath/carl9170/rx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ static void carl9170_ba_check(struct ar9170 *ar, void *data, unsigned int len)
602602

603603
if (bar->start_seq_num == entry_bar->start_seq_num &&
604604
TID_CHECK(bar->control, entry_bar->control) &&
605-
compare_ether_addr(bar->ra, entry_bar->ta) == 0 &&
606-
compare_ether_addr(bar->ta, entry_bar->ra) == 0) {
605+
ether_addr_equal(bar->ra, entry_bar->ta) &&
606+
ether_addr_equal(bar->ta, entry_bar->ra)) {
607607
struct ieee80211_tx_info *tx_info;
608608

609609
tx_info = IEEE80211_SKB_CB(entry_skb);

drivers/net/wireless/rt2x00/rt2x00dev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,10 +566,10 @@ static void rt2x00lib_rxdone_check_ba(struct rt2x00_dev *rt2x00dev,
566566

567567
#undef TID_CHECK
568568

569-
if (compare_ether_addr(ba->ra, entry->ta))
569+
if (!ether_addr_equal(ba->ra, entry->ta))
570570
continue;
571571

572-
if (compare_ether_addr(ba->ta, entry->ra))
572+
if (!ether_addr_equal(ba->ta, entry->ra))
573573
continue;
574574

575575
/* Mark BAR since we received the according BA */

drivers/net/wireless/rtlwifi/base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb)
13041304
return;
13051305

13061306
/* and only beacons from the associated BSSID, please */
1307-
if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
1307+
if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
13081308
return;
13091309

13101310
rtlpriv->link_info.bcn_rx_inperiod++;

drivers/net/wireless/rtlwifi/ps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len)
923923
return;
924924

925925
/* and only beacons from the associated BSSID, please */
926-
if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
926+
if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
927927
return;
928928

929929
/* check if this really is a beacon */

drivers/net/wireless/rtlwifi/rtl8188ee/trx.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,14 @@ static void _rtl88ee_translate_rx_signal_stuff(struct ieee80211_hw *hw,
305305
psaddr = ieee80211_get_SA(hdr);
306306
memcpy(pstatus->psaddr, psaddr, ETH_ALEN);
307307

308-
addr = (!compare_ether_addr(mac->bssid, (ufc & IEEE80211_FCTL_TODS) ?
309-
hdr->addr1 : (ufc & IEEE80211_FCTL_FROMDS) ?
310-
hdr->addr2 : hdr->addr3));
308+
addr = ether_addr_equal(mac->bssid,
309+
(ufc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
310+
(ufc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
311+
hdr->addr3);
311312
match_bssid = ((IEEE80211_FTYPE_CTL != type) && (!pstatus->hwerror) &&
312313
(!pstatus->crc) && (!pstatus->icv)) && addr;
313314

314-
addr = (!compare_ether_addr(praddr, rtlefuse->dev_addr));
315+
addr = ether_addr_equal(praddr, rtlefuse->dev_addr);
315316
packet_toself = match_bssid && addr;
316317

317318
if (ieee80211_is_beacon(fc))

0 commit comments

Comments
 (0)