Drivers: staging: wlan-ng: p80211conv: replaced functions for copying/comparing ethernet addresses
PATCH 1/1 Drivers: staging: wlan-ng: p80211conv: replaced functions for copying/comparing ethernet addresses
Replaced the function memcpy() by ether_addr_copy() and, memcmp() by ether_addr_equal() as these functions are more preferable for copying and comparing the ethernet addresses respectively.
Also fixed the issue of character limit of 80 per line and removed one unnecessary statement.
--- drivers/staging/wlan-ng/p80211conv.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/staging/wlan-ng/p80211conv.c +13 -13
@@ -178,21 +178,23 @@ 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,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a2, wlandev->netdev->dev_addr, +ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a3, wlandev->bssid,ETH_ALEN );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,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a2, wlandev->netdev->dev_addr, +ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a3, &e_hdr.daddr,ETH_ALEN );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,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a2, wlandev->bssid,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a3, &e_hdr.saddr,ETH_ALEN );break ;default : netdev_err(wlandev->netdev,
@@ -242,8 +244,8 @@ 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 ); +if (!ether_addr_equal (wlandev->spy_address[i], mac,ETH_ALEN )) { +ether_addr_copy (wlandev->spy_address[i], mac,ETH_ALEN ); wlandev->spy_stat[i].level = rxmeta->signal; wlandev->spy_stat[i].noise = rxmeta->noise; wlandev->spy_stat[i].qual =
@@ -614,8 +616,6 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb) rxmeta =kzalloc (sizeof (struct p80211_rxmeta ),GFP_ATOMIC );if (rxmeta ==NULL ) { -netdev_err (wlandev->netdev, -"%s: Failed to allocate rxmeta.\n" , wlandev->name); result =1 ; goto exit; }
Signature · 1 line
2.1.0
Greg KH
maintainerQuoted 5 lines · Shivani Bhardwaj
Replaced the function
memcpy()byether_addr_copy()and,memcmp()byether_addr_equal()as these functions are more preferable for copying and comparing the ethernet addresses respectively.
Also fixed the issue of character limit of 80 per line and removed one unnecessary statement.
When you start listing "other" things you did in a patch, that's a huge sign that you need to split this up into different patches. Remember, it's "only one thing per patch".
Also, you can't just do a search/replace for ether_addr_equal(), otherwise we would have done that a long time ago. You have to be able to prove that this function will work properly, and that depends on knowing the layout of the structure to ensure that everything is aligned properly. Look at how other people have made this change in the drivers/staging/ tree in the past for the type of proof that I need in order to accept this change.
thanks,
greg k-h
If you look at git log --oneline for this file, it seems that Staging:
wlan-ng: is preferred for this file, rather than Drivers: staging:
wlan-ng: p80211conv:.
Quoted 5 lines · Shivani Bhardwaj
Replaced the function
memcpy()byether_addr_copy()and,memcmp()byether_addr_equal()as these functions are more preferable for copying and comparing the ethernet addresses respectively.
Also fixed the issue of character limit of 80 per line and removed one unnecessary statement.
The removed statement is related to logging on kzalloc. It has nothing to do with the other changes, so it should not be in the same patch.
julia
Quoted 72 lines
Signed-off-by Shivani Bhardwaj <[email protected]>--- drivers/staging/wlan-ng/p80211conv.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)drivers/staging/wlan-ng/p80211conv.c +13
-13@@ -178,21 +178,23 @@ 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,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a2, wlandev->netdev->dev_addr, +ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a3, wlandev->bssid,ETH_ALEN );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,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a2, wlandev->netdev->dev_addr, +ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a3, &e_hdr.daddr,ETH_ALEN );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,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a2, wlandev->bssid,ETH_ALEN ); +ether_addr_copy (p80211_hdr->a3.a3, &e_hdr.saddr,ETH_ALEN );break ;default : netdev_err(wlandev->netdev,@@ -242,8 +244,8 @@ 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 ); +if (!ether_addr_equal (wlandev->spy_address[i], mac,ETH_ALEN )) { +ether_addr_copy (wlandev->spy_address[i], mac,ETH_ALEN ); wlandev->spy_stat[i].level = rxmeta->signal; wlandev->spy_stat[i].noise = rxmeta->noise; wlandev->spy_stat[i].qual =@@ -614,8 +616,6 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb) rxmeta =kzalloc (sizeof (struct p80211_rxmeta ),GFP_ATOMIC );if (rxmeta ==NULL ) { -netdev_err (wlandev->netdev, -"%s: Failed to allocate rxmeta.\n" , wlandev->name); result =1 ; goto exit; }Signature · 8 lines
2.1.0 -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20150929221607.GA15184%40ubuntu. For more options, visit https://groups.google.com/d/optout.
A message that is not in the archive (sent off-list or not yet received): CAKHNQQFv07V3NZdJk3CQQBjmUgdr-3viHh-pG-r7vfHidTKkdg@mail.gmail.com
Thanks Greg, Julia! I'll keep in mind.
Quoted 119 lines · Shivani Bhardwaj
Thanks Greg, Julia! I'll keep in mind.
Quoted 112 lines · Julia Lawall
If you look at git log --oneline for this file, it seems that Staging:
wlan-ng: is preferred for this file, rather than Drivers: staging:
wlan-ng: p80211conv:.Quoted 5 lines · Shivani Bhardwaj
Replaced the function
memcpy()byether_addr_copy()and,memcmp()byether_addr_equal()as these functions are more preferable for copying and comparing the ethernet addresses respectively.
Also fixed the issue of character limit of 80 per line and removed one unnecessary statement.The removed statement is related to logging on kzalloc. It has nothing to do with the other changes, so it should not be in the same patch.
julia
Review
Quoted 6 lines
Signed-off-by Shivani Bhardwaj <[email protected]>--- drivers/staging/wlan-ng/p80211conv.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)(quoted diff) +0
-0
b/drivers/staging/wlan-ng/p80211conv.cdrivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev,
Quoted 4 lines
index 49f2ef8..9c4dba6 100644
drivers/staging/wlan-ng/p80211conv.c +0
-0@@ -178,21 +178,23 @@ int skb_ether_to_p80211(wlandevice_t *wlandev,u32 ethconv,
drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
Quoted 5 lines
drivers/staging/wlan-ng/p80211conv.c +0
-2switch (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);drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, · line 180
Quoted 2 lines
drivers/staging/wlan-ng/p80211conv.c +1
-1-memcpy (p80211_hdr->a3.a3, wlandev->bssid,ETH_ALEN ); + ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr,
ETH_ALEN);drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, · line 181
Quoted 1 line
drivers/staging/wlan-ng/p80211conv.c +1
-0+ ether_addr_copy(p80211_hdr->a3.a2,
wlandev->netdev->dev_addr,drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, · line 183
Quoted 2 lines
drivers/staging/wlan-ng/p80211conv.c +2
-0+ ETH_ALEN); + ether_addr_copy(p80211_hdr->a3.a3, wlandev->bssid,
ETH_ALEN);drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
Quoted 5 lines
drivers/staging/wlan-ng/p80211conv.c +0
-2break ;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);drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, · line 187
Quoted 2 lines
drivers/staging/wlan-ng/p80211conv.c +1
-1-memcpy (p80211_hdr->a3.a3, &e_hdr.daddr,ETH_ALEN ); + ether_addr_copy(p80211_hdr->a3.a1, wlandev->bssid,
ETH_ALEN);drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, · line 188
Quoted 1 line
drivers/staging/wlan-ng/p80211conv.c +1
-0+ ether_addr_copy(p80211_hdr->a3.a2,
wlandev->netdev->dev_addr,drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, · line 190
Quoted 2 lines
drivers/staging/wlan-ng/p80211conv.c +2
-0+ ETH_ALEN); + ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.daddr,
ETH_ALEN);drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
Quoted 7 lines
drivers/staging/wlan-ng/p80211conv.c +1
-3break ;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,
ETH_ALEN);drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, · line 195
Quoted 1 line
drivers/staging/wlan-ng/p80211conv.c +1
-0+ ether_addr_copy(p80211_hdr->a3.a2, wlandev->bssid,
ETH_ALEN);drivers/staging/wlan-ng/p80211conv.c int skb_ether_to_p80211(wlandevice_t *wlandev, · line 196
Quoted 1 line
drivers/staging/wlan-ng/p80211conv.c +1
-0+ ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.saddr,
ETH_ALEN);drivers/staging/wlan-ng/p80211conv.c static void orinoco_spy_gather(wlandevice_t
Quoted 4 lines
drivers/staging/wlan-ng/p80211conv.c +0
-0break ;default : netdev_err(wlandev->netdev,@@ -242,8 +244,8 @@ static void orinoco_spy_gather(wlandevice_t*wlandev, char *mac,
drivers/staging/wlan-ng/p80211conv.c static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
Quoted 6 lines
drivers/staging/wlan-ng/p80211conv.c +1
-2for (i = 0; i < wlandev->spy_number; i++) { -if (!memcmp (wlandev->spy_address[i], mac,ETH_ALEN )) { -memcpy (wlandev->spy_address[i], mac,ETH_ALEN ); + if (!ether_addr_equal(wlandev->spy_address[i], mac,
ETH_ALEN)) {drivers/staging/wlan-ng/p80211conv.c static void orinoco_spy_gather(wlandevice_t · line 247
Quoted 1 line
drivers/staging/wlan-ng/p80211conv.c +1
-0+ ether_addr_copy(wlandev->spy_address[i], mac,
ETH_ALEN);drivers/staging/wlan-ng/p80211conv.c int p80211skb_rxmeta_attach(struct wlandevice
Quoted 4 lines
drivers/staging/wlan-ng/p80211conv.c +0
-0wlandev->spy_stat[i].level = rxmeta->signal; wlandev->spy_stat[i].noise = rxmeta->noise; wlandev->spy_stat[i].qual =@@ -614,8 +616,6 @@ int p80211skb_rxmeta_attach(struct wlandevice*wlandev, struct
sk_buff*skb)drivers/staging/wlan-ng/p80211conv.c int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
Quoted 5 lines
drivers/staging/wlan-ng/p80211conv.c +0
-2rxmeta =kzalloc (sizeof (struct p80211_rxmeta ),GFP_ATOMIC );if (rxmeta ==NULL ) { - netdev_err(wlandev->netdev, - "%s: Failed to allocate rxmeta.\n",
wlandev->name);Quoted 8 lines
drivers/staging/wlan-ng/p80211conv.c +0
-1result =1 ; goto exit; } --2.1.0
--
You received this message because you are subscribed to the GoogleGroups "outreachy-kernel" group.
Quoted 1 line
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
Quoted 2 lines
To post to this group, send email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/20150929221607.GA15184%40ubuntu
.Quoted 2 lines
For more options, visit https://groups.google.com/d/optout.