All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: rtl8188eu: use list_entry to access current list element instead of container_of
@ 2019-03-28 11:47 Bhanusree Pola
  2019-03-28 14:20 ` [Outreachy kernel] " Julia Lawall
  2019-03-28 15:40 ` Larry Finger
  0 siblings, 2 replies; 3+ messages in thread
From: Bhanusree Pola @ 2019-03-28 11:47 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: Larry Finger, Greg Kroah-Hartman

For struct list_head* type variables use list_entry to access the current list
elements rather than using container_of.
Issue found using coccinelle.

The following semantic patch is used to implement this:

<smpl>
@rule_list@
struct list_head* l;
@@

-container_of
+list_entry
  (l,...)
</smpl>

Signed-off-by: Bhanusree Pola <bhanusreemahesh@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 c360856a86ec..0554792e191f 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -179,7 +179,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) {
@@ -212,7 +212,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) {
@@ -1021,7 +1021,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)) {
@@ -1081,7 +1081,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)) {
@@ -1328,7 +1328,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;
 
@@ -1599,7 +1599,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;
 
@@ -1726,7 +1726,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.17.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: use list_entry to access current list element instead of container_of
  2019-03-28 11:47 [PATCH] Staging: rtl8188eu: use list_entry to access current list element instead of container_of Bhanusree Pola
@ 2019-03-28 14:20 ` Julia Lawall
  2019-03-28 15:40 ` Larry Finger
  1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2019-03-28 14:20 UTC (permalink / raw)
  To: Bhanusree Pola; +Cc: outreachy-kernel, Larry Finger, Greg Kroah-Hartman



On Thu, 28 Mar 2019, Bhanusree Pola wrote:

> For struct list_head* type variables use list_entry to access the current list
> elements rather than using container_of.
> Issue found using coccinelle.
>
> The following semantic patch is used to implement this:
>
> <smpl>
> @rule_list@
> struct list_head* l;
> @@
>
> -container_of
> +list_entry
>   (l,...)
> </smpl>


Can these be implemented with list_for_each?

julia

>
> Signed-off-by: Bhanusree Pola <bhanusreemahesh@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 c360856a86ec..0554792e191f 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_ap.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
> @@ -179,7 +179,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) {
> @@ -212,7 +212,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) {
> @@ -1021,7 +1021,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)) {
> @@ -1081,7 +1081,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)) {
> @@ -1328,7 +1328,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;
>
> @@ -1599,7 +1599,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;
>
> @@ -1726,7 +1726,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.17.1
>
> --
> 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/20190328114741.4367-1-bhanusreemahesh%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Staging: rtl8188eu: use list_entry to access current list element instead of container_of
  2019-03-28 11:47 [PATCH] Staging: rtl8188eu: use list_entry to access current list element instead of container_of Bhanusree Pola
  2019-03-28 14:20 ` [Outreachy kernel] " Julia Lawall
@ 2019-03-28 15:40 ` Larry Finger
  1 sibling, 0 replies; 3+ messages in thread
From: Larry Finger @ 2019-03-28 15:40 UTC (permalink / raw)
  To: Bhanusree Pola, outreachy-kernel; +Cc: Greg Kroah-Hartman

On 3/28/19 6:47 AM, Bhanusree Pola wrote:
> For struct list_head* type variables use list_entry to access the current list
> elements rather than using container_of.
> Issue found using coccinelle.
> 
> The following semantic patch is used to implement this:
> 
> <smpl>
> @rule_list@
> struct list_head* l;
> @@
> 
> -container_of
> +list_entry
>    (l,...)
> </smpl>
> 
> Signed-off-by: Bhanusree Pola <bhanusreemahesh@gmail.com>

Have you actually tested this patch on real hardware? If not, then you must find 
a partner before submitting it. It is one thing to do minor semantic changes 
following the suggestion of some tool for code semantics, but quite another when 
you are significantly modifying list handling.

Your patch may in fact be correct, but until it has actually been tested and the 
commit log reflects such testing, then this patch is not acceptable. After all, 
your reputation would hardly be advanced by submitting a patch that broke a driver!

NACK.

Larry

> ---
>   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 c360856a86ec..0554792e191f 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_ap.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
> @@ -179,7 +179,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) {
> @@ -212,7 +212,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) {
> @@ -1021,7 +1021,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)) {
> @@ -1081,7 +1081,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)) {
> @@ -1328,7 +1328,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;
>   
> @@ -1599,7 +1599,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;
>   
> @@ -1726,7 +1726,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) {
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-31 17:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-28 11:47 [PATCH] Staging: rtl8188eu: use list_entry to access current list element instead of container_of Bhanusree Pola
2019-03-28 14:20 ` [Outreachy kernel] " Julia Lawall
2019-03-28 15:40 ` Larry Finger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.