staging: rtl8192u: ieee80211: Replace list_for_each with list_for_each_entry
PATCH 1/1 staging: rtl8192u: ieee80211: Replace list_for_each with list_for_each_entry
list_for_each is a macro that iterates over the elements of a list. list_entry is a function that takes as argument a list pointer and returns the structure that is pointed to. list_for_each_entry is a macro that iterates over the structures in the list, rather than exposing the list spine.
Here the list is only used for its entries, and thus list_for_each_entry can be used instead of the composition of list_for_each and list_entry.
This patch is with the help of following Coccinelle script:
@@
expression l, list;
type t1, t2;
identifier p, v;
iterator name list_for_each_entry, list_for_each;
@@
- t1 *p;
...
- list_for_each(p, l)
+ list_for_each_entry(v, l, list)
{
... when != p
- v = list_entry(p, t2, list);
... when != p
}
--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +1 -3
@@ -447,13 +447,11 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,switch (ieee->iw_mode) {case IW_MODE_ADHOC : { -struct list_head *p;struct ieee_ibss_seq *entry =NULL ;u8 *mac = header->addr2;int index = mac[5 ] %IEEE_IBSS_MAC_HASH_SIZE ; -list_for_each (p, &ieee->ibss_mac_hash[index]) { - entry = list_entry(p, struct ieee_ibss_seq, list); +list_for_each_entry (entry, &ieee->ibss_mac_hash[index], list) {if (!memcmp (entry->mac, mac,ETH_ALEN ))break ; }
Signature · 1 line
2.7.4
Quoted 43 lines · Aastha Gupta
list_for_eachis a macro that iterates over the elements of a list.list_entryis a function that takes as argument a list pointer and returns the structure that is pointed to.list_for_each_entryis a macro that iterates over the structures in the list, rather than exposing the list spine.Here the list is only used for its entries, and thus
list_for_each_entrycan be used instead of the composition oflist_for_eachandlist_entry.This patch is with the help of following Coccinelle script:
@@
expression l, list;
type t1, t2;
identifier p, v;
iterator namelist_for_each_entry,list_for_each;
@@- t1 *p;
...
-list_for_each(p, l)
+list_for_each_entry(v, l, list)
{
... when != p
- v =list_entry(p, t2, list);
... when != p
}Signed-off-by Aastha Gupta <[email protected]>--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +0
-1@@ -447,13 +447,11 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,switch (ieee->iw_mode) {case IW_MODE_ADHOC : { -struct list_head *p;
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c static int is_duplicate_packet(struct ieee80211_device *ieee, · line 457
Quoted 10 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +1
-2struct ieee_ibss_seq *entry =NULL ;u8 *mac = header->addr2;int index = mac[5 ] %IEEE_IBSS_MAC_HASH_SIZE ; -list_for_each (p, &ieee->ibss_mac_hash[index]) { - entry = list_entry(p, struct ieee_ibss_seq, list); +list_for_each_entry (entry, &ieee->ibss_mac_hash[index], list) {if (!memcmp (entry->mac, mac,ETH_ALEN ))break ; }
You can also drop the braces.
julia
Quoted 10 lines
--
2.7.4--
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/1507401578-26613-1-git-send-email-aastha.gupta4104%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 60 lines · Julia Lawall
Quoted 43 lines · Aastha Gupta
list_for_eachis a macro that iterates over the elements of a list.list_entryis a function that takes as argument a list pointer and returns the structure that is pointed to.list_for_each_entryis a macro that iterates over the structures in the list, rather than exposing the list spine.Here the list is only used for its entries, and thus
list_for_each_entrycan be used instead of the composition oflist_for_eachandlist_entry.This patch is with the help of following Coccinelle script:
@@
expression l, list;
type t1, t2;
identifier p, v;
iterator namelist_for_each_entry,list_for_each;
@@- t1 *p;
...
-list_for_each(p, l)
+list_for_each_entry(v, l, list)
{
... when != p
- v =list_entry(p, t2, list);
... when != p
}Signed-off-by Aastha Gupta <[email protected]>--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +0
-1@@ -447,13 +447,11 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,switch (ieee->iw_mode) {case IW_MODE_ADHOC : { -struct list_head *p;drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c static int is_duplicate_packet(struct ieee80211_device *ieee, · line 457
Quoted 10 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +1
-2struct ieee_ibss_seq *entry =NULL ;u8 *mac = header->addr2;int index = mac[5 ] %IEEE_IBSS_MAC_HASH_SIZE ; -list_for_each (p, &ieee->ibss_mac_hash[index]) { - entry = list_entry(p, struct ieee_ibss_seq, list); +list_for_each_entry (entry, &ieee->ibss_mac_hash[index], list) {if (!memcmp (entry->mac, mac,ETH_ALEN ))break ; }You can also drop the braces.
Quoted 1 line
julia
Braces after the list_for_each_entry in ieee80211_rx.c ?
Quoted 11 lines
Quoted 11 lines
--
2.7.4--
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/1507401578-26613-1-git-send-email-aastha.gupta4104%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 61 lines · Aastha Gupta
Quoted 60 lines · Julia Lawall
Quoted 43 lines · Aastha Gupta
list_for_eachis a macro that iterates over the elements of a list.list_entryis a function that takes as argument a list pointer and returns the structure that is pointed to.list_for_each_entryis a macro that iterates over the structures in the list, rather than exposing the list spine.Here the list is only used for its entries, and thus
list_for_each_entrycan be used instead of the composition oflist_for_eachandlist_entry.This patch is with the help of following Coccinelle script:
@@
expression l, list;
type t1, t2;
identifier p, v;
iterator namelist_for_each_entry,list_for_each;
@@- t1 *p;
...
-list_for_each(p, l)
+list_for_each_entry(v, l, list)
{
... when != p
- v =list_entry(p, t2, list);
... when != p
}Signed-off-by Aastha Gupta <[email protected]>--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +0
-1@@ -447,13 +447,11 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,switch (ieee->iw_mode) {case IW_MODE_ADHOC : { -struct list_head *p;drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c static int is_duplicate_packet(struct ieee80211_device *ieee, · line 457
Quoted 10 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +1
-2struct ieee_ibss_seq *entry =NULL ;u8 *mac = header->addr2;int index = mac[5 ] %IEEE_IBSS_MAC_HASH_SIZE ; -list_for_each (p, &ieee->ibss_mac_hash[index]) { - entry = list_entry(p, struct ieee_ibss_seq, list); +list_for_each_entry (entry, &ieee->ibss_mac_hash[index], list) {if (!memcmp (entry->mac, mac,ETH_ALEN ))break ; }You can also drop the braces.
Quoted 3 lines
Quoted 1 line
julia
Braces after the
list_for_each_entryinieee80211_rx.c?
Yes. The body of the loop is a single statement.
julia
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
--
2.7.4--
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/1507401578-26613-1-git-send-email-aastha.gupta4104%40gmail.com.
For more options, visit https://groups.google.com/d/optout.