diff options
author | Aya Mahfouz <mahfouz.saif.elyazal@gmail.com> | 2014-10-11 00:34:07 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-10-20 02:30:15 (GMT) |
commit | 87bb326eada535ed72ca312878bb5ba69bad870b (patch) | |
tree | b4a0d27c38722925d5a7a4ff7a65ad28d5343189 /drivers/staging/vt6655 | |
parent | e1499e81497cd46f296c4680096323f0aadd2604 (diff) | |
download | linux-87bb326eada535ed72ca312878bb5ba69bad870b.tar.xz |
staging: vt6655: dpc.c: replace memcpy() by ether_addr_copy() using coccinelle
This patch focuses on fixing the following warning generated
by checkpatch.pl for the file dpc.c :
Prefer ether_addr_copy() over memcpy() if the Ethernet addresses
are __aligned(2)
The changes were applied using the following coccinelle rule:
@@ expression e1, e2; @@
- memcpy(e1, e2, ETH_ALEN);
+ ether_addr_copy(e1, e2);
According to ether_addr_copy() description and functionality,
all Ethernet addresses should align to the u16 datatype.
Here is the output of pahole for the relevant datastructures:
struct tagS802_11Header {
short unsigned int wFrameCtl; /* 0 2 */
short unsigned int wDurationID; /* 2 2 */
unsigned char abyAddr1[6]; /* 4 6 */
unsigned char abyAddr2[6]; /* 10 6 */
unsigned char abyAddr3[6]; /* 16 6 */
short unsigned int wSeqCtl; /* 22 2 */
unsigned char abyAddr4[6]; /* 24 6 */
/* size: 30, cachelines: 1, members: 7 */
/* 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 */
};
struct sockaddr {
sa_family_t sa_family; /* 0 2 */
char sa_data[14]; /* 2 14 */
/* size: 16, cachelines: 1, members: 2 */
/* last cacheline: 16 bytes */
};
There is one thing to note though, sa_data is a char array of size 14.
And the number of bytes copied using memcpy() or ether_addr_copy()
is 6.
Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/vt6655')
-rw-r--r-- | drivers/staging/vt6655/dpc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 8515b8c..344e12f 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -742,7 +742,8 @@ device_receive_frame( } ev.src_addr.sa_family = ARPHRD_ETHER; - memcpy(ev.src_addr.sa_data, pMACHeader->abyAddr2, ETH_ALEN); + ether_addr_copy(ev.src_addr.sa_data, + pMACHeader->abyAddr2); memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = sizeof(ev); wireless_send_event(pDevice->dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev); |