staging/wlan-ng: use ether_addr_equal_unaligned
PATCH 1/1 staging/wlan-ng: use ether_addr_equal_unaligned
This patch get rid of all memcmp() on ethernet addresses in wlan-ng. Replaced with ether_addr_equal_unaligned().
--- drivers/staging/wlan-ng/p80211conv.c | 6 +++--- drivers/staging/wlan-ng/prism2sta.c | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-)
drivers/staging/wlan-ng/p80211conv.c +3 -3
@@ -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 */
drivers/staging/wlan-ng/prism2sta.c +9 -7
@@ -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) {
Signature · 1 line
1.9.0
Quoted 2 lines · Denis Pithon
This patch get rid of all
memcmp()on ethernet addresses in wlan-ng. Replaced withether_addr_equal_unaligned().
ether_addr_equal_unaligned is only useful for
code symmetry when some uses are known to beether_addr_equal.
At least one of these conversions could/should beether_addr_equal.
Have you checked or did you just do a global
s/memcpy/ether_addr_equal_unaligned/ ?
drivers/staging/wlan-ng/prism2sta.c
Quoted 1 line
drivers/staging/wlan-ng/prism2sta.c +0
-0
[]
drivers/staging/wlan-ng/prism2sta.c static void prism2sta_inf_assocstatus(wlandevice_t *wlandev, · line 1510
Quoted 7 lines
drivers/staging/wlan-ng/prism2sta.c +2
-1@@ -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]))
I looked at this one, both are __aligned(2)
I didn't look at any others.