Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe
PATCH v2 1/1 Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe
This is a cleanup patch and doesn't change runtime behaviour. It changes an open coded list traversal to use list_for_each_entry_safe. Done using the following semantic patch by coccinelle.
@r@
struct list_head* l;
expression e;
identifier m,list_del_init,f;
type T1;
T1* pos;
iterator name list_for_each_entry_safe;
@@
f(...){
+T1* tmp;
<+...
-while(...)
+list_for_each_entry_safe(pos,tmp,l,m)
{
...
-pos = container_of(l,T1,m);
...
-l=e;
<+...
list_del_init(&pos->m)
...+>
}
...+>
}
Signed-off-by Srishti Sharma <[email protected]>
---
Changes in v2
-Make commit message more clear.
-Add file name to the subject.
drivers/staging/rtl8188eu/core/rtw_ap.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/staging/rtl8188eu/core/rtw_ap.c +3 -9
@@ -280,7 +280,7 @@ void expire_timeout_chk(struct adapter *padapter) {struct list_head *phead, *plist;u8 updated =0 ; -struct sta_info *psta =NULL ; +struct sta_info *psta =NULL , *tmp;struct sta_priv *pstapriv = &padapter->stapriv;u8 chk_alive_num =0 ;char chk_alive_list[NUM_STA ];
@@ -292,10 +292,7 @@ void expire_timeout_chk(struct adapter *padapter) plist = phead->next;/* check auth_queue */ -while (phead != plist) { - psta = container_of(plist, struct sta_info, auth_list); - plist = plist->next; - +list_for_each_entry_safe (psta, tmp, plist, auth_list) {if (psta->expire_to >0 ) { psta->expire_to--;if (psta->expire_to ==0 ) {
@@ -326,10 +323,7 @@ void expire_timeout_chk(struct adapter *padapter) plist = phead->next;/* check asoc_queue */ -while (phead != plist) { - psta = container_of(plist, struct sta_info, asoc_list); - plist = plist->next; - +list_for_each_entry_safe (psta, tmp, plist, asoc_list) {if (chk_sta_is_alive (psta) || !psta->expire_to) { psta->expire_to = pstapriv->expire_to; psta->keep_alive_trycnt =0 ;
Signature · 1 line
2.7.4