staging: rtl8712: use list macros
v4 cover staging: rtl8712: use list macros
This patchset
- Replaces usage of container_of with list_entry - Replaces a while loop with list_for_each - Removes an unnecessary NULL check
V2:
- Include new patches for using list_for_each and removing unnecessary NULL check
V3:
- Include explanations for the changes in log messages
V4:
- Change log messages drop one patch
Himadri Pandya (6):
staging: rtl8712: use list_entry in function _r8712_find_network
staging: rtl8712: use list_for_each in function _r8712_find_network
staging: rtl8712: use list_entry in function _free_network_queue
staging: rtl8712: use list_entry in function
r8712_get_oldest_wlan_network
staging: rtl8712: use list_entry in function update_scanned_network
staging: rtl8712: use list_entry in function
r8712_select_and_join_from_scandrivers/staging/rtl8712/rtl871x_mlme.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
PATCH v4 1/6 staging: rtl8712: use list_entry in function _r8712_find_network
struct wlan_network contains field list of type list_head. Hence, getting the address of wlan_network using list_entry is equivalent of using container_of to do the same. And to use list_entry for list manipulations is a better choice.
---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message
--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8712/rtl871x_mlme.c +1 -1
@@ -142,7 +142,7 @@ static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue, phead = &scanned_queue->queue; plist = phead->next;while (plist != phead) { - pnetwork = container_of(plist, struct wlan_network, list); + pnetwork = list_entry(plist, struct wlan_network, list); plist = plist->next;if (!memcmp (addr, pnetwork->network.MacAddress,ETH_ALEN ))break ;
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH v4 1/6] staging: rtl8712: use list_entry in function _r8712_find_network
Quoted 20 lines · Himadri Pandya
struct
wlan_networkcontains field list of typelist_head. Hence, getting the address ofwlan_networkusinglist_entryis equivalent of usingcontainer_ofto do the same. And to uselist_entryfor list manipulations is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/rtl8712/rtl871x_mlme.c +0
-0
drivers/staging/rtl8712/rtl871x_mlme.c static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue, · line 146
Quoted 6 lines
drivers/staging/rtl8712/rtl871x_mlme.c +1
-1@@ -142,7 +142,7 @@ static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue, phead = &scanned_queue->queue; plist = phead->next;while (plist != phead) { - pnetwork = container_of(plist, struct wlan_network, list); + pnetwork = list_entry(plist, struct wlan_network, list); plist = plist->next;
If this really is the list structure, then let's use the list structure correctly. We should not be touching any ->next fields, nor comparing to phead, or any of that logic at all.
You should just need to use something like:
list_for_each_entry()
for this loop, right?
That will save a bunch of lines, and make things a lot more obvious what is happening.
thanks,
greg k-h
PATCH v4 2/6 staging: rtl8712: use list_for_each in function _r8712_find_network
In reply to Himadri Pandyastruct queue is of type list_head and member of struct __queue. Hence, using list_for_each to iterate over queue is a better choice.
---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message
--- drivers/staging/rtl8712/rtl871x_mlme.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8712/rtl871x_mlme.c +1 -2
@@ -141,9 +141,8 @@ static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue,spin_lock_irqsave (&scanned_queue->lock, irqL); phead = &scanned_queue->queue; plist = phead->next; -while (plist != phead) { +list_for_each (plist, phead) { pnetwork = list_entry(plist, struct wlan_network, list); - plist = plist->next;if (!memcmp (addr, pnetwork->network.MacAddress,ETH_ALEN ))break ; }
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH v4 2/6] staging: rtl8712: use list_for_each in function _r8712_find_network
Quoted 18 lines · Himadri Pandya
struct queue is of type
list_headand member of struct__queue. Hence, usinglist_for_eachto iterate over queue is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message--- drivers/staging/rtl8712/rtl871x_mlme.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/rtl8712/rtl871x_mlme.c +0
-0
drivers/staging/rtl8712/rtl871x_mlme.c static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue, · line 146
Quoted 7 lines
drivers/staging/rtl8712/rtl871x_mlme.c +1
-2@@ -141,9 +141,8 @@ static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue,spin_lock_irqsave (&scanned_queue->lock, irqL); phead = &scanned_queue->queue; plist = phead->next; -while (plist != phead) { +list_for_each (plist, phead) { pnetwork = list_entry(plist, struct wlan_network, list); - plist = plist->next;
list_for_each_entry() please.
PATCH v4 3/6 staging: rtl8712: use list_entry in function _free_network_queue
In reply to Himadri Pandyastruct wlan_network contains field list of type list_head. Hence, getting the address of wlan_network using list_entry is equivalent of using container_of to do the same. And to use list_entry for list manipulations is a better choice.
---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message
--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8712/rtl871x_mlme.c +1 -1
@@ -162,7 +162,7 @@ static void _free_network_queue(struct _adapter *padapter) phead = &scanned_queue->queue; plist = phead->next;while (!end_of_queue_search (phead, plist)) { - pnetwork = container_of(plist, struct wlan_network, list); + pnetwork = list_entry(plist, struct wlan_network, list); plist = plist->next;_free_network (pmlmepriv, pnetwork); }
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH v4 3/6] staging: rtl8712: use list_entry in function _free_network_queue
Quoted 20 lines · Himadri Pandya
struct
wlan_networkcontains field list of typelist_head. Hence, getting the address ofwlan_networkusinglist_entryis equivalent of usingcontainer_ofto do the same. And to uselist_entryfor list manipulations is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/rtl8712/rtl871x_mlme.c +0
-0
drivers/staging/rtl8712/rtl871x_mlme.c static void _free_network_queue(struct _adapter *padapter) · line 165
Quoted 5 lines
drivers/staging/rtl8712/rtl871x_mlme.c +1
-1@@ -162,7 +162,7 @@ static void _free_network_queue(struct _adapter *padapter) phead = &scanned_queue->queue; plist = phead->next;while (!end_of_queue_search (phead, plist)) { - pnetwork = container_of(plist, struct wlan_network, list); + pnetwork = list_entry(plist, struct wlan_network, list);
Very odd, I think you can use list_for_each_entry() here too, but be careful to verify it, I don't know what end_of_queue_search() is trying to do.
thanks,
greg k-h
Re: [Outreachy kernel] Re: [PATCH v4 3/6] staging: rtl8712: use list_entry in function _free_network_queue
Quoted 16 lines · Greg KH
Quoted 15 lines · Himadri Pandya
struct
wlan_networkcontains field list of typelist_head. Hence, getting the address ofwlan_networkusinglist_entryis equivalent of usingcontainer_ofto do the same. And to uselist_entryfor list manipulations is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
drivers/staging/rtl8712/rtl871x_mlme.c static void _free_network_queue(struct _adapter *padapter) · line 165
Quoted 10 lines
drivers/staging/rtl8712/rtl871x_mlme.c +1
-1@@ -162,7 +162,7 @@ static void _free_network_queue(struct _adapter *padapter) phead = &scanned_queue->queue; plist = phead->next;while (!end_of_queue_search (phead, plist)) { - pnetwork = container_of(plist, struct wlan_network, list); + pnetwork = list_entry(plist, struct wlan_network, list);Very odd, I think you can use
list_for_each_entry()here too, but be careful to verify it, I don't know whatend_of_queue_search()is trying to do.
Nothing. It's an equality test on the head.
julia
Quoted 12 lines
thanks,
greg k-h
--
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 [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190402055608.GG14075%40kroah.com.
For more options, visit https://groups.google.com/d/optout.
Re: [PATCH v4 3/6] staging: rtl8712: use list_entry in function _free_network_queue
In reply to Greg KHQuoted 29 lines · Greg KH,
Quoted 11 lines · Himadri Pandya
struct
wlan_networkcontains field list of typelist_head. Hence, getting the address ofwlan_networkusinglist_entryis equivalent of usingcontainer_ofto do the same. And to uselist_entryfor list manipulations is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log messageReview
Quoted 5 lines
--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/staging/rtl8712/rtl871x_mlme.cdrivers/staging/rtl8712/rtl871x_mlme.c static void _free_network_queue(struct _adapter
Quoted 4 lines
index
6912d73e8172..e0b4b8fbcc0e100644drivers/staging/rtl8712/rtl871x_mlme.c +0
-0@@ -162,7 +162,7 @@ static void _free_network_queue(struct _adapter*padapter)
drivers/staging/rtl8712/rtl871x_mlme.c static void _free_network_queue(struct _adapter *padapter) · line 165
Quoted 5 lines
drivers/staging/rtl8712/rtl871x_mlme.c +1
-1phead = &scanned_queue->queue; plist = phead->next;while (!end_of_queue_search (phead, plist)) { - pnetwork = container_of(plist, struct wlan_network, list); + pnetwork = list_entry(plist, struct wlan_network, list);
Quoted 8 lines
Very odd, I think you can use
list_for_each_entry()here too, but be careful to verify it, I don't know whatend_of_queue_search()is trying to do.thanks,
greg k-h
I'll check. Thank you.
- Himadri
Quoted 1 line
PATCH v4 4/6 staging: rtl8712: use list_entry in function r8712_get_oldest_wlan_network
In reply to Himadri Pandyastruct wlan_network contains field list of type list_head. Hence, getting the address of wlan_network using list_entry is equivalent of using container_of to do the same. And to use list_entry for list manipulations is a better choice.
---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message
--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8712/rtl871x_mlme.c +1 -1
@@ -289,7 +289,7 @@ struct wlan_network *r8712_get_oldest_wlan_network( while (1) { if (end_of_queue_search(phead, plist) == true) break; - pwlan = container_of(plist, struct wlan_network, list); + pwlan = list_entry(plist, struct wlan_network, list); if (pwlan->fixed != true) { if (oldest == NULL || time_after((unsigned long)oldest->last_scanned,
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH v4 4/6] staging: rtl8712: use list_entry in function r8712_get_oldest_wlan_network
Quoted 20 lines · Himadri Pandya
struct
wlan_networkcontains field list of typelist_head. Hence, getting the address ofwlan_networkusinglist_entryis equivalent of usingcontainer_ofto do the same. And to uselist_entryfor list manipulations is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/rtl8712/rtl871x_mlme.c +0
-0
drivers/staging/rtl8712/rtl871x_mlme.c struct wlan_network *r8712_get_oldest_wlan_network( · line 292
Quoted 5 lines
drivers/staging/rtl8712/rtl871x_mlme.c +1
-1@@ -289,7 +289,7 @@ struct wlan_network *r8712_get_oldest_wlan_network(while (1 ) {if (end_of_queue_search (phead, plist) == true)break ; - pwlan = container_of(plist, struct wlan_network, list); + pwlan = list_entry(plist, struct wlan_network, list);
same here, list_for_each_entry()?
PATCH v4 5/6 staging: rtl8712: use list_entry in function update_scanned_network
In reply to Himadri Pandyastruct wlan_network contains field list of type list_head. Hence, getting the address of wlan_network using list_entry is equivalent of using container_of to do the same. And to use list_entry for list manipulations is a better choice.
---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message
--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8712/rtl871x_mlme.c +1 -1
@@ -370,7 +370,7 @@ static void update_scanned_network(struct _adapter *adapter,if (end_of_queue_search (phead, plist))break ; - pnetwork = container_of(plist, struct wlan_network, list); + pnetwork = list_entry(plist, struct wlan_network, list);if (is_same_network (&pnetwork->network, target))break ; if ((oldest == ((struct wlan_network *)0)) ||
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH v4 5/6] staging: rtl8712: use list_entry in function update_scanned_network
Quoted 20 lines · Himadri Pandya
struct
wlan_networkcontains field list of typelist_head. Hence, getting the address ofwlan_networkusinglist_entryis equivalent of usingcontainer_ofto do the same. And to uselist_entryfor list manipulations is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/rtl8712/rtl871x_mlme.c +0
-0
drivers/staging/rtl8712/rtl871x_mlme.c static void update_scanned_network(struct _adapter *adapter, · line 373
Quoted 5 lines
drivers/staging/rtl8712/rtl871x_mlme.c +1
-1@@ -370,7 +370,7 @@ static void update_scanned_network(struct _adapter *adapter,if (end_of_queue_search (phead, plist))break ; - pnetwork = container_of(plist, struct wlan_network, list); + pnetwork = list_entry(plist, struct wlan_network, list);
And here for this loop?
PATCH v4 6/6 staging: rtl8712: use list_entry in function r8712_select_and_join_from_scan
In reply to Himadri Pandyastruct wlan_network contains field list of type list_head. Hence, getting the address of wlan_network using list_entry is equivalent of using container_of to do the same. And to use list_entry for list manipulations is a better choice.
---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message
--- drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8712/rtl871x_mlme.c +2 -2
@@ -1117,8 +1117,8 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) }return _FAIL; } - pnetwork =container_of (pmlmepriv->pscanned, - struct wlan_network, list); + pnetwork =list_entry (pmlmepriv->pscanned, + struct wlan_network, list);if (pnetwork ==NULL )return _FAIL; pmlmepriv->pscanned = pmlmepriv->pscanned->next;
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH v4 6/6] staging: rtl8712: use list_entry in function r8712_select_and_join_from_scan
Quoted 20 lines · Himadri Pandya
struct
wlan_networkcontains field list of typelist_head. Hence, getting the address ofwlan_networkusinglist_entryis equivalent of usingcontainer_ofto do the same. And to uselist_entryfor list manipulations is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message--- drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8712/rtl871x_mlme.c +0
-0
drivers/staging/rtl8712/rtl871x_mlme.c int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) · line 1123
Quoted 9 lines
drivers/staging/rtl8712/rtl871x_mlme.c +2
-2@@ -1117,8 +1117,8 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) }return _FAIL; } - pnetwork =container_of (pmlmepriv->pscanned, - struct wlan_network, list); + pnetwork =list_entry (pmlmepriv->pscanned, + struct wlan_network, list);if (pnetwork ==NULL )return _FAIL;
A list entry can not be null, so this check is very odd.
Re: [Outreachy kernel] Re: [PATCH v4 6/6] staging: rtl8712: use list_entry in function r8712_select_and_join_from_scan
Quoted 16 lines · Greg KH
Quoted 15 lines · Himadri Pandya
struct
wlan_networkcontains field list of typelist_head. Hence, getting the address ofwlan_networkusinglist_entryis equivalent of usingcontainer_ofto do the same. And to uselist_entryfor list manipulations is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message--- drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 5 lines
drivers/staging/rtl8712/rtl871x_mlme.c +0
-0drivers/staging/rtl8712/rtl871x_mlme.c int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) · line 1123
Quoted 9 lines
drivers/staging/rtl8712/rtl871x_mlme.c +2
-2@@ -1117,8 +1117,8 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) }return _FAIL; } - pnetwork =container_of (pmlmepriv->pscanned, - struct wlan_network, list); + pnetwork =list_entry (pmlmepriv->pscanned, + struct wlan_network, list);if (pnetwork ==NULL )return _FAIL;A list entry can not be null, so this check is very odd.
I guess it could be, if the value is NULL, because the list field is at the top of the structure. However, it looks like the list is build properly, with init_list_head and then list_add_tail, so the NULL test should not be needed.
Himadri, there are several very simple loops on lists that could be nicely converted to list_for_each or list_for_each_entry. Search for end_of_queue_search.
julia
Quoted 8 lines
--
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 [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190402055701.GJ14075%40kroah.com.
For more options, visit https://groups.google.com/d/optout.
Re: [Outreachy kernel] Re: [PATCH v4 6/6] staging: rtl8712: use list_entry in function r8712_select_and_join_from_scan
Quoted 37 lines · Julia Lawall,
Quoted 16 lines · Greg KH
Quoted 15 lines · Himadri Pandya
struct
wlan_networkcontains field list of typelist_head. Hence, getting the address ofwlan_networkusinglist_entryis equivalent of usingcontainer_ofto do the same. And to uselist_entryfor list manipulations is a better choice.Signed-off-by Himadri Pandya <[email protected]>---
Changes in V4:
- Change log message
Changes in V3:
- Improve log message--- drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/staging/rtl8712/rtl871x_mlme.cQuoted 4 lines
drivers/staging/rtl8712/rtl871x_mlme.c int r8712_select_and_join_from_scan(struct
Quoted 4 lines
index
1a15c45aa83b..164422b3ac07100644drivers/staging/rtl8712/rtl871x_mlme.c +0
-0@@ -1117,8 +1117,8 @@ int r8712_select_and_join_from_scan(struct
mlme_priv*pmlmepriv)Quoted 10 lines
Quoted 9 lines
drivers/staging/rtl8712/rtl871x_mlme.c +2
-2}return _FAIL; } - pnetwork =container_of (pmlmepriv->pscanned, - struct wlan_network, list); + pnetwork =list_entry (pmlmepriv->pscanned, + struct wlan_network, list);if (pnetwork ==NULL )return _FAIL;
Quoted 7 lines
Quoted 1 line
A list entry can not be null, so this check is very odd.
I guess it could be, if the value is NULL, because the list field is at the top of the structure. However, it looks like the list is build properly, with
init_list_headand thenlist_add_tail, so the NULL test should not be needed.
Should I remove the NULL test then?
Quoted 6 lines
Himadri, there are several very simple loops on lists that could be nicely converted to
list_for_eachorlist_for_each_entry. Search forend_of_queue_search.julia
On it. Thank you.
- Himadri
Quoted 25 lines
Quoted 4 lines
--
You received this message because you are subscribed to the GoogleGroups "outreachy-kernel" group.
Quoted 1 line
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
Quoted 2 lines
To post to this group, send email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/20190402055701.GJ14075%40kroah.com
.Quoted 2 lines
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1904020831350.2664%40hadrien
.
For more options, visit https://groups.google.com/d/optout.
Re: [Outreachy kernel] Re: [PATCH v4 6/6] staging: rtl8712: use list_entry in function r8712_select_and_join_from_scan
Quoted 57 lines · Himadri Pandya
On Tue, 2 Apr, 2019, 12:05 PM Julia Lawall, <[email protected]> wrote:
On Tue, 2 Apr 2019, Greg KH wrote: > On Tue, Apr 02, 2019 at 01:39:55AM +0530, Himadri Pandya wrote: > > struct wlan_network contains field list of type list_head. Hence, > > getting the address of wlan_network using list_entry is equivalent > > of using container_of to do the same. And to use list_entry for list > > manipulations is a better choice. > > > > Signed-off-by: Himadri Pandya <[email protected]> > > --- > > Changes in V4: > >ᅵ ᅵ ᅵ- Change log message > > Changes in V3: > >ᅵ ᅵ ᅵ- Improve log message > > --- > >ᅵ drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++-- > >ᅵ 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c > > index 1a15c45aa83b..164422b3ac07 100644 > > --- a/drivers/staging/rtl8712/rtl871x_mlme.c > > +++ b/drivers/staging/rtl8712/rtl871x_mlme.c > > @@ -1117,8 +1117,8 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) > >ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ} > >ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵreturn _FAIL; > >ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ} > > -ᅵ ᅵ ᅵ ᅵ ᅵ ᅵpnetwork = container_of(pmlmepriv->pscanned, > > -ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵstruct wlan_network, list); > > +ᅵ ᅵ ᅵ ᅵ ᅵ ᅵpnetwork = list_entry(pmlmepriv->pscanned, > > +ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵstruct wlan_network, list); > >ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵif (pnetwork == NULL) > >ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵreturn _FAIL; > > A list entry can not be null, so this check is very odd. I guess it could be, if the value is NULL, because the list field is at the top of the structure.ᅵ However, it looks like the list is build properly, with init_list_head and then list_add_tail, so the NULL test should not be needed.
Quoted 1 line
Should I remove the NULL test then?
Yes, but you need to explain in the log message in terms of the code why removing it is correct.
julia
Quoted 44 lines
Himadri, there are several very simple loops on lists that could be nicely
converted tolist_for_eachor list_for_each_entry.ᅵ Search forend_of_queue_search.julia
On it. Thank you.
- Himadri
>
> --
> 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
[email protected].
> To post to this group, send email to
[email protected].
> To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/20190402055701.GJ14075%4 0kroah.com.
> For more options, visit https://groups.google.com/d/optout.
>--
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
[email protected].
To post to this group, send email to
[email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.19040208 31350.2664%40hadrien.
For more options, visit https://groups.google.com/d/optout.
Re: [Outreachy kernel] Re: [PATCH v4 6/6] staging: rtl8712: use list_entry in function r8712_select_and_join_from_scan
Quoted 62 lines · Julia Lawall,
Quoted 3 lines · Himadri Pandya
On Tue, 2 Apr, 2019, 12:05 PM Julia Lawall, <[email protected]>
Quoted 54 lines · wrote:
On Tue, 2 Apr 2019, Greg KH wrote: > On Tue, Apr 02, 2019 at 01:39:55AM +0530, Himadri Pandya wrote: > > struct wlan_network contains field list of type list_head. Hence, > > getting the address of wlan_network using list_entry is equivalent > > of using container_of to do the same. And to use list_entry for list > > manipulations is a better choice. > > > > Signed-off-by: Himadri Pandya <[email protected]> > > --- > > Changes in V4: > > - Change log message > > Changes in V3: > > - Improve log message > > --- > > drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c > > index 1a15c45aa83b..164422b3ac07 100644 > > --- a/drivers/staging/rtl8712/rtl871x_mlme.c > > +++ b/drivers/staging/rtl8712/rtl871x_mlme.c > > @@ -1117,8 +1117,8 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) > > } > > return _FAIL; > > } > > - pnetwork = container_of(pmlmepriv->pscanned, > > - struct wlan_network, list); > > + pnetwork = list_entry(pmlmepriv->pscanned, > > + struct wlan_network, list); > > if (pnetwork == NULL) > > return _FAIL; > > A list entry can not be null, so this check is very odd. I guess it could be, if the value is NULL, because the list field is at the top of the structure. However, it looks like the list is build properly, with init_list_head and then list_add_tail, so the NULL test should not be needed.
Quoted 7 lines
Quoted 1 line
Should I remove the NULL test then?
Yes, but you need to explain in the log message in terms of the code why removing it is correct.
julia
Okay. I'll do that. Thank you.
- Himadri
Quoted 59 lines
Quoted 17 lines
Himadri, there are several very simple loops on lists that could be nicely
converted tolist_for_eachorlist_for_each_entry. Search forend_of_queue_search.julia
On it. Thank you.
- Himadri
Quoted 10 lines
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/20190402055701.GJ14075%4
Quoted 4 lines
0kroah.com.
> For more options, visit https://groups.google.com/d/optout.
>Quoted 9 lines
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.19040208
Quoted 5 lines
31350.2664%40hadrien.
For more options, visit https://groups.google.com/d/optout.--
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 [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.20.1904021157590.3297%40hadrien
.
For more options, visit https://groups.google.com/d/optout.