Change zap_threads() paths to use for_each_thread() rather than
while_each_thread().

While at it, change zap_threads() to avoid the nested if's to make
the code more readable and lessen the indentation.

Signed-off-by: Oleg Nesterov <o...@redhat.com>
---
 fs/coredump.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/fs/coredump.c b/fs/coredump.c
index 4fed8d0..b3c153c 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -292,15 +292,14 @@ static int zap_process(struct task_struct *start, int 
exit_code, int flags)
        start->signal->group_exit_code = exit_code;
        start->signal->group_stop_count = 0;
 
-       t = start;
-       do {
+       for_each_thread(start, t) {
                task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
                if (t != current && t->mm) {
                        sigaddset(&t->pending.signal, SIGKILL);
                        signal_wake_up(t, 1);
                        nr++;
                }
-       } while_each_thread(start, t);
+       }
 
        return nr;
 }
@@ -362,18 +361,18 @@ static int zap_threads(struct task_struct *tsk, struct 
mm_struct *mm,
                        continue;
                if (g->flags & PF_KTHREAD)
                        continue;
-               p = g;
-               do {
-                       if (p->mm) {
-                               if (unlikely(p->mm == mm)) {
-                                       lock_task_sighand(p, &flags);
-                                       nr += zap_process(p, exit_code,
-                                                         SIGNAL_GROUP_EXIT);
-                                       unlock_task_sighand(p, &flags);
-                               }
-                               break;
+
+               for_each_thread(g, p) {
+                       if (unlikely(!p->mm))
+                               continue;
+                       if (unlikely(p->mm == mm)) {
+                               lock_task_sighand(p, &flags);
+                               nr += zap_process(p, exit_code,
+                                                       SIGNAL_GROUP_EXIT);
+                               unlock_task_sighand(p, &flags);
                        }
-               } while_each_thread(g, p);
+                       break;
+               }
        }
        rcu_read_unlock();
 done:
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to