Skip to contentSkip to conversation

staging: prism2sta: Replace memcpy with ether_add_copy

PATCH Superseded Ioana Ciornei 2 participants 2 messages Mar 17, 2015 – Mar 18, 2015 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: prism2sta: Replace memcpy with ether_add_copy

Replace memcpy() with ether_addr_copy() since addresses are __aligned(2). The 2 structures are aligned to u16:

typedef struct hfa384x_authenticateStation_data {
	u8 address[ETH_ALEN];				/* 0	6 */
	u16 status;					/* 6	2 */
	u16 algorithm;					/* 8	2 */
} __packed hfa384x_authenticateStation_data_t;

Total size: 10

typedef struct hfa384x_AuthRequest {
	u8 sta_addr[ETH_ALEN];				/* 0	6 */
	u16 algorithm;					/* 6	2 */
} __packed hfa384x_AuthReq_t;

Total size: 8

---

Changes in v2:
- added 'linux/etherdevice.h'
- add explanations on why the addresses are u16 aligned

 drivers/staging/wlan-ng/prism2sta.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/staging/wlan-ng/prism2sta.c +5 -3
index 854571f..1eb2e58 100644
@@ -59,6 +59,8 @@
 #include <linux/netdevice.h>
 #include <linux/workqueue.h>
 #include <linux/byteorder/generic.h>
+#include <linux/etherdevice.h>
+
 
 #include <linux/io.h>
 #include <linux/delay.h>
@@ -1544,7 +1546,7 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
 	 ** authentication.
 	 */
 
-	memcpy(rec.address, inf->info.authreq.sta_addr, ETH_ALEN);
+	ether_addr_copy(rec.address, inf->info.authreq.sta_addr);
 	rec.status = P80211ENUM_status_unspec_failure;
 
 	/*
@@ -1657,8 +1659,8 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
 			if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
 				rec.status = P80211ENUM_status_ap_full;
 			} else {
-				memcpy(hw->authlist.addr[hw->authlist.cnt],
-				       rec.address, ETH_ALEN);
+				ether_addr_copy(hw->authlist.addr[hw->authlist.cnt],
+						rec.address);
 				hw->authlist.cnt++;
 				added = 1;
 			}
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 33 lines · Ioana Ciornei

Replace memcpy() with ether_addr_copy() since addresses are __aligned(2). The 2 structures are aligned to u16:

typedef struct hfa384x_authenticateStation_data {
	u8 address[ETH_ALEN];				/* 0	6 */
	u16 status;					/* 6	2 */
	u16 algorithm;					/* 8	2 */
} __packed hfa384x_authenticateStation_data_t;

Total size: 10

typedef struct hfa384x_AuthRequest {
	u8 sta_addr[ETH_ALEN];				/* 0	6 */
	u16 algorithm;					/* 6	2 */
} __packed hfa384x_AuthReq_t;

Total size: 8

---

Changes in v2:
- added 'linux/etherdevice.h'
- add explanations on why the addresses are u16 aligned

 drivers/staging/wlan-ng/prism2sta.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/staging/wlan-ng/prism2sta.c +0 -0
index 854571f..1eb2e58 100644

drivers/staging/wlan-ng/prism2sta.c line 64

Quoted 6 lines
drivers/staging/wlan-ng/prism2sta.c +2 -0
@@ -59,6 +59,8 @@
 #include <linux/netdevice.h>
 #include <linux/workqueue.h>
 #include <linux/byteorder/generic.h>
+#include <linux/etherdevice.h>
+
 

Why include yet another blank line here?

Please don't.