Commit c60298c5 authored by sayli karnik's avatar sayli karnik Committed by Greg Kroah-Hartman

staging: rtl8188eu: core: Replace memcpy() with ether_addr_copy() if ethernet...

staging: rtl8188eu: core: Replace memcpy() with ether_addr_copy() if ethernet addresses are __aligned(2)

This patch fixes the checkpatch warning:
Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are
__aligned(2)
Done using coccinelle:

@@
expression exp1, exp2;
@@
- memcpy(exp1, exp2, ETH_ALEN);
+ ether_addr_copy(exp1, exp2);

The output of pahole shows that the addresses are aligned:

struct ieee80211_hdr {
        __le16                     frame_control;        /*     0     2 */
        __le16                     duration_id;          /*     2     2 */
        u8                         addr1[6];             /*     4     6 */
        u8                         addr2[6];             /*    10     6 */
        u8                         addr3[6];             /*    16     6 */
        __le16                     seq_ctrl;             /*    22     2 */
        u8                         addr4[6];             /*    24     6 */

        /* size: 30, cachelines: 1, members: 7 */
        /* last cacheline: 30 bytes */
};

struct wlan_bssid_ex {
        u32                        Length;               /*     0     4 */
        unsigned char              MacAddress[6];        /*     4     6 */
        u8                         Reserved[2];          /*    10     2 */
        struct ndis_802_11_ssid    Ssid;                 /*    12    36 */
        u32                        Privacy;              /*    48     4 */
        long int                   Rssi;                 /*    52     8 */
        enum NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;  /*    60     4 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        struct ndis_802_11_config  Configuration;        /*    64    32 */
        enum ndis_802_11_network_infra InfrastructureMode; /*    96     4 */
        unsigned char              SupportedRates[16];   /*   100    16 */
        struct wlan_phy_info       PhyInfo;              /*   116     4 */
        u32                        IELength;             /*   120     4 */
        u8                         IEs[768];             /*   124   768 */
        /* --- cacheline 13 boundary (832 bytes) was 60 bytes ago --- */

        /* size: 892, cachelines: 14, members: 13 */
        /* last cacheline: 60 bytes */
};

struct stadel_event {
        unsigned char              macaddr[6];           /*     0     6 */
        unsigned char              rsvd[2];              /*     6     2 */
        int                        mac_id;               /*     8     4 */

        /* size: 12, cachelines: 1, members: 3 */
        /* last cacheline: 12 bytes */
};
Signed-off-by: default avatarsayli karnik <karniksayli1995@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fbafd397
...@@ -353,9 +353,9 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms) ...@@ -353,9 +353,9 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms)
fctrl = &pwlanhdr->frame_control; fctrl = &pwlanhdr->frame_control;
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, bc_addr);
memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)));
memcpy(pwlanhdr->addr3, cur_network->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, cur_network->MacAddress);
SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/);
/* pmlmeext->mgnt_seq++; */ /* pmlmeext->mgnt_seq++; */
...@@ -495,9 +495,9 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) ...@@ -495,9 +495,9 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da)
fctrl = &pwlanhdr->frame_control; fctrl = &pwlanhdr->frame_control;
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, da, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, da);
memcpy(pwlanhdr->addr2, mac, ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, mac);
memcpy(pwlanhdr->addr3, bssid, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, bssid);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
pmlmeext->mgnt_seq++; pmlmeext->mgnt_seq++;
...@@ -642,15 +642,15 @@ static int issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pss ...@@ -642,15 +642,15 @@ static int issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pss
if (da) { if (da) {
/* unicast probe request frame */ /* unicast probe request frame */
memcpy(pwlanhdr->addr1, da, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, da);
memcpy(pwlanhdr->addr3, da, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, da);
} else { } else {
/* broadcast probe request frame */ /* broadcast probe request frame */
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, bc_addr);
memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, bc_addr);
} }
memcpy(pwlanhdr->addr2, mac, ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, mac);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
pmlmeext->mgnt_seq++; pmlmeext->mgnt_seq++;
...@@ -785,9 +785,11 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, ...@@ -785,9 +785,11 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta,
if (psta) {/* for AP mode */ if (psta) {/* for AP mode */
#ifdef CONFIG_88EU_AP_MODE #ifdef CONFIG_88EU_AP_MODE
memcpy(pwlanhdr->addr1, psta->hwaddr, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, psta->hwaddr);
memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ether_addr_copy(pwlanhdr->addr2,
memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); myid(&(padapter->eeprompriv)));
ether_addr_copy(pwlanhdr->addr3,
myid(&(padapter->eeprompriv)));
/* setting auth algo number */ /* setting auth algo number */
...@@ -825,9 +827,9 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, ...@@ -825,9 +827,9 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta,
} else { } else {
__le32 le_tmp32; __le32 le_tmp32;
__le16 le_tmp16; __le16 le_tmp16;
memcpy(pwlanhdr->addr1, pnetwork->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, pnetwork->MacAddress);
memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv));
memcpy(pwlanhdr->addr3, pnetwork->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress);
/* setting auth algo number */ /* setting auth algo number */
val16 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) ? 1 : 0;/* 0:OPEN System, 1:Shared key */ val16 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) ? 1 : 0;/* 0:OPEN System, 1:Shared key */
...@@ -921,9 +923,10 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, ...@@ -921,9 +923,10 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status,
fctrl = &pwlanhdr->frame_control; fctrl = &pwlanhdr->frame_control;
*(fctrl) = 0; *(fctrl) = 0;
memcpy((void *)GetAddr1Ptr(pwlanhdr), pstat->hwaddr, ETH_ALEN); ether_addr_copy((void *)GetAddr1Ptr(pwlanhdr), pstat->hwaddr);
memcpy((void *)GetAddr2Ptr(pwlanhdr), myid(&(padapter->eeprompriv)), ETH_ALEN); ether_addr_copy((void *)GetAddr2Ptr(pwlanhdr),
memcpy((void *)GetAddr3Ptr(pwlanhdr), pnetwork->MacAddress, ETH_ALEN); myid(&(padapter->eeprompriv)));
ether_addr_copy((void *)GetAddr3Ptr(pwlanhdr), pnetwork->MacAddress);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
...@@ -1044,9 +1047,9 @@ static void issue_assocreq(struct adapter *padapter) ...@@ -1044,9 +1047,9 @@ static void issue_assocreq(struct adapter *padapter)
fctrl = &pwlanhdr->frame_control; fctrl = &pwlanhdr->frame_control;
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, pnetwork->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, pnetwork->MacAddress);
memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)));
memcpy(pwlanhdr->addr3, pnetwork->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
pmlmeext->mgnt_seq++; pmlmeext->mgnt_seq++;
...@@ -1252,9 +1255,9 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned ...@@ -1252,9 +1255,9 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned
if (power_mode) if (power_mode)
SetPwrMgt(fctrl); SetPwrMgt(fctrl);
memcpy(pwlanhdr->addr1, da, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, da);
memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)));
memcpy(pwlanhdr->addr3, pnetwork->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
pmlmeext->mgnt_seq++; pmlmeext->mgnt_seq++;
...@@ -1380,9 +1383,9 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 ...@@ -1380,9 +1383,9 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16
SetAckpolicy(qc, pattrib->ack_policy); SetAckpolicy(qc, pattrib->ack_policy);
memcpy(pwlanhdr->addr1, da, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, da);
memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)));
memcpy(pwlanhdr->addr3, pnetwork->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
pmlmeext->mgnt_seq++; pmlmeext->mgnt_seq++;
...@@ -1483,9 +1486,9 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned s ...@@ -1483,9 +1486,9 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned s
fctrl = &pwlanhdr->frame_control; fctrl = &pwlanhdr->frame_control;
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, da, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, da);
memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)));
memcpy(pwlanhdr->addr3, pnetwork->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
pmlmeext->mgnt_seq++; pmlmeext->mgnt_seq++;
...@@ -1601,9 +1604,9 @@ static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, ...@@ -1601,9 +1604,9 @@ static void issue_action_BA(struct adapter *padapter, unsigned char *raddr,
fctrl = &pwlanhdr->frame_control; fctrl = &pwlanhdr->frame_control;
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, raddr);
memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)));
memcpy(pwlanhdr->addr3, pnetwork->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
pmlmeext->mgnt_seq++; pmlmeext->mgnt_seq++;
...@@ -1760,9 +1763,9 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) ...@@ -1760,9 +1763,9 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)
fctrl = &pwlanhdr->frame_control; fctrl = &pwlanhdr->frame_control;
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, cur_network->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr1, cur_network->MacAddress);
memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)));
memcpy(pwlanhdr->addr3, cur_network->MacAddress, ETH_ALEN); ether_addr_copy(pwlanhdr->addr3, cur_network->MacAddress);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
pmlmeext->mgnt_seq++; pmlmeext->mgnt_seq++;
...@@ -2159,7 +2162,7 @@ static u8 collect_bss_info(struct adapter *padapter, ...@@ -2159,7 +2162,7 @@ static u8 collect_bss_info(struct adapter *padapter,
if (subtype == WIFI_PROBEREQ) { if (subtype == WIFI_PROBEREQ) {
/* FIXME */ /* FIXME */
bssid->InfrastructureMode = Ndis802_11Infrastructure; bssid->InfrastructureMode = Ndis802_11Infrastructure;
memcpy(bssid->MacAddress, GetAddr2Ptr(pframe), ETH_ALEN); ether_addr_copy(bssid->MacAddress, GetAddr2Ptr(pframe));
bssid->Privacy = 1; bssid->Privacy = 1;
return _SUCCESS; return _SUCCESS;
} }
...@@ -2171,10 +2174,10 @@ static u8 collect_bss_info(struct adapter *padapter, ...@@ -2171,10 +2174,10 @@ static u8 collect_bss_info(struct adapter *padapter,
if (val16 & BIT(0)) { if (val16 & BIT(0)) {
bssid->InfrastructureMode = Ndis802_11Infrastructure; bssid->InfrastructureMode = Ndis802_11Infrastructure;
memcpy(bssid->MacAddress, GetAddr2Ptr(pframe), ETH_ALEN); ether_addr_copy(bssid->MacAddress, GetAddr2Ptr(pframe));
} else { } else {
bssid->InfrastructureMode = Ndis802_11IBSS; bssid->InfrastructureMode = Ndis802_11IBSS;
memcpy(bssid->MacAddress, GetAddr3Ptr(pframe), ETH_ALEN); ether_addr_copy(bssid->MacAddress, GetAddr3Ptr(pframe));
} }
if (val16 & BIT(4)) if (val16 & BIT(4))
...@@ -4395,7 +4398,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi ...@@ -4395,7 +4398,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq);
pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
memcpy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr, ETH_ALEN); ether_addr_copy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr);
memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2); memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2);
...@@ -4448,7 +4451,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int ...@@ -4448,7 +4451,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq);
padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
memcpy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr, ETH_ALEN); ether_addr_copy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr);
padd_sta_evt->cam_id = cam_idx; padd_sta_evt->cam_id = cam_idx;
DBG_88E("report_add_sta_event: add STA\n"); DBG_88E("report_add_sta_event: add STA\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment