drivers/net: Convert uses of compare_ether_addr to ether_addr_equal
authorJoe Perches <joe@perches.com>
Sun, 1 Sep 2013 18:51:23 +0000 (11:51 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 4 Sep 2013 02:28:04 +0000 (22:28 -0400)
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 <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
drivers/net/ethernet/tile/tilegx.c
drivers/net/usb/qmi_wwan.c
drivers/net/vxlan.c
drivers/net/wireless/ath/carl9170/rx.c
drivers/net/wireless/rt2x00/rt2x00dev.c
drivers/net/wireless/rtlwifi/base.c
drivers/net/wireless/rtlwifi/ps.c
drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
drivers/net/wireless/rtlwifi/rtl8723ae/trx.c

index 1f5166ad6bb514ade1ee4fd906c1e47385bf5b6a..59a62bbfb3714a55683bec8fcb49e9adcb5cb279 100644 (file)
@@ -488,8 +488,8 @@ static bool ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
                 * source pruning.
                 */
                if ((skb->pkt_type & (PACKET_BROADCAST | PACKET_MULTICAST)) &&
-                   !(compare_ether_addr(adapter->netdev->dev_addr,
-                                       eth_hdr(skb)->h_source))) {
+                   ether_addr_equal(adapter->netdev->dev_addr,
+                                    eth_hdr(skb)->h_source)) {
                        dev_kfree_skb_irq(skb);
                        goto next_desc;
                }
index a9bc651e9ffa6c3e47ab3e7d9bdd4594fc83f684..330d9a8774ad69a1d6d8e4d4f38aa87e243bf699 100644 (file)
@@ -1652,14 +1652,14 @@ int qlcnic_sriov_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
        if (!is_valid_ether_addr(mac) || vf >= num_vfs)
                return -EINVAL;
 
-       if (!compare_ether_addr(adapter->mac_addr, mac)) {
+       if (ether_addr_equal(adapter->mac_addr, mac)) {
                netdev_err(netdev, "MAC address is already in use by the PF\n");
                return -EINVAL;
        }
 
        for (i = 0; i < num_vfs; i++) {
                vf_info = &sriov->vf_info[i];
-               if (!compare_ether_addr(vf_info->vp->mac, mac)) {
+               if (ether_addr_equal(vf_info->vp->mac, mac)) {
                        netdev_err(netdev,
                                   "MAC address is already in use by VF %d\n",
                                   i);
index 5d2a719fc68824c3b77ee5519406f4f9df31d42f..949076f4e6ae180ae78f83b68973b8486b4087bd 100644 (file)
@@ -544,7 +544,7 @@ static inline bool filter_packet(struct net_device *dev, void *buf)
        /* Filter out packets that aren't for us. */
        if (!(dev->flags & IFF_PROMISC) &&
            !is_multicast_ether_addr(buf) &&
-           compare_ether_addr(dev->dev_addr, buf) != 0)
+           !ether_addr_equal(dev->dev_addr, buf))
                return true;
 
        return false;
index 606eba2872bd5ede94e19d50ff0a5725545009e1..3a8131582e753074c5fa0e3b9df2cab76f0face6 100644 (file)
@@ -323,7 +323,7 @@ next_desc:
        /* Never use the same address on both ends of the link, even
         * if the buggy firmware told us to.
         */
-       if (!compare_ether_addr(dev->net->dev_addr, default_modem_addr))
+       if (ether_addr_equal(dev->net->dev_addr, default_modem_addr))
                eth_hw_addr_random(dev->net);
 
        /* make MAC addr easily distinguishable from an IP header */
index 6b560f373fc373db6fedaba728e2f10095cd3296..8f6d6c1153ce39a51c9a444a2b7e9976733c6e42 100644 (file)
@@ -478,7 +478,7 @@ static struct vxlan_fdb *__vxlan_find_mac(struct vxlan_dev *vxlan,
        struct vxlan_fdb *f;
 
        hlist_for_each_entry_rcu(f, head, hlist) {
-               if (compare_ether_addr(mac, f->eth_addr) == 0)
+               if (ether_addr_equal(mac, f->eth_addr))
                        return f;
        }
 
@@ -1049,8 +1049,7 @@ static void vxlan_rcv(struct vxlan_sock *vs,
        skb->protocol = eth_type_trans(skb, vxlan->dev);
 
        /* Ignore packet loops (and multicast echo) */
-       if (compare_ether_addr(eth_hdr(skb)->h_source,
-                              vxlan->dev->dev_addr) == 0)
+       if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr))
                goto drop;
 
        /* Re-examine inner Ethernet packet */
@@ -1320,7 +1319,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
        if (n) {
                bool diff;
 
-               diff = compare_ether_addr(eth_hdr(skb)->h_dest, n->ha) != 0;
+               diff = !ether_addr_equal(eth_hdr(skb)->h_dest, n->ha);
                if (diff) {
                        memcpy(eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
                                dev->addr_len);
index 4684dd9894961a84dca6cf0f8abe099b6eb8fe92..e935f61c7fad1b8ea60cfbaad45affe081611222 100644 (file)
@@ -602,8 +602,8 @@ static void carl9170_ba_check(struct ar9170 *ar, void *data, unsigned int len)
 
                if (bar->start_seq_num == entry_bar->start_seq_num &&
                    TID_CHECK(bar->control, entry_bar->control) &&
-                   compare_ether_addr(bar->ra, entry_bar->ta) == 0 &&
-                   compare_ether_addr(bar->ta, entry_bar->ra) == 0) {
+                   ether_addr_equal(bar->ra, entry_bar->ta) &&
+                   ether_addr_equal(bar->ta, entry_bar->ra)) {
                        struct ieee80211_tx_info *tx_info;
 
                        tx_info = IEEE80211_SKB_CB(entry_skb);
index b16521e6bf4a1250ccbef85f580e08c334faf0d7..712eea9d398ffa747a1c76ebfd0da0ad84ed8854 100644 (file)
@@ -566,10 +566,10 @@ static void rt2x00lib_rxdone_check_ba(struct rt2x00_dev *rt2x00dev,
 
 #undef TID_CHECK
 
-               if (compare_ether_addr(ba->ra, entry->ta))
+               if (!ether_addr_equal(ba->ra, entry->ta))
                        continue;
 
-               if (compare_ether_addr(ba->ta, entry->ra))
+               if (!ether_addr_equal(ba->ta, entry->ra))
                        continue;
 
                /* Mark BAR since we received the according BA */
index 7651f5acc14bcccdc179fc09450af258f9d30e23..8bb4a9a01a1838e47d0d64b844503726999f3ff9 100644 (file)
@@ -1304,7 +1304,7 @@ void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb)
                return;
 
        /* and only beacons from the associated BSSID, please */
-       if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
+       if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
                return;
 
        rtlpriv->link_info.bcn_rx_inperiod++;
index f646b7585d9bf99ae35d8c7196d4e9f14c198438..0d81f766fd0f9e27b6b60478ceae71d9629bfa9a 100644 (file)
@@ -923,7 +923,7 @@ void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len)
                return;
 
        /* and only beacons from the associated BSSID, please */
-       if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
+       if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
                return;
 
        /* check if this really is a beacon */
index a8871d66d56a25ed5bc5b68026be3850acafe65c..68685a8982574e3e6b88c94379d00e4518a02601 100644 (file)
@@ -305,13 +305,14 @@ static void _rtl88ee_translate_rx_signal_stuff(struct ieee80211_hw *hw,
        psaddr = ieee80211_get_SA(hdr);
        memcpy(pstatus->psaddr, psaddr, ETH_ALEN);
 
-       addr = (!compare_ether_addr(mac->bssid, (ufc & IEEE80211_FCTL_TODS) ?
-               hdr->addr1 : (ufc & IEEE80211_FCTL_FROMDS) ?
-               hdr->addr2 : hdr->addr3));
+       addr = ether_addr_equal(mac->bssid,
+                               (ufc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+                               (ufc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+                               hdr->addr3);
        match_bssid = ((IEEE80211_FTYPE_CTL != type) && (!pstatus->hwerror) &&
                       (!pstatus->crc) && (!pstatus->icv)) && addr;
 
-       addr = (!compare_ether_addr(praddr, rtlefuse->dev_addr));
+       addr = ether_addr_equal(praddr, rtlefuse->dev_addr);
        packet_toself = match_bssid && addr;
 
        if (ieee80211_is_beacon(fc))
index c72758d8f4edc682a777950154c1025978fb31f8..bcd82a1020a5bebd7104467594ffefc47bf28eba 100644 (file)
@@ -255,16 +255,16 @@ static void _rtl8723ae_translate_rx_signal_stuff(struct ieee80211_hw *hw,
        type = WLAN_FC_GET_TYPE(fc);
        praddr = hdr->addr1;
 
-       packet_matchbssid = ((IEEE80211_FTYPE_CTL != type) &&
-                           (!compare_ether_addr(mac->bssid,
-                           (le16_to_cpu(fc) & IEEE80211_FCTL_TODS) ?
-                           hdr->addr1 : (le16_to_cpu(fc) &
-                           IEEE80211_FCTL_FROMDS) ?
-                           hdr->addr2 : hdr->addr3)) && (!pstatus->hwerror) &&
-                           (!pstatus->crc) && (!pstatus->icv));
-
-       packet_toself = packet_matchbssid &&
-           (!compare_ether_addr(praddr, rtlefuse->dev_addr));
+       packet_matchbssid =
+               ((IEEE80211_FTYPE_CTL != type) &&
+                ether_addr_equal(mac->bssid,
+                                 (le16_to_cpu(fc) & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+                                 (le16_to_cpu(fc) & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+                                 hdr->addr3) &&
+                (!pstatus->hwerror) && (!pstatus->crc) && (!pstatus->icv));
+
+       packet_toself = (packet_matchbssid &&
+                        ether_addr_equal(praddr, rtlefuse->dev_addr));
 
        if (ieee80211_is_beacon(fc))
                packet_beacon = true;