Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1592798

[PATCH 4/5] staging: lustre: llite: Use list_for_each_entry_safe

From simran singhal <singhalsimran0@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 4/5] staging: lustre: llite: Use list_for_each_entry_safe
Date 2017-03-05 18:20 +0100
Message-ID <thHZ8-3pL-19@gated-at.bofh.it> (permalink)
References <thHZ8-3pL-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Doubly linked lists which are  iterated  using list_empty
and list_entry macros have been replaced with list_for_each_entry_safe
macro.
This makes the iteration simpler and more readable.

This patch replaces the while loop containing list_empty and list_entry
with list_for_each_entry_safe.

This was done with Coccinelle.

@@
expression E1;
identifier I1, I2;
type T;
iterator name list_for_each_entry_safe;
@@

T *I1;
+ T *tmp;
...
- while (list_empty(&E1) == 0)
+ list_for_each_entry_safe (I1, tmp, &E1, I2)
{
...when != T *I1;
- I1 = list_entry(E1.next, T, I2);
...
}

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
---
 drivers/staging/lustre/lustre/llite/statahead.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index fb7c315..d1287b2 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -860,6 +860,7 @@ static int ll_agl_thread(void *arg)
 	struct inode	     *dir    = d_inode(parent);
 	struct ll_inode_info     *plli   = ll_i2info(dir);
 	struct ll_inode_info     *clli;
+	struct ll_inode_info *tmp;
 	struct ll_sb_info	*sbi    = ll_i2sbi(dir);
 	struct ll_statahead_info *sai;
 	struct ptlrpc_thread *thread;
@@ -909,9 +910,7 @@ static int ll_agl_thread(void *arg)
 
 	spin_lock(&plli->lli_agl_lock);
 	sai->sai_agl_valid = 0;
-	while (!list_empty(&sai->sai_agls)) {
-		clli = list_entry(sai->sai_agls.next,
-				  struct ll_inode_info, lli_agl_list);
+	list_for_each_entry_safe(clli, tmp, &sai->sai_agls, lli_agl_list) {
 		list_del_init(&clli->lli_agl_list);
 		spin_unlock(&plli->lli_agl_lock);
 		clli->lli_agl_index = 0;
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] Use list_for_each_entry_safe simran singhal <singhalsimran0@gmail.com> - 2017-03-05 18:20 +0100
  [PATCH 4/5] staging: lustre: llite: Use list_for_each_entry_safe simran singhal <singhalsimran0@gmail.com> - 2017-03-05 18:20 +0100
  [PATCH 5/5] staging: lustre: osc_page.c:  Use list_for_each_entry_safe simran singhal <singhalsimran0@gmail.com> - 2017-03-05 18:20 +0100
    Re: [Outreachy kernel] [PATCH 5/5] staging: lustre: osc_page.c: Use  list_for_each_entry_safe Julia Lawall <julia.lawall@lip6.fr> - 2017-03-05 18:20 +0100
      Re: [Outreachy kernel] [PATCH 5/5] staging: lustre: osc_page.c: Use  list_for_each_entry_safe Julia Lawall <julia.lawall@lip6.fr> - 2017-03-05 18:30 +0100
    Re: [Outreachy kernel] [PATCH 5/5] staging: lustre: osc_page.c: Use  list_for_each_entry_safe Julia Lawall <julia.lawall@lip6.fr> - 2017-03-05 18:30 +0100
      Re: [Outreachy kernel] [PATCH 5/5] staging: lustre: osc_page.c: Use  list_for_each_entry_safe Julia Lawall <julia.lawall@lip6.fr> - 2017-03-05 18:50 +0100
        Re: [Outreachy kernel] [PATCH 5/5] staging: lustre: osc_page.c: Use list_for_each_entry_safe SIMRAN SINGHAL <singhalsimran0@gmail.com> - 2017-03-05 19:00 +0100
          Re: [Outreachy kernel] [PATCH 5/5] staging: lustre: osc_page.c: Use  list_for_each_entry_safe Julia Lawall <julia.lawall@lip6.fr> - 2017-03-05 19:00 +0100
      Re: [Outreachy kernel] [PATCH 5/5] staging: lustre: osc_page.c: Use list_for_each_entry_safe SIMRAN SINGHAL <singhalsimran0@gmail.com> - 2017-03-05 18:50 +0100
    Re: [PATCH 5/5] staging: lustre: osc_page.c:  Use  list_for_each_entry_safe James Simmons <jsimmons@infradead.org> - 2017-03-06 16:30 +0100
      Re: [PATCH 5/5] staging: lustre: osc_page.c: Use list_for_each_entry_safe SIMRAN SINGHAL <singhalsimran0@gmail.com> - 2017-03-06 20:30 +0100
      Re: [PATCH 5/5] staging: lustre: osc_page.c:  Use  list_for_each_entry_safe "Dilger, Andreas" <andreas.dilger@intel.com> - 2017-03-07 13:10 +0100

csiph-web