LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] staging: vt6656: fix Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
@ 2015-01-21 11:08 Heba Aamer
2015-01-23 0:09 ` Aya Mahfouz
0 siblings, 1 reply; 4+ messages in thread
From: Heba Aamer @ 2015-01-21 11:08 UTC (permalink / raw)
To: devel; +Cc: forest, gregkh, tvboxspy, linux-kernel
This patch fixes the following checkpatch.pl warning:
fix Prefer ether_addr_copy() over memcpy()
if the Ethernet addresses are __aligned(2)
Pahole showed that the 2 structs are aligned to u16
struct vnt_mic_hdr {
u8 id; /* 0 1 */
u8 tx_priority; /* 1 1 */
u8 mic_addr2[6]; /* 2 6 */
u8 ccmp_pn[6]; /* 8 6 */
__be16 payload_len; /* 14 2 */
__be16 hlen; /* 16 2 */
__le16 frame_control; /* 18 2 */
u8 addr1[6]; /* 20 6 */
u8 addr2[6]; /* 26 6 */
u8 addr3[6]; /* 32 6 */
__le16 seq_ctrl; /* 38 2 */
u8 addr4[6]; /* 40 6 */
u16 packing; /* 46 2 */
/* size: 48, cachelines: 1, members: 13 */
/* last cacheline: 48 bytes */
};
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 */
};
Signed-off-by: Heba Aamer <heba93aamer@gmail.com>
---
drivers/staging/vt6656/rxtx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index bb6a4d4..b74f672 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -738,7 +738,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
mic_hdr->id = 0x59;
mic_hdr->payload_len = cpu_to_be16(payload_len);
- memcpy(mic_hdr->mic_addr2, hdr->addr2, ETH_ALEN);
+ ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2);
ieee80211_get_key_tx_seq(tx_key, &seq);
--
1.7.9.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: vt6656: fix Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
2015-01-21 11:08 [PATCH] staging: vt6656: fix Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) Heba Aamer
@ 2015-01-23 0:09 ` Aya Mahfouz
0 siblings, 0 replies; 4+ messages in thread
From: Aya Mahfouz @ 2015-01-23 0:09 UTC (permalink / raw)
To: Heba Aamer; +Cc: devel, tvboxspy, gregkh, forest, linux-kernel
On Wed, Jan 21, 2015 at 01:08:48PM +0200, Heba Aamer wrote:
> This patch fixes the following checkpatch.pl warning:
> fix Prefer ether_addr_copy() over memcpy()
> if the Ethernet addresses are __aligned(2)
>
> Pahole showed that the 2 structs are aligned to u16
>
> struct vnt_mic_hdr {
> u8 id; /* 0 1 */
> u8 tx_priority; /* 1 1 */
> u8 mic_addr2[6]; /* 2 6 */
> u8 ccmp_pn[6]; /* 8 6 */
> __be16 payload_len; /* 14 2 */
> __be16 hlen; /* 16 2 */
> __le16 frame_control; /* 18 2 */
> u8 addr1[6]; /* 20 6 */
> u8 addr2[6]; /* 26 6 */
> u8 addr3[6]; /* 32 6 */
> __le16 seq_ctrl; /* 38 2 */
> u8 addr4[6]; /* 40 6 */
> u16 packing; /* 46 2 */
>
> /* size: 48, cachelines: 1, members: 13 */
> /* last cacheline: 48 bytes */
> };
>
> 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 */
> };
>
> Signed-off-by: Heba Aamer <heba93aamer@gmail.com>
Reviewed-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
> ---
> drivers/staging/vt6656/rxtx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
> index bb6a4d4..b74f672 100644
> --- a/drivers/staging/vt6656/rxtx.c
> +++ b/drivers/staging/vt6656/rxtx.c
> @@ -738,7 +738,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
>
> mic_hdr->id = 0x59;
> mic_hdr->payload_len = cpu_to_be16(payload_len);
> - memcpy(mic_hdr->mic_addr2, hdr->addr2, ETH_ALEN);
> + ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2);
>
> ieee80211_get_key_tx_seq(tx_key, &seq);
>
> --
> 1.7.9.5
>
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] staging: vt6656: fix Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
@ 2015-01-21 16:44 Lin Kassem
2015-01-21 15:55 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Lin Kassem @ 2015-01-21 16:44 UTC (permalink / raw)
To: devel; +Cc: forest, gregkh, tvboxspy, linux-kernel
This patch fixes the following checkpatch.pl warning:
fix Prefer ether_addr_copy() over memcpy()
if the Ethernet addresses are __aligned(2)
Pahole showed that the 2 structs are aligned to u16
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 vnt_mic_hdr {
u8 id; /* 0 1 */
u8 tx_priority; /* 1 1 */
u8 mic_addr2[6]; /* 2 6 */
u8 ccmp_pn[6]; /* 8 6 */
__be16 payload_len; /* 14 2 */
__be16 hlen; /* 16 2 */
__le16 frame_control; /* 18 2 */
u8 addr1[6]; /* 20 6 */
u8 addr2[6]; /* 26 6 */
u8 addr3[6]; /* 32 6 */
__le16 seq_ctrl; /* 38 2 */
u8 addr4[6]; /* 40 6 */
u16 packing; /* 46 2 */
/* size: 48, cachelines: 1, members: 13 */
/* last cacheline: 48 bytes */
};
Signed-off-by: Lin Kassem <linsara1@gmail.com>
---
drivers/staging/vt6656/rxtx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index bb6a4d4..c202147 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -749,7 +749,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
else
mic_hdr->hlen = cpu_to_be16(22);
- memcpy(mic_hdr->addr1, hdr->addr1, ETH_ALEN);
+ ether_addr_copy(mic_hdr->addr1, hdr->addr1);
memcpy(mic_hdr->addr2, hdr->addr2, ETH_ALEN);
memcpy(mic_hdr->addr3, hdr->addr3, ETH_ALEN);
--
1.7.9.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: vt6656: fix Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
2015-01-21 16:44 Lin Kassem
@ 2015-01-21 15:55 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2015-01-21 15:55 UTC (permalink / raw)
To: Lin Kassem; +Cc: devel, forest, gregkh, tvboxspy, linux-kernel
On Wed, 2015-01-21 at 18:44 +0200, Lin Kassem wrote:
> This patch fixes the following checkpatch.pl warning:
> fix Prefer ether_addr_copy() over memcpy()
> if the Ethernet addresses are __aligned(2)
>
> Pahole showed that the 2 structs are aligned to u16
[]
> diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
[]
> @@ -749,7 +749,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
> else
> mic_hdr->hlen = cpu_to_be16(22);
>
> - memcpy(mic_hdr->addr1, hdr->addr1, ETH_ALEN);
> + ether_addr_copy(mic_hdr->addr1, hdr->addr1);
> memcpy(mic_hdr->addr2, hdr->addr2, ETH_ALEN);
> memcpy(mic_hdr->addr3, hdr->addr3, ETH_ALEN);
>
Why would you modify only one of these?
Please modify all 4.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-23 0:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-21 11:08 [PATCH] staging: vt6656: fix Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) Heba Aamer
2015-01-23 0:09 ` Aya Mahfouz
2015-01-21 16:44 Lin Kassem
2015-01-21 15:55 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).