Skip to contentSkip to conversation

staging: rtl8723au: core: Prefer list_for_each_entry_safe()

PATCH In review Janani Ravichandran 1 participant 2 messages Feb 28, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723au: core: Prefer list_for_each_entry_safe()

Use list_for_each_entry_safe() rather than a combination of list_for_each_safe() and container_of().

Semantic patch used:

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

(
- list_for_each(pos, head)
+ list_for_each_entry(var, head, mem)
{
... when != var
- var = \(list_entry \| container_of\)(pos, t, mem); ... when any
}
|
- 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 any
}
)

---
 drivers/staging/rtl8723au/core/rtw_recv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723au/core/rtw_recv.c +1 -2
index a66d631..3ad81d4 100644
@@ -1795,8 +1795,7 @@ static int enqueue_reorder_recvframe23a(struct recv_reorder_ctrl *preorder_ctrl,
 	ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
 	phead = get_list_head(ppending_recvframe_queue);
 
-	list_for_each_safe(plist, ptmp, phead) {
-		hdr = container_of(plist, struct recv_frame, list);
+	list_for_each_entry_safe(hdr, ptmp, phead, list) {
 		pnextattrib = &hdr->attrib;
 
 		if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) {
Signature · 1 line
2.5.0
#1 lore raw
Quoted 53 lines · Janani Ravichandran

Use list_for_each_entry_safe() rather than a combination of list_for_each_safe() and container_of().

Semantic patch used:

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

(
- list_for_each(pos, head)
+ list_for_each_entry(var, head, mem)

  {
   ... when != var

- var = \(list_entry \| container_of\)(pos, t, mem); ... when any
}
|
- 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 any
}
)

---
 drivers/staging/rtl8723au/core/rtw_recv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723au/core/rtw_recv.c +1 -2
index a66d631..3ad81d4 100644
@@ -1795,8 +1795,7 @@ static int enqueue_reorder_recvframe23a(struct
 recv_reorder_ctrl *preorder_ctrl,
        ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
        phead = get_list_head(ppending_recvframe_queue);
 
-       list_for_each_safe(plist, ptmp, phead) {
-               hdr = container_of(plist, struct recv_frame, list);
+       list_for_each_entry_safe(hdr, ptmp, phead, list) {
                pnextattrib = &hdr->attrib;
 
                if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) {
Quoted 4 lines

--
2.5.0

Please ignore this patch. There is an error. Sorry about that.

Janani.