Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: rtl8712: Use list iterators and helpers

Use existing list iterators and helper functions.

The following coccinelle script was used to convert the code.

@@
identifier v1, v2, v3, v4;
symbol next;
expression e;
iterator name list_for_each;
statement S;
@@

<+...
(
- e = v1->next;
|
- e = get_next(v1);
)
... when != e
- while ( \( v1 != e \| e != v1 \) )
+ list_for_each (e, v1)
{
...
- v2 = container_of(e, struct v3, v4);
+ v2 = list_entry(e, struct v3, v4);
?- if (!v2) S
...
(
- e = e->next;
|
- e = get_next(e);
)
... when != e
}
...+>

Compile tested only.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210428173523.149958-1-linux@roeck-us.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Guenter Roeck and committed by
Greg Kroah-Hartman
3580942c 23017c88

+2 -4
+2 -4
drivers/staging/rtl8712/rtl871x_mlme.c
··· 139 139 return NULL; 140 140 spin_lock_irqsave(&scanned_queue->lock, irqL); 141 141 phead = &scanned_queue->queue; 142 - plist = phead->next; 143 - while (plist != phead) { 144 - pnetwork = container_of(plist, struct wlan_network, list); 145 - plist = plist->next; 142 + list_for_each(plist, phead) { 143 + pnetwork = list_entry(plist, struct wlan_network, list); 146 144 if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) 147 145 break; 148 146 }