staging: rtl8723au: core: rtw_mlme.c: Prefer list_for_each_entry()
PATCH v2 1/1 staging: rtl8723au: core: rtw_mlme.c: Prefer list_for_each_entry()
Use list_for_each_entry() rather than a combination of list_for_each() and container_of(). Also remove variable plist as it becomes useless after the transformation.
Semantic patch:
@a@
expression pos, head;
expression mem;
type t;
identifier var;
iterator name list_for_each_entry, list_for_each;
@@
- list_for_each(pos, head)
+ list_for_each_entry(var, head, mem)
{
... when != var
- var = \(list_entry \| container_of\)(pos, t, mem); ... when != pos
}
Signed-off-by Janani Ravichandran <[email protected]>
---
Changes since v2:
*Removed variable plist
*Changed semantic patch
drivers/staging/rtl8723au/core/rtw_mlme.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rtl8723au/core/rtw_mlme.c +2 -4
@@ -426,7 +426,7 @@ Caller must hold pmlmepriv->lock first.static void rtw_update_scanned_network (struct rtw_adapter *adapter,struct wlan_bssid_ex *target) { -struct list_head *plist, *phead; +struct list_head *phead;struct mlme_priv *pmlmepriv = &adapter->mlmepriv;struct wlan_network *pnetwork =NULL ;struct wlan_network *oldest =NULL ;
@@ -436,9 +436,7 @@ static void rtw_update_scanned_network(struct rtw_adapter *adapter,spin_lock_bh (&queue->lock); phead =get_list_head (queue); -list_for_each (plist, phead) { - pnetwork = container_of(plist, struct wlan_network, list); - +list_for_each_entry (pnetwork, phead, list) {if (is_same_network23a (&pnetwork->network, target)) { found =1 ;break ;
Signature · 1 line
2.5.0