Skip to contentSkip to conversation

staging: rtl8723au: os_dep: Use list_for_each_entry_safe()

PATCH New Janani Ravichandran 1 participant 1 message Feb 28, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: rtl8723au: os_dep: Use list_for_each_entry_safe()

Use list_for_each_entry_safe() rather than a combination of list_for_each_safe() and container_of(). Also, remove variable plist which becomes useless as a result.
Semantic patch used:

@a@
expression pos, n, head;
expression mem;
type t;
identifier var;
iterator name list_for_each_entry_safe, list_for_each_safe; @@

- list_for_each_safe(pos, n, head)
+ list_for_each_entry_safe(var, n, head, mem) {
... when != var
- var = \(list_entry \| container_of\)(pos, t, mem); ... when != pos
}

---
Changes since v1:
*Removed variable plist.
*Changed semantic patch.

 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +2 -3
index 908b84c..b4bcaa8 100644
@@ -1945,7 +1945,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 				struct cfg80211_connect_params *sme)
 {
 	int ret = 0;
-	struct list_head *phead, *plist, *ptmp;
+	struct list_head *phead, *ptmp;
 	struct wlan_network *pnetwork = NULL;
 	/* u8 matched_by_bssid = false; */
 	/* u8 matched_by_ssid = false; */
@@ -1994,8 +1994,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 
 	phead = get_list_head(queue);
 
-	list_for_each_safe(plist, ptmp, phead) {
-		pnetwork = container_of(plist, struct wlan_network, list);
+	list_for_each_entry_safe(pnetwork, ptmp, phead, list) {
 
 		if (sme->bssid) {
 			if (!ether_addr_equal(pnetwork->network.MacAddress,
Signature · 1 line
2.5.0