Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742536 > unrolled thread

[PATCH 0/6] Replace container_of with list_entry

Started bySrishti Sharma <srishtishar@gmail.com>
First post2017-09-30 09:20 +0200
Last post2017-09-30 13:20 +0200
Articles 9 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/6] Replace container_of with list_entry Srishti Sharma <srishtishar@gmail.com> - 2017-09-30 09:20 +0200
    [PATCH 1/6] Staging: rtl8188eu: core: Use list_entry instead of container_of Srishti Sharma <srishtishar@gmail.com> - 2017-09-30 09:20 +0200
    [PATCH 2/6] Staging: rtl8188eu: core: Use list_entry instead of container_of Srishti Sharma <srishtishar@gmail.com> - 2017-09-30 09:20 +0200
    [PATCH 3/6] Staging: rtl8188eu: core: Use list_entry instead of container_of Srishti Sharma <srishtishar@gmail.com> - 2017-09-30 09:30 +0200
    [PATCH 4/6] Staging: rtl8188eu: core: Use list_entry instead of container_of Srishti Sharma <srishtishar@gmail.com> - 2017-09-30 09:30 +0200
    [PATCH 6/6] Staging: rtl8188eu: core: Use list_entry instead of container_of Srishti Sharma <srishtishar@gmail.com> - 2017-09-30 09:30 +0200
      Re: [Outreachy kernel] [PATCH 6/6] Staging: rtl8188eu: core: Use  list_entry instead of container_of Julia Lawall <julia.lawall@lip6.fr> - 2017-09-30 10:40 +0200
    [PATCH 5/6] Staging: rtl8188eu: core: Use list_entry instead of container_of Srishti Sharma <srishtishar@gmail.com> - 2017-09-30 09:30 +0200
    Re: [PATCH 0/6] Replace container_of with list_entry "Tobin C. Harding" <me@tobin.cc> - 2017-09-30 13:20 +0200

#1742536 — [PATCH 0/6] Replace container_of with list_entry

FromSrishti Sharma <srishtishar@gmail.com>
Date2017-09-30 09:20 +0200
Subject[PATCH 0/6] Replace container_of with list_entry
Message-ID<uvke5-YT-5@gated-at.bofh.it>
Replaces instances of container_of with list_entry to 
access current list element.

Srishti Sharma (6):
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of

 drivers/staging/rtl8188eu/core/rtw_ap.c       | 14 +++++++-------
 drivers/staging/rtl8188eu/core/rtw_mlme.c     |  8 ++++----
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c |  4 ++--
 drivers/staging/rtl8188eu/core/rtw_recv.c     | 14 +++++++-------
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c  | 12 ++++++------
 drivers/staging/rtl8188eu/core/rtw_xmit.c     | 14 +++++++-------
 6 files changed, 33 insertions(+), 33 deletions(-)

-- 
2.7.4

[toc] | [next] | [standalone]


#1742540 — [PATCH 1/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

FromSrishti Sharma <srishtishar@gmail.com>
Date2017-09-30 09:20 +0200
Subject[PATCH 1/6] Staging: rtl8188eu: core: Use list_entry instead of container_of
Message-ID<uvke6-YT-21@gated-at.bofh.it>
In reply to#1742536
For variables of the struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 3fd5f41..af59c16 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -193,7 +193,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,  struct __queue *pfre
 	plist = phead->next;
 
 	while (phead != plist) {
-		hdr = container_of(plist, struct recv_frame, list);
+		hdr = list_entry(plist, struct recv_frame, list);
 
 		plist = plist->next;
 
@@ -943,7 +943,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter,
 			xmitframe_plist = xmitframe_phead->next;
 
 			if (xmitframe_phead != xmitframe_plist) {
-				pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
+				pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
 
 				xmitframe_plist = xmitframe_plist->next;
 
@@ -1347,7 +1347,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
 
 	phead = get_list_head(defrag_q);
 	plist = phead->next;
-	pfhdr = container_of(plist, struct recv_frame, list);
+	pfhdr = list_entry(plist, struct recv_frame, list);
 	prframe = pfhdr;
 	list_del_init(&(prframe->list));
 
@@ -1367,7 +1367,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
 	plist = plist->next;
 
 	while (phead != plist) {
-		pnfhdr = container_of(plist, struct recv_frame, list);
+		pnfhdr = list_entry(plist, struct recv_frame, list);
 		pnextrframe = pnfhdr;
 
 		/* check the fragment sequence  (2nd ~n fragment frame) */
@@ -1655,7 +1655,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
 	plist = phead->next;
 
 	while (phead != plist) {
-		hdr = container_of(plist, struct recv_frame, list);
+		hdr = list_entry(plist, struct recv_frame, list);
 		pnextattrib = &hdr->attrib;
 
 		if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
@@ -1690,7 +1690,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor
 		if (list_empty(phead))
 			return true;
 
-		prhdr = container_of(plist, struct recv_frame, list);
+		prhdr = list_entry(plist, struct recv_frame, list);
 		pattrib = &prhdr->attrib;
 		preorder_ctrl->indicate_seq = pattrib->seq_num;
 	}
@@ -1698,7 +1698,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor
 	/*  Prepare indication list and indication. */
 	/*  Check if there is any packet need indicate. */
 	while (!list_empty(phead)) {
-		prhdr = container_of(plist, struct recv_frame, list);
+		prhdr = list_entry(plist, struct recv_frame, list);
 		prframe = prhdr;
 		pattrib = &prframe->attrib;
 
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1742541 — [PATCH 2/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

FromSrishti Sharma <srishtishar@gmail.com>
Date2017-09-30 09:20 +0200
Subject[PATCH 2/6] Staging: rtl8188eu: core: Use list_entry instead of container_of
Message-ID<uvke6-YT-27@gated-at.bofh.it>
In reply to#1742536
For variables of the type struct list_head use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 22cf362..f9df4ac 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -152,8 +152,8 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
 			while (phead != plist) {
 				int i;
 
-				psta = container_of(plist, struct sta_info,
-						    hash_list);
+				psta = list_entry(plist, struct sta_info,
+						  hash_list);
 				plist = plist->next;
 
 				for (i = 0; i < 16; i++) {
@@ -323,7 +323,7 @@ u32	rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta)
 		plist = phead->next;
 
 		while (!list_empty(phead)) {
-			prframe = container_of(plist, struct recv_frame, list);
+			prframe = list_entry(plist, struct recv_frame, list);
 
 			plist = plist->next;
 
@@ -399,7 +399,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
 		plist = phead->next;
 
 		while (phead != plist) {
-			psta = container_of(plist, struct sta_info, hash_list);
+			psta = list_entry(plist, struct sta_info, hash_list);
 
 			plist = plist->next;
 
@@ -435,7 +435,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
 	plist = phead->next;
 
 	while (phead != plist) {
-		psta = container_of(plist, struct sta_info, hash_list);
+		psta = list_entry(plist, struct sta_info, hash_list);
 
 		if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) {
 			/*  if found the matched address */
@@ -493,7 +493,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
 	phead = get_list_head(pacl_node_q);
 	plist = phead->next;
 	while (phead != plist) {
-		paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+		paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
 		plist = plist->next;
 
 		if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) {
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1742542 — [PATCH 3/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

FromSrishti Sharma <srishtishar@gmail.com>
Date2017-09-30 09:30 +0200
Subject[PATCH 3/6] Staging: rtl8188eu: core: Use list_entry instead of container_of
Message-ID<uvknL-12H-3@gated-at.bofh.it>
In reply to#1742536
For variables of the type struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
  (l,...)

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_mlme.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index f663e6c..71b1f8a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -198,7 +198,7 @@ struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr)
 	plist = phead->next;
 
 	while (plist != phead) {
-		pnetwork = container_of(plist, struct wlan_network, list);
+		pnetwork = list_entry(plist, struct wlan_network, list);
 		if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
 			break;
 		plist = plist->next;
@@ -223,7 +223,7 @@ void rtw_free_network_queue(struct adapter *padapter, u8 isfreeall)
 	plist = phead->next;
 
 	while (phead != plist) {
-		pnetwork = container_of(plist, struct wlan_network, list);
+		pnetwork = list_entry(plist, struct wlan_network, list);
 
 		plist = plist->next;
 
@@ -342,7 +342,7 @@ 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) {
-		pwlan = container_of(plist, struct wlan_network, list);
+		pwlan = list_entry(plist, struct wlan_network, list);
 
 		if (!pwlan->fixed) {
 			if (!oldest || time_after(oldest->last_scanned, pwlan->last_scanned))
@@ -421,7 +421,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t
 	plist = phead->next;
 
 	while (phead != plist) {
-		pnetwork	= container_of(plist, struct wlan_network, list);
+		pnetwork	= list_entry(plist, struct wlan_network, list);
 
 		if (is_same_network(&(pnetwork->network), target))
 			break;
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1742547 — [PATCH 4/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

FromSrishti Sharma <srishtishar@gmail.com>
Date2017-09-30 09:30 +0200
Subject[PATCH 4/6] Staging: rtl8188eu: core: Use list_entry instead of container_of
Message-ID<uvknM-12H-19@gated-at.bofh.it>
In reply to#1742536
For variables of the type struct list_head* use list_entry to access
current list element instead of using container_of. Done using the
following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_ap.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..35c03d8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -293,7 +293,7 @@ void	expire_timeout_chk(struct adapter *padapter)
 
 	/* check auth_queue */
 	while (phead != plist) {
-		psta = container_of(plist, struct sta_info, auth_list);
+		psta = list_entry(plist, struct sta_info, auth_list);
 		plist = plist->next;
 
 		if (psta->expire_to > 0) {
@@ -327,7 +327,7 @@ void	expire_timeout_chk(struct adapter *padapter)
 
 	/* check asoc_queue */
 	while (phead != plist) {
-		psta = container_of(plist, struct sta_info, asoc_list);
+		psta = list_entry(plist, struct sta_info, asoc_list);
 		plist = plist->next;
 
 		if (chk_sta_is_alive(psta) || !psta->expire_to) {
@@ -1149,7 +1149,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
 	plist = phead->next;
 
 	while (phead != plist) {
-		paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+		paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
 		plist = plist->next;
 
 		if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1209,7 +1209,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
 	plist = phead->next;
 
 	while (phead != plist) {
-		paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+		paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
 		plist = plist->next;
 
 		if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1456,7 +1456,7 @@ void associated_clients_update(struct adapter *padapter, u8 updated)
 
 		/* check asoc_queue */
 		while (phead != plist) {
-			psta = container_of(plist, struct sta_info, asoc_list);
+			psta = list_entry(plist, struct sta_info, asoc_list);
 
 			plist = plist->next;
 
@@ -1728,7 +1728,7 @@ int rtw_sta_flush(struct adapter *padapter)
 
 	/* free sta asoc_queue */
 	while (phead != plist) {
-		psta = container_of(plist, struct sta_info, asoc_list);
+		psta = list_entry(plist, struct sta_info, asoc_list);
 
 		plist = plist->next;
 
@@ -1856,7 +1856,7 @@ void stop_ap_mode(struct adapter *padapter)
 	phead = get_list_head(pacl_node_q);
 	plist = phead->next;
 	while (phead != plist) {
-		paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+		paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
 		plist = plist->next;
 
 		if (paclnode->valid) {
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1742549 — [PATCH 6/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

FromSrishti Sharma <srishtishar@gmail.com>
Date2017-09-30 09:30 +0200
Subject[PATCH 6/6] Staging: rtl8188eu: core: Use list_entry instead of container_of
Message-ID<uvknM-12H-29@gated-at.bofh.it>
In reply to#1742536
For variables of type struct list_head* use list_entry to access
current list element instead of using container_of. Done by the
following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
  (l,...)

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index be2f46e..29e9ee9 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -1401,7 +1401,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram
 	plist = phead->next;
 
 	while (phead != plist) {
-		pxmitframe = container_of(plist, struct xmit_frame, list);
+		pxmitframe = list_entry(plist, struct xmit_frame, list);
 
 		plist = plist->next;
 
@@ -1432,7 +1432,7 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, str
 	xmitframe_plist = xmitframe_phead->next;
 
 	if (xmitframe_phead != xmitframe_plist) {
-		pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
+		pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
 
 		xmitframe_plist = xmitframe_plist->next;
 
@@ -1473,7 +1473,7 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmi
 		sta_plist = sta_phead->next;
 
 		while (sta_phead != sta_plist) {
-			ptxservq = container_of(sta_plist, struct tx_servq, tx_pending);
+			ptxservq = list_entry(sta_plist, struct tx_servq, tx_pending);
 
 			pframe_queue = &ptxservq->sta_pending;
 
@@ -1811,7 +1811,7 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc
 	plist = phead->next;
 
 	while (phead != plist) {
-		pxmitframe = container_of(plist, struct xmit_frame, list);
+		pxmitframe = list_entry(plist, struct xmit_frame, list);
 
 		plist = plist->next;
 
@@ -1878,7 +1878,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
 	xmitframe_plist = xmitframe_phead->next;
 
 	while (xmitframe_phead != xmitframe_plist) {
-		pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
+		pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
 
 		xmitframe_plist = xmitframe_plist->next;
 
@@ -1959,7 +1959,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
 		xmitframe_plist = xmitframe_phead->next;
 
 		while (xmitframe_phead != xmitframe_plist) {
-			pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
+			pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
 
 			xmitframe_plist = xmitframe_plist->next;
 
@@ -2006,7 +2006,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst
 	xmitframe_plist = xmitframe_phead->next;
 
 	while (xmitframe_phead != xmitframe_plist) {
-		pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
+		pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
 
 		xmitframe_plist = xmitframe_plist->next;
 
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1742565 — Re: [Outreachy kernel] [PATCH 6/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

FromJulia Lawall <julia.lawall@lip6.fr>
Date2017-09-30 10:40 +0200
SubjectRe: [Outreachy kernel] [PATCH 6/6] Staging: rtl8188eu: core: Use list_entry instead of container_of
Message-ID<uvltv-1HL-1@gated-at.bofh.it>
In reply to#1742549

On Sat, 30 Sep 2017, Srishti Sharma wrote:

> For variables of type struct list_head* use list_entry to access
> current list element instead of using container_of. Done by the
> following semantic patch by coccinelle.
>
> @r@
> struct list_head* l;
> @@
>
> -container_of
> +list_entry
>   (l,...)
>
> Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
> ---
>  drivers/staging/rtl8188eu/core/rtw_xmit.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> index be2f46e..29e9ee9 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> @@ -1401,7 +1401,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram
>  	plist = phead->next;
>
>  	while (phead != plist) {
> -		pxmitframe = container_of(plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(plist, struct xmit_frame, list);
>
>  		plist = plist->next;

It looks to me like this loop could be rewritten using
list_for_each_entry_safe.  The entry is because you only do something
interesting with the entry and the safe is because the elements of the
list are deleted along the way.  Perhaps the others canbe changed this way
too.

julia



>
> @@ -1432,7 +1432,7 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, str
>  	xmitframe_plist = xmitframe_phead->next;
>
>  	if (xmitframe_phead != xmitframe_plist) {
> -		pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
>
>  		xmitframe_plist = xmitframe_plist->next;
>
> @@ -1473,7 +1473,7 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmi
>  		sta_plist = sta_phead->next;
>
>  		while (sta_phead != sta_plist) {
> -			ptxservq = container_of(sta_plist, struct tx_servq, tx_pending);
> +			ptxservq = list_entry(sta_plist, struct tx_servq, tx_pending);
>
>  			pframe_queue = &ptxservq->sta_pending;
>
> @@ -1811,7 +1811,7 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc
>  	plist = phead->next;
>
>  	while (phead != plist) {
> -		pxmitframe = container_of(plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(plist, struct xmit_frame, list);
>
>  		plist = plist->next;
>
> @@ -1878,7 +1878,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
>  	xmitframe_plist = xmitframe_phead->next;
>
>  	while (xmitframe_phead != xmitframe_plist) {
> -		pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
>
>  		xmitframe_plist = xmitframe_plist->next;
>
> @@ -1959,7 +1959,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
>  		xmitframe_plist = xmitframe_phead->next;
>
>  		while (xmitframe_phead != xmitframe_plist) {
> -			pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
> +			pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
>
>  			xmitframe_plist = xmitframe_plist->next;
>
> @@ -2006,7 +2006,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst
>  	xmitframe_plist = xmitframe_phead->next;
>
>  	while (xmitframe_phead != xmitframe_plist) {
> -		pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
>
>  		xmitframe_plist = xmitframe_plist->next;
>
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/778fb00439b44bd4a9e1ef06b1d619f9e4f5525f.1506755266.git.srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

[toc] | [prev] | [next] | [standalone]


#1742550 — [PATCH 5/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

FromSrishti Sharma <srishtishar@gmail.com>
Date2017-09-30 09:30 +0200
Subject[PATCH 5/6] Staging: rtl8188eu: core: Use list_entry instead of container_of
Message-ID<uvknM-12H-33@gated-at.bofh.it>
In reply to#1742536
For variables of type struct list_head* use list_entry to access
current list element instead of using container_of. Done using
the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 611c940..80fe6ae 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -1790,7 +1790,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)
 			u8 *p;
 			struct wlan_bssid_ex *pbss_network;
 
-			pnetwork = container_of(plist, struct wlan_network, list);
+			pnetwork = list_entry(plist, struct wlan_network, list);
 
 			plist = plist->next;
 
@@ -5470,7 +5470,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
 			xmitframe_plist = xmitframe_phead->next;
 
 			while (xmitframe_phead != xmitframe_plist) {
-				pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
+				pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
 
 				xmitframe_plist = xmitframe_plist->next;
 
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1742602

From"Tobin C. Harding" <me@tobin.cc>
Date2017-09-30 13:20 +0200
Message-ID<uvnYl-3oZ-9@gated-at.bofh.it>
In reply to#1742536
On Sat, Sep 30, 2017 at 12:49:00PM +0530, Srishti Sharma wrote:
> Replaces instances of container_of with list_entry to 
> access current list element.
> 
> Srishti Sharma (6):
>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>   Staging: rtl8188eu: core: Use list_entry instead of container_of

You may have trouble getting patches merged with duplicate commit logs like this. The reason is that
the git index should be grep'able. You may like to squash all of these commits into a single patch
since they all do the same thing. The mantra is 'one thing per patch' so this makes sense in this
case.

Hope this helps,
Tobin.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web