diff options
author | Joe Perches <joe@perches.com> | 2012-05-08 14:56:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-05-09 20:49:18 -0400 |
commit | b203ca39126bad99583c908be587df067820a1ea (patch) | |
tree | 940e32bd15392b400cf50c2ac31c7895637c09fe /net/mac80211/mlme.c | |
parent | c47fc9814ca15cc075f1f09e8c069b041f2ea397 (diff) |
mac80211: 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/mac80211/mlme.c')
-rw-r--r-- | net/mac80211/mlme.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 03f93f958fa4..b1c617fdabd6 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -1776,7 +1776,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, | |||
1776 | 1776 | ||
1777 | memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); | 1777 | memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); |
1778 | 1778 | ||
1779 | if (compare_ether_addr(bssid, mgmt->bssid)) | 1779 | if (!ether_addr_equal(bssid, mgmt->bssid)) |
1780 | return RX_MGMT_NONE; | 1780 | return RX_MGMT_NONE; |
1781 | 1781 | ||
1782 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); | 1782 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); |
@@ -1853,7 +1853,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, | |||
1853 | return RX_MGMT_NONE; | 1853 | return RX_MGMT_NONE; |
1854 | 1854 | ||
1855 | if (!ifmgd->associated || | 1855 | if (!ifmgd->associated || |
1856 | compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid)) | 1856 | !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) |
1857 | return RX_MGMT_NONE; | 1857 | return RX_MGMT_NONE; |
1858 | 1858 | ||
1859 | bssid = ifmgd->associated->bssid; | 1859 | bssid = ifmgd->associated->bssid; |
@@ -1886,7 +1886,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1886 | return RX_MGMT_NONE; | 1886 | return RX_MGMT_NONE; |
1887 | 1887 | ||
1888 | if (!ifmgd->associated || | 1888 | if (!ifmgd->associated || |
1889 | compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid)) | 1889 | !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) |
1890 | return RX_MGMT_NONE; | 1890 | return RX_MGMT_NONE; |
1891 | 1891 | ||
1892 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); | 1892 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); |
@@ -2113,7 +2113,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2113 | 2113 | ||
2114 | if (!assoc_data) | 2114 | if (!assoc_data) |
2115 | return RX_MGMT_NONE; | 2115 | return RX_MGMT_NONE; |
2116 | if (compare_ether_addr(assoc_data->bss->bssid, mgmt->bssid)) | 2116 | if (!ether_addr_equal(assoc_data->bss->bssid, mgmt->bssid)) |
2117 | return RX_MGMT_NONE; | 2117 | return RX_MGMT_NONE; |
2118 | 2118 | ||
2119 | /* | 2119 | /* |
@@ -2193,8 +2193,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
2193 | bool need_ps = false; | 2193 | bool need_ps = false; |
2194 | 2194 | ||
2195 | if (sdata->u.mgd.associated && | 2195 | if (sdata->u.mgd.associated && |
2196 | compare_ether_addr(mgmt->bssid, sdata->u.mgd.associated->bssid) | 2196 | ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid)) { |
2197 | == 0) { | ||
2198 | bss = (void *)sdata->u.mgd.associated->priv; | 2197 | bss = (void *)sdata->u.mgd.associated->priv; |
2199 | /* not previously set so we may need to recalc */ | 2198 | /* not previously set so we may need to recalc */ |
2200 | need_ps = !bss->dtim_period; | 2199 | need_ps = !bss->dtim_period; |
@@ -2249,7 +2248,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, | |||
2249 | 2248 | ||
2250 | ASSERT_MGD_MTX(ifmgd); | 2249 | ASSERT_MGD_MTX(ifmgd); |
2251 | 2250 | ||
2252 | if (compare_ether_addr(mgmt->da, sdata->vif.addr)) | 2251 | if (!ether_addr_equal(mgmt->da, sdata->vif.addr)) |
2253 | return; /* ignore ProbeResp to foreign address */ | 2252 | return; /* ignore ProbeResp to foreign address */ |
2254 | 2253 | ||
2255 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; | 2254 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; |
@@ -2262,12 +2261,11 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, | |||
2262 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); | 2261 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); |
2263 | 2262 | ||
2264 | if (ifmgd->associated && | 2263 | if (ifmgd->associated && |
2265 | compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid) == 0) | 2264 | ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) |
2266 | ieee80211_reset_ap_probe(sdata); | 2265 | ieee80211_reset_ap_probe(sdata); |
2267 | 2266 | ||
2268 | if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies && | 2267 | if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies && |
2269 | compare_ether_addr(mgmt->bssid, ifmgd->auth_data->bss->bssid) | 2268 | ether_addr_equal(mgmt->bssid, ifmgd->auth_data->bss->bssid)) { |
2270 | == 0) { | ||
2271 | /* got probe response, continue with auth */ | 2269 | /* got probe response, continue with auth */ |
2272 | printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name); | 2270 | printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name); |
2273 | ifmgd->auth_data->tries = 0; | 2271 | ifmgd->auth_data->tries = 0; |
@@ -2324,8 +2322,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2324 | return; | 2322 | return; |
2325 | 2323 | ||
2326 | if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && | 2324 | if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && |
2327 | compare_ether_addr(mgmt->bssid, ifmgd->assoc_data->bss->bssid) | 2325 | ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { |
2328 | == 0) { | ||
2329 | ieee802_11_parse_elems(mgmt->u.beacon.variable, | 2326 | ieee802_11_parse_elems(mgmt->u.beacon.variable, |
2330 | len - baselen, &elems); | 2327 | len - baselen, &elems); |
2331 | 2328 | ||
@@ -2340,7 +2337,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2340 | } | 2337 | } |
2341 | 2338 | ||
2342 | if (!ifmgd->associated || | 2339 | if (!ifmgd->associated || |
2343 | compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid)) | 2340 | !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) |
2344 | return; | 2341 | return; |
2345 | bssid = ifmgd->associated->bssid; | 2342 | bssid = ifmgd->associated->bssid; |
2346 | 2343 | ||
@@ -3166,7 +3163,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, | |||
3166 | return err; | 3163 | return err; |
3167 | } | 3164 | } |
3168 | } else | 3165 | } else |
3169 | WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, cbss->bssid)); | 3166 | WARN_ON_ONCE(!ether_addr_equal(ifmgd->bssid, cbss->bssid)); |
3170 | 3167 | ||
3171 | return 0; | 3168 | return 0; |
3172 | } | 3169 | } |
@@ -3306,7 +3303,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, | |||
3306 | bool match; | 3303 | bool match; |
3307 | 3304 | ||
3308 | /* keep sta info, bssid if matching */ | 3305 | /* keep sta info, bssid if matching */ |
3309 | match = compare_ether_addr(ifmgd->bssid, req->bss->bssid) == 0; | 3306 | match = ether_addr_equal(ifmgd->bssid, req->bss->bssid); |
3310 | ieee80211_destroy_auth_data(sdata, match); | 3307 | ieee80211_destroy_auth_data(sdata, match); |
3311 | } | 3308 | } |
3312 | 3309 | ||
@@ -3466,7 +3463,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, | |||
3466 | sdata->name, req->bssid, req->reason_code); | 3463 | sdata->name, req->bssid, req->reason_code); |
3467 | 3464 | ||
3468 | if (ifmgd->associated && | 3465 | if (ifmgd->associated && |
3469 | compare_ether_addr(ifmgd->associated->bssid, req->bssid) == 0) | 3466 | ether_addr_equal(ifmgd->associated->bssid, req->bssid)) |
3470 | ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, | 3467 | ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, |
3471 | req->reason_code, true, frame_buf); | 3468 | req->reason_code, true, frame_buf); |
3472 | else | 3469 | else |