* Re: [Outreachy kernel] [PATCH v2 1/5] Staging: rtl8192e: Replace memcpy with ether_addr_copy
2015-03-18 12:34 ` [PATCH v2 " Darshana Padmadas
@ 2015-03-18 12:36 ` Julia Lawall
0 siblings, 0 replies; 9+ messages in thread
From: Julia Lawall @ 2015-03-18 12:36 UTC (permalink / raw)
To: Darshana Padmadas; +Cc: outreachy-kernel
I think that both addresses have to be aligned?
julia
On Wed, 18 Mar 2015, Darshana Padmadas wrote:
> This patch fixes the following warning found by checkpatch.pl:
> Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2
>
> Also included the header file linux/etherdevice.h where ether_addr_copy has
> been defined.
> Pahole showed that the structure for BAReq and Delba is aligned:
> struct rtllib_hdr_3addr {
> __le16 frame_ctl; /* 0 2 */
> __le16 duration_id; /* 2 2 */
> u8 addr1[6]; /* 4 6 */
> u8 addr2[6]; /* 10 6 */
> u8 addr3[6]; /* 16 6 */
> __le16 seq_ctl; /* 22 2 */
> u8 payload[0]; /* 24 0 */
>
> /* size: 24, cachelines: 1, members: 7 */
> /* last cacheline: 24 bytes */
> };
>
> Signed-off-by: Darshana Padmadas <darshanapadmadas@gmail.com>
> ---
> Changes in v2:
> - Included header file where ether_addr_copy is defined.
> - Made the commit message more clear.
>
> drivers/staging/rtl8192e/rtl819x_BAProc.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c
> index 0415e02..4031462 100644
> --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
> +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
> @@ -18,6 +18,7 @@
> ******************************************************************************/
> #include <asm/byteorder.h>
> #include <asm/unaligned.h>
> +#include <linux/etherdevice.h>
> #include "rtllib.h"
> #include "rtl819x_BA.h"
>
> @@ -103,7 +104,7 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
> BAReq = (struct rtllib_hdr_3addr *)skb_put(skb,
> sizeof(struct rtllib_hdr_3addr));
>
> - memcpy(BAReq->addr1, Dst, ETH_ALEN);
> + ether_addr_copy(BAReq->addr1, Dst);
> memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
>
> memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
> @@ -168,7 +169,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
> Delba = (struct rtllib_hdr_3addr *) skb_put(skb,
> sizeof(struct rtllib_hdr_3addr));
>
> - memcpy(Delba->addr1, dst, ETH_ALEN);
> + ether_addr_copy(Delba->addr1, dst);
> memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
> memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
> Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
> --
> 1.9.1
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/9eab4a1c89f930dac0710fda702a6de414172237.1426681038.git.darshanapadmadas%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 0/5] Replace memcpy with ether_addr_copy and fix checkpatch warning
@ 2015-03-18 13:43 Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 1/5] Staging: rtl8192e: Replace memcpy with ether_addr_copy Darshana Padmadas
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Darshana Padmadas @ 2015-03-18 13:43 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Darshana Padmadas
This patch set replaces memcpy with ether_addr_copy if the
addresses of the structures are aligned. Structure layout is
shown by using the Pahole tool.
This patch set fixes the following warning reported by checkpatch:
WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
Darshana Padmadas (5):
Changes in v2:
- Included header files that define ether_addr_copy in
patch 1/5 and 2/5.
- Edited the commit message more clear in 1/5 and 2/5.
Staging: rtl8192e: Replace memcpy with ether_addr_copy
Staging: rtl8192e: Use ether_addr_copy instead of memcpy
Staging: rtl8192e: Use ether_addr_copy replacing memcpy
Staging: rtl8192e: Use ether_addr_copy for aligned addresses
Staging: rtl8192e: replace memcpy with ether_addr_copy for aligned
structures
drivers/staging/rtl8192e/rtl819x_BAProc.c | 5 +++--
drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 12 +++++------
drivers/staging/rtl8192e/rtllib_rx.c | 32 ++++++++++++++--------------
drivers/staging/rtl8192e/rtllib_softmac.c | 12 +++++------
drivers/staging/rtl8192e/rtllib_tx.c | 6 +++---
5 files changed, 34 insertions(+), 33 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/5] Staging: rtl8192e: Replace memcpy with ether_addr_copy
2015-03-18 13:43 [PATCH v2 0/5] Replace memcpy with ether_addr_copy and fix checkpatch warning Darshana Padmadas
@ 2015-03-18 13:43 ` Darshana Padmadas
2015-03-20 12:10 ` [Outreachy kernel] " Greg KH
2015-03-18 13:43 ` [PATCH v2 2/5] Staging: rtl8192e: Use ether_addr_copy instead of memcpy Darshana Padmadas
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Darshana Padmadas @ 2015-03-18 13:43 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Darshana Padmadas
This patch fixes the following warning found by checkpatch.pl:
Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2
Also included header file linux/etherdevice.h that defines
ether_addr_copy.
Pahole showed that the structure for BAReq and Delba is aligned:
struct rtllib_hdr_3addr {
__le16 frame_ctl; /* 0 2 */
__le16 duration_id; /* 2 2 */
u8 addr1[6]; /* 4 6 */
u8 addr2[6]; /* 10 6 */
u8 addr3[6]; /* 16 6 */
__le16 seq_ctl; /* 22 2 */
u8 payload[0]; /* 24 0 */
/* size: 24, cachelines: 1, members: 7 */
/* last cacheline: 24 bytes */
};
Signed-off-by: Darshana Padmadas <darshanapadmadas@gmail.com>
---
drivers/staging/rtl8192e/rtl819x_BAProc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 0415e02..4031462 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -18,6 +18,7 @@
******************************************************************************/
#include <asm/byteorder.h>
#include <asm/unaligned.h>
+#include <linux/etherdevice.h>
#include "rtllib.h"
#include "rtl819x_BA.h"
@@ -103,7 +104,7 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
BAReq = (struct rtllib_hdr_3addr *)skb_put(skb,
sizeof(struct rtllib_hdr_3addr));
- memcpy(BAReq->addr1, Dst, ETH_ALEN);
+ ether_addr_copy(BAReq->addr1, Dst);
memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
@@ -168,7 +169,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
Delba = (struct rtllib_hdr_3addr *) skb_put(skb,
sizeof(struct rtllib_hdr_3addr));
- memcpy(Delba->addr1, dst, ETH_ALEN);
+ ether_addr_copy(Delba->addr1, dst);
memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/5] Staging: rtl8192e: Use ether_addr_copy instead of memcpy
2015-03-18 13:43 [PATCH v2 0/5] Replace memcpy with ether_addr_copy and fix checkpatch warning Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 1/5] Staging: rtl8192e: Replace memcpy with ether_addr_copy Darshana Padmadas
@ 2015-03-18 13:43 ` Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 3/5] Staging: rtl8192e: Use ether_addr_copy replacing memcpy Darshana Padmadas
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Darshana Padmadas @ 2015-03-18 13:43 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Darshana Padmadas
This patch replaces use of memcpy with ether_addr_copy since
the addresses for struct of hdr11 and ev are aligned as shown by Pahole
and hdr is of type u8.
The header file linux/etherdevice.h is also included where
ether_addr_copy is defined.
struct rtllib_hdr_4addr {
__le16 frame_ctl; /* 0 2 */
__le16 duration_id; /* 2 2 */
u8 addr1[6]; /* 4 6 */
u8 addr2[6]; /* 10 6 */
u8 addr3[6]; /* 16 6 */
__le16 seq_ctl; /* 22 2 */
u8 addr4[6]; /* 24 6 */
u8 payload[0]; /* 30 0 */
/* size: 30, cachelines: 1, members: 8 */
/* last cacheline: 30 bytes */
};
struct iw_michaelmicfailure {
__u32 flags; /* 0 4 */
struct sockaddr src_addr; /* 4 16 */
__u8 tsc[8]; /* 20 8 */
/* size: 28, cachelines: 1, members: 3 */
/* last cacheline: 28 bytes */
};
Signed-off-by: Darshana Padmadas <darshanapadmadas@gmail.com>
---
drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index 78db2b6..949fc8f 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -21,7 +21,7 @@
#include <linux/crypto.h>
#include <linux/scatterlist.h>
#include <linux/crc32.h>
-
+#include <linux/etherdevice.h>
#include "rtllib.h"
struct rtllib_tkip_data {
@@ -525,19 +525,19 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
switch (le16_to_cpu(hdr11->frame_ctl) &
(RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
case RTLLIB_FCTL_TODS:
- memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
+ ether_addr_copy(hdr, hdr11->addr3); /* DA */
memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
break;
case RTLLIB_FCTL_FROMDS:
- memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
+ ether_addr_copy(hdr, hdr11->addr1); /* DA */
memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
break;
case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS:
- memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
+ ether_addr_copy(hdr, hdr11->addr3); /* DA */
memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
break;
case 0:
- memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
+ ether_addr_copy(hdr, hdr11->addr1); /* DA */
memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
break;
}
@@ -591,7 +591,7 @@ static void rtllib_michael_mic_failure(struct net_device *dev,
else
ev.flags |= IW_MICFAILURE_PAIRWISE;
ev.src_addr.sa_family = ARPHRD_ETHER;
- memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN);
+ ether_addr_copy(ev.src_addr.sa_data, hdr->addr2);
memset(&wrqu, 0, sizeof(wrqu));
wrqu.data.length = sizeof(ev);
wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/5] Staging: rtl8192e: Use ether_addr_copy replacing memcpy
2015-03-18 13:43 [PATCH v2 0/5] Replace memcpy with ether_addr_copy and fix checkpatch warning Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 1/5] Staging: rtl8192e: Replace memcpy with ether_addr_copy Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 2/5] Staging: rtl8192e: Use ether_addr_copy instead of memcpy Darshana Padmadas
@ 2015-03-18 13:43 ` Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 4/5] Staging: rtl8192e: Use ether_addr_copy for aligned addresses Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 5/5] Staging: rtl8192e: replace memcpy with ether_addr_copy for aligned structures Darshana Padmadas
4 siblings, 0 replies; 9+ messages in thread
From: Darshana Padmadas @ 2015-03-18 13:43 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Darshana Padmadas
This patch uses ether_addr_copy instead of memcpy since
the structures of beacon_buf, assoc, auth, a, header
are aligned as shown by Pahole:
struct rtllib_probe_response {
struct rtllib_hdr_3addr header; /* 0 24 */
u32 time_stamp[2]; /* 24 8 */
__le16 beacon_interval; /* 32 2 */
__le16 capability; /* 34 2 */
struct rtllib_info_element info_element[0]; /* 36 0 */
/* size: 36, cachelines: 1, members: 5 */
/* last cacheline: 36 bytes */
};
struct rtllib_assoc_response_frame {
struct rtllib_hdr_3addr header; /* 0 24 */
__le16 capability; /* 24 2 */
__le16 status; /* 26 2 */
__le16 aid; /* 28 2 */
struct rtllib_info_element info_element[0]; /* 30 0 */
/* size: 30, cachelines: 1, members: 5 */
/* last cacheline: 30 bytes */
};
struct rtllib_authentication {
struct rtllib_hdr_3addr header; /* 0 24 */
__le16 algorithm; /* 24 2 */
__le16 transaction; /* 26 2 */
__le16 status; /* 28 2 */
struct rtllib_info_element info_element[0]; /* 30 0 */
/* size: 30, cachelines: 1, members: 5 */
/* last cacheline: 30 bytes */
};
struct rtllib_hdr_3addr {
__le16 frame_ctl; /* 0 2 */
__le16 duration_id; /* 2 2 */
u8 addr1[6]; /* 4 6 */
u8 addr2[6]; /* 10 6 */
u8 addr3[6]; /* 16 6 */
__le16 seq_ctl; /* 22 2 */
u8 payload[0]; /* 24 0 */
/* size: 24, cachelines: 1, members: 7 */
/* last cacheline: 24 bytes */
};
Signed-off-by: Darshana Padmadas <darshanapadmadas@gmail.com>
---
drivers/staging/rtl8192e/rtllib_softmac.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index 16aef7c..d2ea955 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -911,7 +911,7 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)
beacon_buf = (struct rtllib_probe_response *) skb_put(skb,
(beacon_size - ieee->tx_headroom));
- memcpy(beacon_buf->header.addr1, dest, ETH_ALEN);
+ ether_addr_copy(beacon_buf->header.addr1, dest);
memcpy(beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
memcpy(beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
@@ -1008,7 +1008,7 @@ static struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest)
skb_put(skb, sizeof(struct rtllib_assoc_response_frame));
assoc->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_RESP);
- memcpy(assoc->header.addr1, dest, ETH_ALEN);
+ ether_addr_copy(assoc->header.addr1, dest);
memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
@@ -1067,7 +1067,7 @@ static struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status,
memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(auth->header.addr1, dest, ETH_ALEN);
+ ether_addr_copy(auth->header.addr1, dest);
auth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_AUTH);
return skb;
@@ -1831,7 +1831,7 @@ static int auth_rq_parse(struct sk_buff *skb, u8 *dest)
}
a = (struct rtllib_authentication *) skb->data;
- memcpy(dest, a->header.addr2, ETH_ALEN);
+ ether_addr_copy(dest, a->header.addr2);
if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
@@ -1859,7 +1859,7 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb,
if (bssid_match)
return -1;
- memcpy(src, header->addr2, ETH_ALEN);
+ ether_addr_copy(src, header->addr2);
skbend = (u8 *)skb->data + skb->len;
@@ -1898,7 +1898,7 @@ static int assoc_rq_parse(struct sk_buff *skb, u8 *dest)
a = (struct rtllib_assoc_request_frame *) skb->data;
- memcpy(dest, a->header.addr2, ETH_ALEN);
+ ether_addr_copy(dest, a->header.addr2);
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/5] Staging: rtl8192e: Use ether_addr_copy for aligned addresses
2015-03-18 13:43 [PATCH v2 0/5] Replace memcpy with ether_addr_copy and fix checkpatch warning Darshana Padmadas
` (2 preceding siblings ...)
2015-03-18 13:43 ` [PATCH v2 3/5] Staging: rtl8192e: Use ether_addr_copy replacing memcpy Darshana Padmadas
@ 2015-03-18 13:43 ` Darshana Padmadas
2015-03-20 11:01 ` Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 5/5] Staging: rtl8192e: replace memcpy with ether_addr_copy for aligned structures Darshana Padmadas
4 siblings, 1 reply; 9+ messages in thread
From: Darshana Padmadas @ 2015-03-18 13:43 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Darshana Padmadas
This patch replaces memcpy with ether_addr_copy since structures
are aligned as shown by pahole:
struct rtllib_hdr_3addrqos {
__le16 frame_ctl; /* 0 2 */
__le16 duration_id; /* 2 2 */
u8 addr1[6]; /* 4 6 */
u8 addr2[6]; /* 10 6 */
u8 addr3[6]; /* 16 6 */
__le16 seq_ctl; /* 22 2 */
__le16 qos_ctl; /* 24 2 */
u8 payload[0]; /* 26 0 */
/* size: 26, cachelines: 1, members: 8 */
/* last cacheline: 26 bytes */
};
Signed-off-by: Darshana Padmadas <darshanapadmadas@gmail.com>
---
drivers/staging/rtl8192e/rtllib_tx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
index 4f68ffe..de74e0e 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -688,12 +688,12 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
memcpy(&header.addr3,
ieee->current_network.bssid, ETH_ALEN);
else
- memcpy(&header.addr3, &dest, ETH_ALEN);
+ ether_addr_copy(&header.addr3, &dest);
} else if (ieee->iw_mode == IW_MODE_ADHOC) {
/* not From/To DS: Addr1 = DA, Addr2 = SA,
Addr3 = BSSID */
- memcpy(&header.addr1, dest, ETH_ALEN);
- memcpy(&header.addr2, src, ETH_ALEN);
+ ether_addr_copy(&header.addr1, dest);
+ ether_addr_copy(&header.addr2, src);
memcpy(&header.addr3, ieee->current_network.bssid,
ETH_ALEN);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 5/5] Staging: rtl8192e: replace memcpy with ether_addr_copy for aligned structures
2015-03-18 13:43 [PATCH v2 0/5] Replace memcpy with ether_addr_copy and fix checkpatch warning Darshana Padmadas
` (3 preceding siblings ...)
2015-03-18 13:43 ` [PATCH v2 4/5] Staging: rtl8192e: Use ether_addr_copy for aligned addresses Darshana Padmadas
@ 2015-03-18 13:43 ` Darshana Padmadas
4 siblings, 0 replies; 9+ messages in thread
From: Darshana Padmadas @ 2015-03-18 13:43 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Darshana Padmadas
This patch replaces memcpy with ether_addr_copy and eliminates the
following warning:
WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
Pahole is used to show the structures for entry, hdr, rxb
struct rtllib_frag_entry {
long unsigned int first_frag_time; /* 0 8 */
unsigned int seq; /* 8 4 */
unsigned int last_frag; /* 12 4 */
struct sk_buff * skb; /* 16 8 */
u8 src_addr[6]; /* 24 6 */
u8 dst_addr[6]; /* 30 6 */
/* size: 40, cachelines: 1, members: 6 */
/* padding: 4 */
/* last cacheline: 40 bytes */
};
struct rtllib_hdr_4addr {
__le16 frame_ctl; /* 0 2 */
__le16 duration_id; /* 2 2 */
u8 addr1[6]; /* 4 6 */
u8 addr2[6]; /* 10 6 */
u8 addr3[6]; /* 16 6 */
__le16 seq_ctl; /* 22 2 */
u8 addr4[6]; /* 24 6 */
u8 payload[0]; /* 30 0 */
/* size: 30, cachelines: 1, members: 8 */
/* last cacheline: 30 bytes */
};
struct rtllib_rxb {
u8 nr_subframes; /* 0 1 */
struct sk_buff * subframes[64]; /* 1 512 */
/* --- cacheline 8 boundary (512 bytes) was 1 bytes ago --- */
u8 dst[6]; /* 513 6 */
u8 src[6]; /* 519 6 */
/* size: 525, cachelines: 9, members: 4 */
/* last cacheline: 13 bytes */
};
Signed-off-by: Darshana Padmadas <darshanapadmadas@gmail.com>
---
drivers/staging/rtl8192e/rtllib_rx.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index e8261ae..06712b5 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -139,8 +139,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
entry->seq = seq;
entry->last_frag = frag;
entry->skb = skb;
- memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
- memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
+ ether_addr_copy(entry->src_addr, hdr->addr2);
+ ether_addr_copy(entry->dst_addr, hdr->addr1);
} else {
/* received a fragment of a frame for which the head fragment
* should have already been received */
@@ -397,7 +397,7 @@ static int is_duplicate_packet(struct rtllib_device *ieee,
if (!entry)
return 0;
- memcpy(entry->mac, mac, ETH_ALEN);
+ ether_addr_copy(entry->mac, mac);
entry->seq_num[tid] = seq;
entry->frag_num[tid] = frag;
entry->packet_time[tid] = jiffies;
@@ -783,8 +783,8 @@ static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb,
return 1;
} else {
rxb->nr_subframes = 0;
- memcpy(rxb->src, src, ETH_ALEN);
- memcpy(rxb->dst, dst, ETH_ALEN);
+ ether_addr_copy(rxb->src, src);
+ ether_addr_copy(rxb->dst, dst);
while (skb->len > ETHERNET_HEADER_SIZE) {
/* Offset 12 denote 2 mac address */
nSubframe_Length = *((u16 *)(skb->data + 12));
@@ -917,24 +917,24 @@ static void rtllib_rx_extract_addr(struct rtllib_device *ieee,
switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
case RTLLIB_FCTL_FROMDS:
- memcpy(dst, hdr->addr1, ETH_ALEN);
- memcpy(src, hdr->addr3, ETH_ALEN);
- memcpy(bssid, hdr->addr2, ETH_ALEN);
+ ether_addr_copy(dst, hdr->addr1);
+ ether_addr_copy(src, hdr->addr3);
+ ether_addr_copy(bssid, hdr->addr2);
break;
case RTLLIB_FCTL_TODS:
- memcpy(dst, hdr->addr3, ETH_ALEN);
- memcpy(src, hdr->addr2, ETH_ALEN);
- memcpy(bssid, hdr->addr1, ETH_ALEN);
+ ether_addr_copy(dst, hdr->addr3);
+ ether_addr_copy(src, hdr->addr2);
+ ether_addr_copy(bssid, hdr->addr1);
break;
case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS:
- memcpy(dst, hdr->addr3, ETH_ALEN);
- memcpy(src, hdr->addr4, ETH_ALEN);
+ ether_addr_copy(dst, hdr->addr3);
+ ether_addr_copy(src, hdr->addr4);
memcpy(bssid, ieee->current_network.bssid, ETH_ALEN);
break;
case 0:
- memcpy(dst, hdr->addr1, ETH_ALEN);
- memcpy(src, hdr->addr2, ETH_ALEN);
- memcpy(bssid, hdr->addr3, ETH_ALEN);
+ ether_addr_copy(dst, hdr->addr1);
+ ether_addr_copy(src, hdr->addr2);
+ ether_addr_copy(bssid, hdr->addr3);
break;
}
}
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 4/5] Staging: rtl8192e: Use ether_addr_copy for aligned addresses
2015-03-18 13:43 ` [PATCH v2 4/5] Staging: rtl8192e: Use ether_addr_copy for aligned addresses Darshana Padmadas
@ 2015-03-20 11:01 ` Darshana Padmadas
0 siblings, 0 replies; 9+ messages in thread
From: Darshana Padmadas @ 2015-03-20 11:01 UTC (permalink / raw)
To: outreachy-kernel; +Cc: darshanapadmadas
[-- Attachment #1.1: Type: text/plain, Size: 2549 bytes --]
This patch brings up incompatible pointer type warning for some arguments
&dest and
&header. So, please ignore this patch.
Also should I send v3 for this patch set?
On Wednesday, March 18, 2015 at 7:13:59 PM UTC+5:30, Darshana Padmadas
wrote:
>
> This patch replaces memcpy with ether_addr_copy since structures
> are aligned as shown by pahole:
> struct rtllib_hdr_3addrqos {
> __le16 frame_ctl; /* 0 2 */
> __le16 duration_id; /* 2 2 */
> u8 addr1[6]; /* 4 6 */
> u8 addr2[6]; /* 10 6 */
> u8 addr3[6]; /* 16 6 */
> __le16 seq_ctl; /* 22 2 */
> __le16 qos_ctl; /* 24 2 */
> u8 payload[0]; /* 26 0 */
>
> /* size: 26, cachelines: 1, members: 8 */
> /* last cacheline: 26 bytes */
> };
>
> Signed-off-by: Darshana Padmadas <darshanapadmadas@gmail.com>
> ---
> drivers/staging/rtl8192e/rtllib_tx.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/rtl8192e/rtllib_tx.c
> b/drivers/staging/rtl8192e/rtllib_tx.c
> index 4f68ffe..de74e0e 100644
> --- a/drivers/staging/rtl8192e/rtllib_tx.c
> +++ b/drivers/staging/rtl8192e/rtllib_tx.c
> @@ -688,12 +688,12 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct
> net_device *dev)
> memcpy(&header.addr3,
> ieee->current_network.bssid,
> ETH_ALEN);
> else
> - memcpy(&header.addr3, &dest, ETH_ALEN);
> + ether_addr_copy(&header.addr3, &dest);
> } else if (ieee->iw_mode == IW_MODE_ADHOC) {
> /* not From/To DS: Addr1 = DA, Addr2 = SA,
> Addr3 = BSSID */
> - memcpy(&header.addr1, dest, ETH_ALEN);
> - memcpy(&header.addr2, src, ETH_ALEN);
> + ether_addr_copy(&header.addr1, dest);
> + ether_addr_copy(&header.addr2, src);
> memcpy(&header.addr3,
> ieee->current_network.bssid,
> ETH_ALEN);
> }
> --
> 1.9.1
>
>
[-- Attachment #1.2: Type: text/html, Size: 5956 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Outreachy kernel] [PATCH v2 1/5] Staging: rtl8192e: Replace memcpy with ether_addr_copy
2015-03-18 13:43 ` [PATCH v2 1/5] Staging: rtl8192e: Replace memcpy with ether_addr_copy Darshana Padmadas
@ 2015-03-20 12:10 ` Greg KH
0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2015-03-20 12:10 UTC (permalink / raw)
To: Darshana Padmadas; +Cc: outreachy-kernel
On Wed, Mar 18, 2015 at 07:13:19PM +0530, Darshana Padmadas wrote:
> This patch fixes the following warning found by checkpatch.pl:
> Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2
>
> Also included header file linux/etherdevice.h that defines
> ether_addr_copy.
<snip>
This series still adds kernel build warnings, which is not allowed. It
looks like the patches are actually incorrect, and the compiler is
correctly warning you about this.
Please fix this up, TEST THEM!!!, and then resend.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-03-20 14:40 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-18 13:43 [PATCH v2 0/5] Replace memcpy with ether_addr_copy and fix checkpatch warning Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 1/5] Staging: rtl8192e: Replace memcpy with ether_addr_copy Darshana Padmadas
2015-03-20 12:10 ` [Outreachy kernel] " Greg KH
2015-03-18 13:43 ` [PATCH v2 2/5] Staging: rtl8192e: Use ether_addr_copy instead of memcpy Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 3/5] Staging: rtl8192e: Use ether_addr_copy replacing memcpy Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 4/5] Staging: rtl8192e: Use ether_addr_copy for aligned addresses Darshana Padmadas
2015-03-20 11:01 ` Darshana Padmadas
2015-03-18 13:43 ` [PATCH v2 5/5] Staging: rtl8192e: replace memcpy with ether_addr_copy for aligned structures Darshana Padmadas
-- strict thread matches above, loose matches on Subject: below --
2015-03-16 19:18 [PATCH 1/5] Staging: rtl8192e: Replace memcpy with ether_addr_copy Darshana Padmadas
2015-03-18 12:34 ` [PATCH v2 " Darshana Padmadas
2015-03-18 12:36 ` [Outreachy kernel] " Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.