aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-05-08 14:56:55 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-09 20:49:19 -0400
commitac422d3cc25351819ec80b7e2852fd2c600c317c (patch)
treea6ca456ad41256bf2cee71a189c1c05027f16532 /net/wireless
parent8561cf99785faf73cccb9f417170d8b5844bf496 (diff)
wireless: 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. I removed a conversion from scan.c/cmp_bss_core that appears to be a sorting function. 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/wireless')
-rw-r--r--net/wireless/ibss.c2
-rw-r--r--net/wireless/mlme.c31
-rw-r--r--net/wireless/scan.c2
-rw-r--r--net/wireless/util.c5
-rw-r--r--net/wireless/wext-sme.c2
-rw-r--r--net/wireless/wext-spy.c2
6 files changed, 21 insertions, 23 deletions
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c
index 30f20fe4a5fe..d2a19b0ff71f 100644
--- a/net/wireless/ibss.c
+++ b/net/wireless/ibss.c
@@ -473,7 +473,7 @@ int cfg80211_ibss_wext_siwap(struct net_device *dev,
473 473
474 /* fixed already - and no change */ 474 /* fixed already - and no change */
475 if (wdev->wext.ibss.bssid && bssid && 475 if (wdev->wext.ibss.bssid && bssid &&
476 compare_ether_addr(bssid, wdev->wext.ibss.bssid) == 0) 476 ether_addr_equal(bssid, wdev->wext.ibss.bssid))
477 return 0; 477 return 0;
478 478
479 wdev_lock(wdev); 479 wdev_lock(wdev);
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 6801d96bc224..eb90988bbd36 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -101,7 +101,7 @@ void __cfg80211_send_deauth(struct net_device *dev,
101 ASSERT_WDEV_LOCK(wdev); 101 ASSERT_WDEV_LOCK(wdev);
102 102
103 if (wdev->current_bss && 103 if (wdev->current_bss &&
104 compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) { 104 ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) {
105 cfg80211_unhold_bss(wdev->current_bss); 105 cfg80211_unhold_bss(wdev->current_bss);
106 cfg80211_put_bss(&wdev->current_bss->pub); 106 cfg80211_put_bss(&wdev->current_bss->pub);
107 wdev->current_bss = NULL; 107 wdev->current_bss = NULL;
@@ -116,7 +116,7 @@ void __cfg80211_send_deauth(struct net_device *dev,
116 116
117 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); 117 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
118 118
119 from_ap = compare_ether_addr(mgmt->sa, dev->dev_addr) != 0; 119 from_ap = !ether_addr_equal(mgmt->sa, dev->dev_addr);
120 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); 120 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
121 } else if (wdev->sme_state == CFG80211_SME_CONNECTING) { 121 } else if (wdev->sme_state == CFG80211_SME_CONNECTING) {
122 __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0, 122 __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0,
@@ -155,7 +155,7 @@ void __cfg80211_send_disassoc(struct net_device *dev,
155 return; 155 return;
156 156
157 if (wdev->current_bss && 157 if (wdev->current_bss &&
158 compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) { 158 ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) {
159 cfg80211_sme_disassoc(dev, wdev->current_bss); 159 cfg80211_sme_disassoc(dev, wdev->current_bss);
160 cfg80211_unhold_bss(wdev->current_bss); 160 cfg80211_unhold_bss(wdev->current_bss);
161 cfg80211_put_bss(&wdev->current_bss->pub); 161 cfg80211_put_bss(&wdev->current_bss->pub);
@@ -166,7 +166,7 @@ void __cfg80211_send_disassoc(struct net_device *dev,
166 166
167 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); 167 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
168 168
169 from_ap = compare_ether_addr(mgmt->sa, dev->dev_addr) != 0; 169 from_ap = !ether_addr_equal(mgmt->sa, dev->dev_addr);
170 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); 170 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
171} 171}
172EXPORT_SYMBOL(__cfg80211_send_disassoc); 172EXPORT_SYMBOL(__cfg80211_send_disassoc);
@@ -286,7 +286,7 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
286 return -EINVAL; 286 return -EINVAL;
287 287
288 if (wdev->current_bss && 288 if (wdev->current_bss &&
289 compare_ether_addr(bssid, wdev->current_bss->pub.bssid) == 0) 289 ether_addr_equal(bssid, wdev->current_bss->pub.bssid))
290 return -EALREADY; 290 return -EALREADY;
291 291
292 memset(&req, 0, sizeof(req)); 292 memset(&req, 0, sizeof(req));
@@ -363,7 +363,7 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
363 memset(&req, 0, sizeof(req)); 363 memset(&req, 0, sizeof(req));
364 364
365 if (wdev->current_bss && prev_bssid && 365 if (wdev->current_bss && prev_bssid &&
366 compare_ether_addr(wdev->current_bss->pub.bssid, prev_bssid) == 0) { 366 ether_addr_equal(wdev->current_bss->pub.bssid, prev_bssid)) {
367 /* 367 /*
368 * Trying to reassociate: Allow this to proceed and let the old 368 * Trying to reassociate: Allow this to proceed and let the old
369 * association to be dropped when the new one is completed. 369 * association to be dropped when the new one is completed.
@@ -447,8 +447,7 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
447 447
448 if (local_state_change) { 448 if (local_state_change) {
449 if (wdev->current_bss && 449 if (wdev->current_bss &&
450 compare_ether_addr(wdev->current_bss->pub.bssid, bssid) 450 ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) {
451 == 0) {
452 cfg80211_unhold_bss(wdev->current_bss); 451 cfg80211_unhold_bss(wdev->current_bss);
453 cfg80211_put_bss(&wdev->current_bss->pub); 452 cfg80211_put_bss(&wdev->current_bss->pub);
454 wdev->current_bss = NULL; 453 wdev->current_bss = NULL;
@@ -497,7 +496,7 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
497 req.local_state_change = local_state_change; 496 req.local_state_change = local_state_change;
498 req.ie = ie; 497 req.ie = ie;
499 req.ie_len = ie_len; 498 req.ie_len = ie_len;
500 if (compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) 499 if (ether_addr_equal(wdev->current_bss->pub.bssid, bssid))
501 req.bss = &wdev->current_bss->pub; 500 req.bss = &wdev->current_bss->pub;
502 else 501 else
503 return -ENOTCONN; 502 return -ENOTCONN;
@@ -760,8 +759,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
760 break; 759 break;
761 } 760 }
762 761
763 if (compare_ether_addr(wdev->current_bss->pub.bssid, 762 if (!ether_addr_equal(wdev->current_bss->pub.bssid,
764 mgmt->bssid)) { 763 mgmt->bssid)) {
765 err = -ENOTCONN; 764 err = -ENOTCONN;
766 break; 765 break;
767 } 766 }
@@ -774,8 +773,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
774 break; 773 break;
775 774
776 /* for station, check that DA is the AP */ 775 /* for station, check that DA is the AP */
777 if (compare_ether_addr(wdev->current_bss->pub.bssid, 776 if (!ether_addr_equal(wdev->current_bss->pub.bssid,
778 mgmt->da)) { 777 mgmt->da)) {
779 err = -ENOTCONN; 778 err = -ENOTCONN;
780 break; 779 break;
781 } 780 }
@@ -783,11 +782,11 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
783 case NL80211_IFTYPE_AP: 782 case NL80211_IFTYPE_AP:
784 case NL80211_IFTYPE_P2P_GO: 783 case NL80211_IFTYPE_P2P_GO:
785 case NL80211_IFTYPE_AP_VLAN: 784 case NL80211_IFTYPE_AP_VLAN:
786 if (compare_ether_addr(mgmt->bssid, dev->dev_addr)) 785 if (!ether_addr_equal(mgmt->bssid, dev->dev_addr))
787 err = -EINVAL; 786 err = -EINVAL;
788 break; 787 break;
789 case NL80211_IFTYPE_MESH_POINT: 788 case NL80211_IFTYPE_MESH_POINT:
790 if (compare_ether_addr(mgmt->sa, mgmt->bssid)) { 789 if (!ether_addr_equal(mgmt->sa, mgmt->bssid)) {
791 err = -EINVAL; 790 err = -EINVAL;
792 break; 791 break;
793 } 792 }
@@ -806,7 +805,7 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
806 return err; 805 return err;
807 } 806 }
808 807
809 if (compare_ether_addr(mgmt->sa, dev->dev_addr) != 0) 808 if (!ether_addr_equal(mgmt->sa, dev->dev_addr))
810 return -EINVAL; 809 return -EINVAL;
811 810
812 /* Transmit the Action frame as requested by user space */ 811 /* Transmit the Action frame as requested by user space */
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 1442bb68a3f3..26d96d7ffba8 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -281,7 +281,7 @@ static bool is_bss(struct cfg80211_bss *a,
281{ 281{
282 const u8 *ssidie; 282 const u8 *ssidie;
283 283
284 if (bssid && compare_ether_addr(a->bssid, bssid)) 284 if (bssid && !ether_addr_equal(a->bssid, bssid))
285 return false; 285 return false;
286 286
287 if (!ssid) 287 if (!ssid)
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 6cba00173a2f..3ba366f51b07 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -609,10 +609,9 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
609 payload = frame->data; 609 payload = frame->data;
610 ethertype = (payload[6] << 8) | payload[7]; 610 ethertype = (payload[6] << 8) | payload[7];
611 611
612 if (likely((compare_ether_addr(payload, rfc1042_header) == 0 && 612 if (likely((ether_addr_equal(payload, rfc1042_header) &&
613 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || 613 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
614 compare_ether_addr(payload, 614 ether_addr_equal(payload, bridge_tunnel_header))) {
615 bridge_tunnel_header) == 0)) {
616 /* remove RFC1042 or Bridge-Tunnel 615 /* remove RFC1042 or Bridge-Tunnel
617 * encapsulation and replace EtherType */ 616 * encapsulation and replace EtherType */
618 skb_pull(frame, 6); 617 skb_pull(frame, 6);
diff --git a/net/wireless/wext-sme.c b/net/wireless/wext-sme.c
index 7c01c2f3b6cf..7decbd357d51 100644
--- a/net/wireless/wext-sme.c
+++ b/net/wireless/wext-sme.c
@@ -276,7 +276,7 @@ int cfg80211_mgd_wext_siwap(struct net_device *dev,
276 276
277 /* fixed already - and no change */ 277 /* fixed already - and no change */
278 if (wdev->wext.connect.bssid && bssid && 278 if (wdev->wext.connect.bssid && bssid &&
279 compare_ether_addr(bssid, wdev->wext.connect.bssid) == 0) 279 ether_addr_equal(bssid, wdev->wext.connect.bssid))
280 goto out; 280 goto out;
281 281
282 err = __cfg80211_disconnect(rdev, dev, 282 err = __cfg80211_disconnect(rdev, dev,
diff --git a/net/wireless/wext-spy.c b/net/wireless/wext-spy.c
index 5d643a548feb..33bef22e44e9 100644
--- a/net/wireless/wext-spy.c
+++ b/net/wireless/wext-spy.c
@@ -203,7 +203,7 @@ void wireless_spy_update(struct net_device * dev,
203 203
204 /* Update all records that match */ 204 /* Update all records that match */
205 for (i = 0; i < spydata->spy_number; i++) 205 for (i = 0; i < spydata->spy_number; i++)
206 if (!compare_ether_addr(address, spydata->spy_address[i])) { 206 if (ether_addr_equal(address, spydata->spy_address[i])) {
207 memcpy(&(spydata->spy_stat[i]), wstats, 207 memcpy(&(spydata->spy_stat[i]), wstats,
208 sizeof(struct iw_quality)); 208 sizeof(struct iw_quality));
209 match = i; 209 match = i;