Staging: rtl8188eu: Replace for statement with list_for_each
PATCH 1/1 Staging: rtl8188eu: Replace for statement with list_for_each
The macro list_for_each is used to iterate over a linked list and here the for statement is doing the same. Therefore replace the for statement with list_for_each macro.
Done using coccinelle:
@@
struct list_head *pos;
struct list_head *head;
statement S;
iterator name list_for_each;
iterator name list_for_each_prev;
@@
(
- for (pos = (head)->prev; pos != (head); pos = pos->prev)S
+ list_for_each_prev(pos,head)S
|
- for (pos = (head)->next; pos != (head); pos = pos->next)S
+ list_for_each(pos,head)S
)
--- drivers/staging/rtl8188eu/core/rtw_mlme.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8188eu/core/rtw_mlme.c +1 -2
@@ -361,9 +361,8 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) phead =get_list_head (scanned_queue); -for (plist = phead->next; plist != phead; plist = plist->next) { +list_for_each (plist, phead) { pwlan = container_of(plist, struct wlan_network, list); -if (!pwlan->fixed) {if (oldest ==NULL ||time_after (oldest->last_scanned, pwlan->last_scanned)) oldest = pwlan;
Signature · 1 line
1.9.1
Quoted 31 lines · Bhumika Goyal
The macro
list_for_eachis used to iterate over a linked list and here the for statement is doing the same. Therefore replace the for statement withlist_for_eachmacro.
Done using coccinelle:@@
structlist_head*pos;
structlist_head*head;
statement S;
iterator namelist_for_each;
iterator namelist_for_each_prev;@@
(
- for (pos = (head)->prev; pos != (head); pos = pos->prev)S
+ list_for_each_prev(pos,head)S
|
- for (pos = (head)->next; pos != (head); pos = pos->next)S
+ list_for_each(pos,head)S
)Signed-off-by Bhumika Goyal <[email protected]>--- drivers/staging/rtl8188eu/core/rtw_mlme.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/rtl8188eu/core/rtw_mlme.c +0
-0
drivers/staging/rtl8188eu/core/rtw_mlme.c struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) · line 365
Quoted 6 lines
drivers/staging/rtl8188eu/core/rtw_mlme.c +1
-1@@ -361,9 +361,8 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) phead =get_list_head (scanned_queue); -for (plist = phead->next; plist != phead; plist = plist->next) { +list_for_each (plist, phead) { pwlan = container_of(plist, struct wlan_network, list);
I think that this should be list_entry rather than container_of.
julia
Quoted 14 lines
drivers/staging/rtl8188eu/core/rtw_mlme.c +0
-2-if (!pwlan->fixed) {if (oldest ==NULL ||time_after (oldest->last_scanned, pwlan->last_scanned)) oldest = pwlan; --1.9.1
--
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/1456498279-13486-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.