All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] staging: p80211conv: Replace memcpy with ether_addr_copy
@ 2015-03-18 13:50 Ioana Ciornei
  2015-03-20 12:21 ` [Outreachy kernel] " Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Ioana Ciornei @ 2015-03-18 13:50 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: Ioana Ciornei

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

Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
---

Changes in v3:
	- fixed corrupted patch

 drivers/staging/wlan-ng/p80211conv.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index bd69e8c..b3f48074 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -178,21 +178,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 +241,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 =
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Outreachy kernel] [PATCH v3] staging: p80211conv: Replace memcpy with ether_addr_copy
  2015-03-18 13:50 [PATCH v3] staging: p80211conv: Replace memcpy with ether_addr_copy Ioana Ciornei
@ 2015-03-20 12:21 ` Greg KH
  2015-03-20 22:16   ` Ioana Ciornei
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2015-03-20 12:21 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: outreachy-kernel

On Wed, Mar 18, 2015 at 03:50:07PM +0200, Ioana Ciornei wrote:
> 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
> 
> Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
> ---
> 
> Changes in v3:
> 	- fixed corrupted patch

Please resend this again, after fixing the obvious build errors with it
:(

ALWAYS test build your patches, to not do so annoys the people you send
them to, as it breaks their workflow, and is a bit rude.

thanks,

greg k-h


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Outreachy kernel] [PATCH v3] staging: p80211conv: Replace memcpy with ether_addr_copy
  2015-03-20 12:21 ` [Outreachy kernel] " Greg KH
@ 2015-03-20 22:16   ` Ioana Ciornei
  0 siblings, 0 replies; 3+ messages in thread
From: Ioana Ciornei @ 2015-03-20 22:16 UTC (permalink / raw)
  To: Greg KH; +Cc: outreachy-kernel

On Fri, Mar 20, 2015 at 2:21 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Mar 18, 2015 at 03:50:07PM +0200, Ioana Ciornei wrote:
> > 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
> >
> > Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
> > ---
> >
> > Changes in v3:
> >       - fixed corrupted patch
>
> Please resend this again, after fixing the obvious build errors with it
> :(
>
> ALWAYS test build your patches, to not do so annoys the people you send
> them to, as it breaks their workflow, and is a bit rude.
>
> thanks,
>
> greg k-h

I am very sorry. I will resend the patch.

Ioana


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-20 22:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-18 13:50 [PATCH v3] staging: p80211conv: Replace memcpy with ether_addr_copy Ioana Ciornei
2015-03-20 12:21 ` [Outreachy kernel] " Greg KH
2015-03-20 22:16   ` Ioana Ciornei

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.