public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Use list_for_each_entry(_safe) instead of list_for_each(_safe)
@ 2007-07-22 18:42 Matthias Kaehlcke
  2007-07-22 18:49 ` [PATCH 1/5] kernel/exit.c: " Matthias Kaehlcke
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Matthias Kaehlcke @ 2007-07-22 18:42 UTC (permalink / raw)
  To: linux-kernel

This patchset converts list_for_each(_safe) to
list_for_each_entry(_safe) in the following files:

kernel/exit.c
kernel/time/clocksource.c
kernel/user.c
mm/oom_kill.c
mm/page_alloc.c
 
-- 
Matthias Kaehlcke
Linux Application Developer
Barcelona

      El trabajo es el refugio de los que no tienen nada que hacer
                            (Oscar Wilde)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* [PATCH 1/5] kernel/exit.c: Use list_for_each_entry(_safe) instead of list_for_each(_safe)
  2007-07-22 18:42 [PATCH 0/5] Use list_for_each_entry(_safe) instead of list_for_each(_safe) Matthias Kaehlcke
@ 2007-07-22 18:49 ` Matthias Kaehlcke
  2007-07-22 18:51 ` [PATCH 2/5] kernel/time/clocksource.c: Use list_for_each_entry instead of list_for_each Matthias Kaehlcke
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Matthias Kaehlcke @ 2007-07-22 18:49 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, akpm

kernel/exit.c: Convert list_for_each(_safe) to
list_for_each_entry(_safe) in forget_original_parent(), exit_notify()
and do_wait()

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>

--

diff --git a/kernel/exit.c b/kernel/exit.c
index ca6a11b..ac84684 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -680,8 +680,7 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
 static void
 forget_original_parent(struct task_struct *father, struct list_head *to_release)
 {
-	struct task_struct *p, *reaper = father;
-	struct list_head *_p, *_n;
+	struct task_struct *p, *n, *reaper = father;
 
 	do {
 		reaper = next_thread(reaper);
@@ -699,9 +698,8 @@ forget_original_parent(struct task_struct *father, struct list_head *to_release)
 	 *
 	 * Search them and reparent children.
 	 */
-	list_for_each_safe(_p, _n, &father->children) {
+	list_for_each_entry_safe(p, n, &father->children, sibling) {
 		int ptrace;
-		p = list_entry(_p, struct task_struct, sibling);
 
 		ptrace = p->ptrace;
 
@@ -729,8 +727,7 @@ forget_original_parent(struct task_struct *father, struct list_head *to_release)
 		if (unlikely(ptrace && p->exit_state == EXIT_ZOMBIE && p->exit_signal == -1))
 			list_add(&p->ptrace_list, to_release);
 	}
-	list_for_each_safe(_p, _n, &father->ptrace_children) {
-		p = list_entry(_p, struct task_struct, ptrace_list);
+	list_for_each_entry_safe(p, n, &father->ptrace_children, ptrace_list) {
 		choose_new_parent(p, reaper);
 		reparent_thread(p, father, 1);
 	}
@@ -1502,12 +1499,9 @@ repeat:
 	tsk = current;
 	do {
 		struct task_struct *p;
-		struct list_head *_p;
 		int ret;
 
-		list_for_each(_p,&tsk->children) {
-			p = list_entry(_p, struct task_struct, sibling);
-
+		list_for_each_entry(p, &tsk->children, sibling) {
 			ret = eligible_child(pid, options, p);
 			if (!ret)
 				continue;
@@ -1589,9 +1583,8 @@ check_continued:
 			}
 		}
 		if (!flag) {
-			list_for_each(_p, &tsk->ptrace_children) {
-				p = list_entry(_p, struct task_struct,
-						ptrace_list);
+			list_for_each_entry(p, &tsk->ptrace_children,
+					    ptrace_list) {
 				if (!eligible_child(pid, options, p))
 					continue;
 				flag = 1;

-- 
Matthias Kaehlcke
Linux Application Developer
Barcelona

             If liberty means anything at all, it means the
           right to tell people what they do not want to hear
                            (George Orwell)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* [PATCH 2/5] kernel/time/clocksource.c: Use list_for_each_entry instead of list_for_each
  2007-07-22 18:42 [PATCH 0/5] Use list_for_each_entry(_safe) instead of list_for_each(_safe) Matthias Kaehlcke
  2007-07-22 18:49 ` [PATCH 1/5] kernel/exit.c: " Matthias Kaehlcke
@ 2007-07-22 18:51 ` Matthias Kaehlcke
  2007-07-22 18:52 ` [PATCH 3/5] kernel/user.c: " Matthias Kaehlcke
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Matthias Kaehlcke @ 2007-07-22 18:51 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, akpm

kernel/time/clocksource.c: Convert list_for_each to
list_for_each_entry in clocksource_resume(),
sysfs_override_clocksource() and show_available_clocksources()

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>

--

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 51b6a6a..c8a9d13 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -207,15 +207,12 @@ static inline void clocksource_resume_watchdog(void) { }
  */
 void clocksource_resume(void)
 {
-	struct list_head *tmp;
+	struct clocksource *cs;
 	unsigned long flags;
 
 	spin_lock_irqsave(&clocksource_lock, flags);
 
-	list_for_each(tmp, &clocksource_list) {
-		struct clocksource *cs;
-
-		cs = list_entry(tmp, struct clocksource, list);
+	list_for_each_entry(cs, &clocksource_list, list) {
 		if (cs->resume)
 			cs->resume();
 	}
@@ -369,7 +366,6 @@ static ssize_t sysfs_override_clocksource(struct sys_device *dev,
 					  const char *buf, size_t count)
 {
 	struct clocksource *ovr = NULL;
-	struct list_head *tmp;
 	size_t ret = count;
 	int len;
 
@@ -389,12 +385,11 @@ static ssize_t sysfs_override_clocksource(struct sys_device *dev,
 
 	len = strlen(override_name);
 	if (len) {
+		struct clocksource *cs;
+
 		ovr = clocksource_override;
 		/* try to select it: */
-		list_for_each(tmp, &clocksource_list) {
-			struct clocksource *cs;
-
-			cs = list_entry(tmp, struct clocksource, list);
+		list_for_each_entry(cs, &clocksource_list, list) {
 			if (strlen(cs->name) == len &&
 			    !strcmp(cs->name, override_name))
 				ovr = cs;
@@ -422,14 +417,11 @@ static ssize_t sysfs_override_clocksource(struct sys_device *dev,
 static ssize_t
 sysfs_show_available_clocksources(struct sys_device *dev, char *buf)
 {
-	struct list_head *tmp;
+	struct clocksource *src;
 	char *curr = buf;
 
 	spin_lock_irq(&clocksource_lock);
-	list_for_each(tmp, &clocksource_list) {
-		struct clocksource *src;
-
-		src = list_entry(tmp, struct clocksource, list);
+	list_for_each_entry(src, &clocksource_list, list) {
 		curr += sprintf(curr, "%s ", src->name);
 	}
 	spin_unlock_irq(&clocksource_lock);

-- 
Matthias Kaehlcke
Linux Application Developer
Barcelona

     The assumption that what currently exists must necessarily
      exist is the acid that corrodes all visionary thinking
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* [PATCH 3/5] kernel/user.c: Use list_for_each_entry instead of list_for_each
  2007-07-22 18:42 [PATCH 0/5] Use list_for_each_entry(_safe) instead of list_for_each(_safe) Matthias Kaehlcke
  2007-07-22 18:49 ` [PATCH 1/5] kernel/exit.c: " Matthias Kaehlcke
  2007-07-22 18:51 ` [PATCH 2/5] kernel/time/clocksource.c: Use list_for_each_entry instead of list_for_each Matthias Kaehlcke
@ 2007-07-22 18:52 ` Matthias Kaehlcke
  2007-07-22 18:54 ` [PATCH 4/5] mm/oom_kill.c: " Matthias Kaehlcke
  2007-07-22 18:56 ` [PATCH 5/5] mm/page_alloc.c: " Matthias Kaehlcke
  4 siblings, 0 replies; 6+ messages in thread
From: Matthias Kaehlcke @ 2007-07-22 18:52 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, akpm

kernel/user.c: Convert list_for_each to list_for_each_entry in
uid_hash_find()

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>

--

diff --git a/kernel/user.c b/kernel/user.c
index 4869563..d0363d1 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -68,13 +68,9 @@ static inline void uid_hash_remove(struct user_struct *up)
 
 static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
 {
-	struct list_head *up;
-
-	list_for_each(up, hashent) {
-		struct user_struct *user;
-
-		user = list_entry(up, struct user_struct, uidhash_list);
+	struct user_struct *user;
 
+	list_for_each_entry(user, hashent, uidhash_list) {
 		if(user->uid == uid) {
 			atomic_inc(&user->__count);
 			return user;

-- 
Matthias Kaehlcke
Linux Application Developer
Barcelona


   Usually when people are sad, they don't do anything. They just cry over
     their condition. But when they get angry, they bring about a change
                              (Malcolm X)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* [PATCH 4/5] mm/oom_kill.c: Use list_for_each_entry instead of list_for_each
  2007-07-22 18:42 [PATCH 0/5] Use list_for_each_entry(_safe) instead of list_for_each(_safe) Matthias Kaehlcke
                   ` (2 preceding siblings ...)
  2007-07-22 18:52 ` [PATCH 3/5] kernel/user.c: " Matthias Kaehlcke
@ 2007-07-22 18:54 ` Matthias Kaehlcke
  2007-07-22 18:56 ` [PATCH 5/5] mm/page_alloc.c: " Matthias Kaehlcke
  4 siblings, 0 replies; 6+ messages in thread
From: Matthias Kaehlcke @ 2007-07-22 18:54 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

mm/oom_kill.c: Convert list_for_each to list_for_each_entry in
oom_kill_process()

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>

--

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index a700141..b1851c4 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -347,7 +347,6 @@ static int oom_kill_process(struct task_struct *p, unsigned long points,
 		const char *message)
 {
 	struct task_struct *c;
-	struct list_head *tsk;
 
 	/*
 	 * If the task is already exiting, don't alarm the sysadmin or kill
@@ -362,8 +361,7 @@ static int oom_kill_process(struct task_struct *p, unsigned long points,
 					message, p->pid, p->comm, points);
 
 	/* Try to kill a child first */
-	list_for_each(tsk, &p->children) {
-		c = list_entry(tsk, struct task_struct, sibling);
+	list_for_each_entry(c, &p->children, sibling) {
 		if (c->mm == p->mm)
 			continue;
 		if (!oom_kill_task(c))

-- 
Matthias Kaehlcke
Linux Application Developer
Barcelona

    Ma patrie est où je suis, où personne ne me dérange, où personne
    ne me demande que je suis, d'où je viens et ce que je fais
                              (B. Traven)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* [PATCH 5/5] mm/page_alloc.c: Use list_for_each_entry instead of list_for_each
  2007-07-22 18:42 [PATCH 0/5] Use list_for_each_entry(_safe) instead of list_for_each(_safe) Matthias Kaehlcke
                   ` (3 preceding siblings ...)
  2007-07-22 18:54 ` [PATCH 4/5] mm/oom_kill.c: " Matthias Kaehlcke
@ 2007-07-22 18:56 ` Matthias Kaehlcke
  4 siblings, 0 replies; 6+ messages in thread
From: Matthias Kaehlcke @ 2007-07-22 18:56 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

mm/page_alloc.c: Convert list_for_each to list_for_each_entry in
mark_free_pages()

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>

--

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 05ace44..1f138fb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -731,7 +731,7 @@ void mark_free_pages(struct zone *zone)
 	unsigned long pfn, max_zone_pfn;
 	unsigned long flags;
 	int order;
-	struct list_head *curr;
+	struct page *curr_page;
 
 	if (!zone->spanned_pages)
 		return;
@@ -748,10 +748,11 @@ void mark_free_pages(struct zone *zone)
 		}
 
 	for (order = MAX_ORDER - 1; order >= 0; --order)
-		list_for_each(curr, &zone->free_area[order].free_list) {
+		list_for_each_entry(curr_page,
+				    &zone->free_area[order].free_list, lru) {
 			unsigned long i;
 
-			pfn = page_to_pfn(list_entry(curr, struct page, lru));
+			pfn = page_to_pfn(curr_page);
 			for (i = 0; i < (1UL << order); i++)
 				swsusp_set_page_free(pfn_to_page(pfn + i));
 		}

-- 
Matthias Kaehlcke
Linux Application Developer
Barcelona

              La posibilidad de realizar un suenyo es lo
                 que hace que la vida sea interesante
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

end of thread, other threads:[~2007-07-22 18:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-22 18:42 [PATCH 0/5] Use list_for_each_entry(_safe) instead of list_for_each(_safe) Matthias Kaehlcke
2007-07-22 18:49 ` [PATCH 1/5] kernel/exit.c: " Matthias Kaehlcke
2007-07-22 18:51 ` [PATCH 2/5] kernel/time/clocksource.c: Use list_for_each_entry instead of list_for_each Matthias Kaehlcke
2007-07-22 18:52 ` [PATCH 3/5] kernel/user.c: " Matthias Kaehlcke
2007-07-22 18:54 ` [PATCH 4/5] mm/oom_kill.c: " Matthias Kaehlcke
2007-07-22 18:56 ` [PATCH 5/5] mm/page_alloc.c: " Matthias Kaehlcke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox