All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe
@ 2017-10-04 13:12 Srishti Sharma
  2017-10-04 13:34 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Srishti Sharma @ 2017-10-04 13:12 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, outreachy-kernel, Srishti Sharma

Use list_for_each_entry_safe to make the code more compact. Done 
by the following semantic patch by coccinelle.

@r@
struct list_head* l;
expression e;
identifier m,list_del_init,f;
type T1;
T1* pos;
iterator name list_for_each_entry_safe;
@@

f(...){

+T1* tmp;
<+...
-while(...)
+list_for_each_entry_safe(pos,tmp,l,m)
{
...
-pos = container_of(l,T1,m);
...
-l=e;
 <+...
 list_del_init(&pos->m)
 ...+>
}
...+>

}

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

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
index a2c599f..551af9e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -280,7 +280,7 @@ void	expire_timeout_chk(struct adapter *padapter)
 {
 	struct list_head *phead, *plist;
 	u8 updated = 0;
-	struct sta_info *psta = NULL;
+	struct sta_info *psta = NULL, *tmp;
 	struct sta_priv *pstapriv = &padapter->stapriv;
 	u8 chk_alive_num = 0;
 	char chk_alive_list[NUM_STA];
@@ -292,10 +292,7 @@ void	expire_timeout_chk(struct adapter *padapter)
 	plist = phead->next;
 
 	/* check auth_queue */
-	while (phead != plist) {
-		psta = container_of(plist, struct sta_info, auth_list);
-		plist = plist->next;
-
+	list_for_each_entry_safe(psta, tmp, plist, auth_list) {
 		if (psta->expire_to > 0) {
 			psta->expire_to--;
 			if (psta->expire_to == 0) {
@@ -326,10 +323,7 @@ void	expire_timeout_chk(struct adapter *padapter)
 	plist = phead->next;
 
 	/* check asoc_queue */
-	while (phead != plist) {
-		psta = container_of(plist, struct sta_info, asoc_list);
-		plist = plist->next;
-
+	list_for_each_entry_safe(psta, tmp, plist, asoc_list) {
 		if (chk_sta_is_alive(psta) || !psta->expire_to) {
 			psta->expire_to = pstapriv->expire_to;
 			psta->keep_alive_trycnt = 0;
-- 
2.7.4



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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe
  2017-10-04 13:12 [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe Srishti Sharma
@ 2017-10-04 13:34 ` Julia Lawall
  2017-10-04 15:08   ` Dan Carpenter
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2017-10-04 13:34 UTC (permalink / raw)
  To: Srishti Sharma; +Cc: gregkh, devel, linux-kernel, outreachy-kernel

Again, you have three patches on different files with the same subject
line.  You could add the file name eg rtw_ap: to the subject line to make
them unique.

julia

On Wed, 4 Oct 2017, Srishti Sharma wrote:

> Use list_for_each_entry_safe to make the code more compact. Done
> by the following semantic patch by coccinelle.
>
> @r@
> struct list_head* l;
> expression e;
> identifier m,list_del_init,f;
> type T1;
> T1* pos;
> iterator name list_for_each_entry_safe;
> @@
>
> f(...){
>
> +T1* tmp;
> <+...
> -while(...)
> +list_for_each_entry_safe(pos,tmp,l,m)
> {
> ...
> -pos = container_of(l,T1,m);
> ...
> -l=e;
>  <+...
>  list_del_init(&pos->m)
>  ...+>
> }
> ...+>
>
> }
>
> Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
> ---
>  drivers/staging/rtl8188eu/core/rtw_ap.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
> index a2c599f..551af9e 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_ap.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
> @@ -280,7 +280,7 @@ void	expire_timeout_chk(struct adapter *padapter)
>  {
>  	struct list_head *phead, *plist;
>  	u8 updated = 0;
> -	struct sta_info *psta = NULL;
> +	struct sta_info *psta = NULL, *tmp;
>  	struct sta_priv *pstapriv = &padapter->stapriv;
>  	u8 chk_alive_num = 0;
>  	char chk_alive_list[NUM_STA];
> @@ -292,10 +292,7 @@ void	expire_timeout_chk(struct adapter *padapter)
>  	plist = phead->next;
>
>  	/* check auth_queue */
> -	while (phead != plist) {
> -		psta = container_of(plist, struct sta_info, auth_list);
> -		plist = plist->next;
> -
> +	list_for_each_entry_safe(psta, tmp, plist, auth_list) {
>  		if (psta->expire_to > 0) {
>  			psta->expire_to--;
>  			if (psta->expire_to == 0) {
> @@ -326,10 +323,7 @@ void	expire_timeout_chk(struct adapter *padapter)
>  	plist = phead->next;
>
>  	/* check asoc_queue */
> -	while (phead != plist) {
> -		psta = container_of(plist, struct sta_info, asoc_list);
> -		plist = plist->next;
> -
> +	list_for_each_entry_safe(psta, tmp, plist, asoc_list) {
>  		if (chk_sta_is_alive(psta) || !psta->expire_to) {
>  			psta->expire_to = pstapriv->expire_to;
>  			psta->keep_alive_trycnt = 0;
> --
> 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/1507122755-5489-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe
  2017-10-04 13:34 ` [Outreachy kernel] " Julia Lawall
@ 2017-10-04 15:08   ` Dan Carpenter
  2017-10-04 16:32     ` Srishti Sharma
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2017-10-04 15:08 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Srishti Sharma, devel, gregkh, linux-kernel, outreachy-kernel

On Wed, Oct 04, 2017 at 03:34:05PM +0200, Julia Lawall wrote:
> Again, you have three patches on different files with the same subject
> line.  You could add the file name eg rtw_ap: to the subject line to make
> them unique.
> 

And the subject needs to start with [PATCH v3] and then after the
Signed off by line put:

---
v2 and v3: Changes to the subjects and changelogs.

regards,
dan carpenter


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe
  2017-10-04 15:08   ` Dan Carpenter
@ 2017-10-04 16:32     ` Srishti Sharma
  2017-10-04 17:07       ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Srishti Sharma @ 2017-10-04 16:32 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Julia Lawall, devel, Greg KH, Linux kernel mailing list,
	outreachy-kernel

On Wed, Oct 4, 2017 at 8:38 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Wed, Oct 04, 2017 at 03:34:05PM +0200, Julia Lawall wrote:
>> Again, you have three patches on different files with the same subject
>> line.  You could add the file name eg rtw_ap: to the subject line to make
>> them unique.
>>
>
> And the subject needs to start with [PATCH v3] and then after the
> Signed off by line put:
Shouldn't it be only v2 as I haven't sent a v2 for this before.

Regards,
Srishti
>
> ---
> v2 and v3: Changes to the subjects and changelogs.
>
> regards,
> dan carpenter


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe
  2017-10-04 16:32     ` Srishti Sharma
@ 2017-10-04 17:07       ` Julia Lawall
  2017-10-04 17:11         ` Srishti Sharma
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2017-10-04 17:07 UTC (permalink / raw)
  To: Srishti Sharma
  Cc: Dan Carpenter, devel, Greg KH, Linux kernel mailing list,
	outreachy-kernel



On Wed, 4 Oct 2017, Srishti Sharma wrote:

> On Wed, Oct 4, 2017 at 8:38 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > On Wed, Oct 04, 2017 at 03:34:05PM +0200, Julia Lawall wrote:
> >> Again, you have three patches on different files with the same subject
> >> line.  You could add the file name eg rtw_ap: to the subject line to make
> >> them unique.
> >>
> >
> > And the subject needs to start with [PATCH v3] and then after the
> > Signed off by line put:
> Shouldn't it be only v2 as I haven't sent a v2 for this before.

It should be ok.  There was a v1 that only did list_entry and where all
the patches had the same subject, but Greg already dropped that one.

julia

>
> Regards,
> Srishti
> >
> > ---
> > v2 and v3: Changes to the subjects and changelogs.
> >
> > regards,
> > dan carpenter
>


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe
  2017-10-04 17:07       ` Julia Lawall
@ 2017-10-04 17:11         ` Srishti Sharma
  0 siblings, 0 replies; 6+ messages in thread
From: Srishti Sharma @ 2017-10-04 17:11 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Dan Carpenter, devel, Greg KH, Linux kernel mailing list,
	outreachy-kernel

On Wed, Oct 4, 2017 at 10:37 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Wed, 4 Oct 2017, Srishti Sharma wrote:
>
>> On Wed, Oct 4, 2017 at 8:38 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>> > On Wed, Oct 04, 2017 at 03:34:05PM +0200, Julia Lawall wrote:
>> >> Again, you have three patches on different files with the same subject
>> >> line.  You could add the file name eg rtw_ap: to the subject line to make
>> >> them unique.
>> >>
>> >
>> > And the subject needs to start with [PATCH v3] and then after the
>> > Signed off by line put:
>> Shouldn't it be only v2 as I haven't sent a v2 for this before.
>
> It should be ok.  There was a v1 that only did list_entry and where all
> the patches had the same subject, but Greg already dropped that one.

Yes, I have sent another patch where we only need to convert
container_of to list_entry, that is where there is no while loop
,since we now have much less cases of this type , I have sent only one
patch for it.

Regards,
Srishti
> julia
>
>>
>> Regards,
>> Srishti
>> >
>> > ---
>> > v2 and v3: Changes to the subjects and changelogs.
>> >
>> > regards,
>> > dan carpenter
>>


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

end of thread, other threads:[~2017-10-04 17:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-04 13:12 [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe Srishti Sharma
2017-10-04 13:34 ` [Outreachy kernel] " Julia Lawall
2017-10-04 15:08   ` Dan Carpenter
2017-10-04 16:32     ` Srishti Sharma
2017-10-04 17:07       ` Julia Lawall
2017-10-04 17:11         ` Srishti Sharma

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.