staging: p80211conv: Replace memcpy with ether_addr_copy
PATCH v2 1/1 staging: p80211conv: Replace memcpy with ether_addr_copy
Replace memcpy() with ether_addr_copy() since addresses are __aligned(2). The 2 structures are aligned to u16:
struct p80211_hdr_a3 {
__le16 fc; /* 0 2 */
u16 dur; /* 2 2 */
u8 a1[ETH_ALEN]; /* 4 6 */
u8 a2[ETH_ALEN]; /* 10 6 */
u8 a3[ETH_ALEN]; /* 16 6 */
u16 seq; /* 22 2 */
} __packed;Total size: 24
struct wlan_ethhdr {
u8 daddr[WLAN_ETHADDR_LEN]; /* 0 6 */
u8 saddr[WLAN_ETHADDR_LEN]; /* 6 6 */
u16 type; /* 12 2 */
} __packed;Total size: 14
---
Changes in v2:
- added explanations on why the addresses are aligned
drivers/staging/wlan-ng/p80211conv.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/staging/wlan-ng/p80211conv.c +10 -10
@@ -62,6 +62,7 @@#include <linux/etherdevice.h> #include <linux/if_ether.h> #include <linux/byteorder/generic.h> #include <asm/byteorder.h>
@@ -178,21 +179,21 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,switch (wlandev->macmode) {case WLAN_MACMODE_IBSS_STA : -memcpy (p80211_hdr->a3.a1, &e_hdr.daddr,ETH_ALEN ); -memcpy (p80211_hdr->a3.a2, wlandev->netdev->dev_addr,ETH_ALEN ); -memcpy (p80211_hdr->a3.a3, wlandev->bssid,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a1, &e_hdr.daddr); +ether_addr_copy (p80211_hdr->a3.a2, wlandev->netdev->dev_addr); +ether_addr_copy (p80211_hdr->a3.a3, wlandev->bssid);break ;case WLAN_MACMODE_ESS_STA : fc |=cpu_to_le16 (WLAN_SET_FC_TODS (1 )); -memcpy (p80211_hdr->a3.a1, wlandev->bssid,ETH_ALEN ); -memcpy (p80211_hdr->a3.a2, wlandev->netdev->dev_addr,ETH_ALEN ); -memcpy (p80211_hdr->a3.a3, &e_hdr.daddr,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a1, wlandev->bssid); +ether_addr_copy (p80211_hdr->a3.a2, wlandev->netdev->dev_addr); +ether_addr_copy (p80211_hdr->a3.a3, &e_hdr.daddr);break ;case WLAN_MACMODE_ESS_AP : fc |=cpu_to_le16 (WLAN_SET_FC_FROMDS (1 )); -memcpy (p80211_hdr->a3.a1, &e_hdr.daddr,ETH_ALEN ); -memcpy (p80211_hdr->a3.a2, wlandev->bssid,ETH_ALEN ); -memcpy (p80211_hdr->a3.a3, &e_hdr.saddr,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a1, &e_hdr.daddr); +ether_addr_copy (p80211_hdr->a3.a2, wlandev->bssid); +ether_addr_copy (p80211_hdr->a3.a3, &e_hdr.saddr);break ;default : netdev_err(wlandev->netdev,
@@ -241,7 +242,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 )) { -memcpy (wlandev->spy_address[i], mac,ETH_ALEN ); +ether_addr_copy (wlandev->spy_address[i], mac); wlandev->spy_stat[i].level = rxmeta->signal; wlandev->spy_stat[i].noise = rxmeta->noise; wlandev->spy_stat[i].qual =
Signature · 1 line
1.9.1
Greg KH
maintainerdrivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
Quoted 43 lines · Ioana Ciornei
Replace
memcpy()withether_addr_copy()since addresses are__aligned(2). The 2 structures are aligned to u16:struct p80211_hdr_a3 { __le16 fc; /* 0 2 */ u16 dur; /* 2 2 */ u8 a1[ETH_ALEN]; /* 4 6 */ u8 a2[ETH_ALEN]; /* 10 6 */ u8 a3[ETH_ALEN]; /* 16 6 */ u16 seq; /* 22 2 */ } __packed;Total size: 24
struct wlan_ethhdr { u8 daddr[WLAN_ETHADDR_LEN]; /* 0 6 */ u8 saddr[WLAN_ETHADDR_LEN]; /* 6 6 */ u16 type; /* 12 2 */ } __packed;Total size: 14
Signed-off-by Ioana Ciornei <[email protected]>---
Changes in v2:
- added explanations on why the addresses are aligneddrivers/staging/wlan-ng/p80211conv.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)drivers/staging/wlan-ng/p80211conv.c +0
-0@@ -62,6 +62,7 @@#include <linux/etherdevice.h> #include <linux/if_ether.h> #include <linux/byteorder/generic.h> #include <asm/byteorder.h> @@ -178,21 +179,21 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
This patch is corrupted, it looks like you edited it by hand, which is fine if you know the format, but when you don't, it breaks the tool and can not be applied.
Look at that hunk above, it doesn't do anything, which is a hint that something bad went wrong :(
Please fix up and resend.
thanks,
greg k-h
Quoted 50 lines · Greg KH
drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
Quoted 43 lines · Ioana Ciornei
Replace
memcpy()withether_addr_copy()since addresses are__aligned(2). The 2 structures are aligned to u16:struct p80211_hdr_a3 { __le16 fc; /* 0 2 */ u16 dur; /* 2 2 */ u8 a1[ETH_ALEN]; /* 4 6 */ u8 a2[ETH_ALEN]; /* 10 6 */ u8 a3[ETH_ALEN]; /* 16 6 */ u16 seq; /* 22 2 */ } __packed;Total size: 24
struct wlan_ethhdr { u8 daddr[WLAN_ETHADDR_LEN]; /* 0 6 */ u8 saddr[WLAN_ETHADDR_LEN]; /* 6 6 */ u16 type; /* 12 2 */ } __packed;Total size: 14
Signed-off-by Ioana Ciornei <[email protected]>---
Changes in v2:
- added explanations on why the addresses are aligneddrivers/staging/wlan-ng/p80211conv.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)drivers/staging/wlan-ng/p80211conv.c +0
-0@@ -62,6 +62,7 @@#include <linux/etherdevice.h> #include <linux/if_ether.h> #include <linux/byteorder/generic.h> #include <asm/byteorder.h> @@ -178,21 +179,21 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,This patch is corrupted, it looks like you edited it by hand, which is fine if you know the format, but when you don't, it breaks the tool and can not be applied.
Quoted 8 lines
Look at that hunk above, it doesn't do anything, which is a hint that something bad went wrong :(
Please fix up and resend.
thanks,
greg k-h
Sorry for that. I fixed it and resent the patch.
Ioana