All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] staging: p80211conv: Replace memcpy with ether_addr_copy
@ 2015-03-17 23:10 Ioana Ciornei
  2015-03-18 10:19 ` [Outreachy kernel] " Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Ioana Ciornei @ 2015-03-17 23:10 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 v2:
	- added explanations on why the addresses are aligned

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

diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index bd69e8c..a51fbfe 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -62,6 +62,7 @@
 #include <linux/etherdevice.h>
 #include <linux/if_ether.h>
 #include <linux/byteorder/generic.h>

 #include <asm/byteorder.h>
 
@@ -178,21 +179,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 +242,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 v2] staging: p80211conv: Replace memcpy with ether_addr_copy
  2015-03-17 23:10 [PATCH v2] staging: p80211conv: Replace memcpy with ether_addr_copy Ioana Ciornei
@ 2015-03-18 10:19 ` Greg KH
  2015-03-18 13:51   ` Ioana Ciornei
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2015-03-18 10:19 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: outreachy-kernel

On Wed, Mar 18, 2015 at 01:10:58AM +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 v2:
> 	- added explanations on why the addresses are aligned
> 
>  drivers/staging/wlan-ng/p80211conv.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
> index bd69e8c..a51fbfe 100644
> --- a/drivers/staging/wlan-ng/p80211conv.c
> +++ b/drivers/staging/wlan-ng/p80211conv.c
> @@ -62,6 +62,7 @@
>  #include <linux/etherdevice.h>
>  #include <linux/if_ether.h>
>  #include <linux/byteorder/generic.h>
> 
>  #include <asm/byteorder.h>
>  
> @@ -178,21 +179,21 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,

This patch is corrupted, it looks like you edited it by hand, which is
fine if you know the format, but when you don't, it breaks the tool and
can not be applied.

Look at that hunk above, it doesn't do anything, which is a hint that
something bad went wrong :(

Please fix up and resend.

thanks,

greg k-h


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

* Re: [Outreachy kernel] [PATCH v2] staging: p80211conv: Replace memcpy with ether_addr_copy
  2015-03-18 10:19 ` [Outreachy kernel] " Greg KH
@ 2015-03-18 13:51   ` Ioana Ciornei
  0 siblings, 0 replies; 3+ messages in thread
From: Ioana Ciornei @ 2015-03-18 13:51 UTC (permalink / raw)
  To: Greg KH; +Cc: outreachy-kernel

On Wed, Mar 18, 2015 at 12:19 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Mar 18, 2015 at 01:10:58AM +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 v2:
> >       - added explanations on why the addresses are aligned
> >
> >  drivers/staging/wlan-ng/p80211conv.c | 21 +++++++++++----------
> >  1 file changed, 11 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
> > index bd69e8c..a51fbfe 100644
> > --- a/drivers/staging/wlan-ng/p80211conv.c
> > +++ b/drivers/staging/wlan-ng/p80211conv.c
> > @@ -62,6 +62,7 @@
> >  #include <linux/etherdevice.h>
> >  #include <linux/if_ether.h>
> >  #include <linux/byteorder/generic.h>
> >
> >  #include <asm/byteorder.h>
> >
> > @@ -178,21 +179,21 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
>
> This patch is corrupted, it looks like you edited it by hand, which is
> fine if you know the format, but when you don't, it breaks the tool and
> can not be applied.
>
> Look at that hunk above, it doesn't do anything, which is a hint that
> something bad went wrong :(
>
> Please fix up and resend.
>
> thanks,
>
> greg k-h

Sorry for that. I fixed it and resent the patch.

Ioana


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

end of thread, other threads:[~2015-03-18 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-17 23:10 [PATCH v2] staging: p80211conv: Replace memcpy with ether_addr_copy Ioana Ciornei
2015-03-18 10:19 ` [Outreachy kernel] " Greg KH
2015-03-18 13:51   ` 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.