[PATCH] staging/wlan-ng: use ether_addr_equal_unaligned

From: Denis Pithon
Date: Sun Jun 01 2014 - 03:25:24 EST


This patch get rid of all memcmp() on ethernet addresses in wlan-ng.
Replaced with ether_addr_equal_unaligned().

Signed-off-by: Denis Pithon <denis.pithon@xxxxxxxxx>
---
drivers/staging/wlan-ng/p80211conv.c | 6 +++---
drivers/staging/wlan-ng/prism2sta.c | 16 +++++++++-------
2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index 913676e..fb8a628 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -241,7 +241,7 @@ static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,

for (i = 0; i < wlandev->spy_number; i++) {

- if (!memcmp(wlandev->spy_address[i], mac, ETH_ALEN)) {
+ if (ether_addr_equal_unaligned(wlandev->spy_address[i], mac)) {
memcpy(wlandev->spy_address[i], mac, ETH_ALEN);
wlandev->spy_stat[i].level = rxmeta->signal;
wlandev->spy_stat[i].noise = rxmeta->noise;
@@ -359,8 +359,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
/* Test for the various encodings */
if ((payload_length >= sizeof(struct wlan_ethhdr)) &&
(e_llc->dsap != 0xaa || e_llc->ssap != 0xaa) &&
- ((memcmp(daddr, e_hdr->daddr, WLAN_ETHADDR_LEN) == 0) ||
- (memcmp(saddr, e_hdr->saddr, WLAN_ETHADDR_LEN) == 0))) {
+ (ether_addr_equal_unaligned(daddr, e_hdr->daddr) ||
+ ether_addr_equal_unaligned(saddr, e_hdr->saddr))) {
pr_debug("802.3 ENCAP len: %d\n", payload_length);
/* 802.3 Encapsulated */
/* Test for an overlength frame */
diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index 278b6a1..d2e492c 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -56,6 +56,7 @@
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/etherdevice.h>
#include <linux/wireless.h>
#include <linux/netdevice.h>
#include <linux/workqueue.h>
@@ -1505,7 +1506,8 @@ static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
*/

for (i = 0; i < hw->authlist.cnt; i++)
- if (memcmp(rec.sta_addr, hw->authlist.addr[i], ETH_ALEN) == 0)
+ if (ether_addr_equal_unaligned(rec.sta_addr,
+ hw->authlist.addr[i]))
break;

if (i >= hw->authlist.cnt) {
@@ -1587,8 +1589,8 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
*/

for (i = 0; i < hw->authlist.cnt; i++)
- if (memcmp(rec.address, hw->authlist.addr[i],
- ETH_ALEN) == 0) {
+ if (ether_addr_equal_unaligned(rec.address,
+ hw->authlist.addr[i])) {
rec.status = P80211ENUM_status_successful;
break;
}
@@ -1625,7 +1627,7 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
}

for (i = 0; i < cnt; i++, addr += ETH_ALEN)
- if (memcmp(rec.address, addr, ETH_ALEN) == 0) {
+ if (ether_addr_equal_unaligned(rec.address, addr)) {
rec.status = P80211ENUM_status_successful;
break;
}
@@ -1655,7 +1657,7 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
rec.status = P80211ENUM_status_successful;

for (i = 0; i < cnt; i++, addr += ETH_ALEN)
- if (memcmp(rec.address, addr, ETH_ALEN) == 0) {
+ if (ether_addr_equal_unaligned(rec.address, addr)) {
rec.status = P80211ENUM_status_unspec_failure;
break;
}
@@ -1676,8 +1678,8 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,

if (rec.status == P80211ENUM_status_successful) {
for (i = 0; i < hw->authlist.cnt; i++)
- if (memcmp(rec.address, hw->authlist.addr[i], ETH_ALEN)
- == 0)
+ if (ether_addr_equal_unaligned(rec.address,
+ hw->authlist.addr[i]))
break;

if (i >= hw->authlist.cnt) {
--
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/