Skip to content

Commit

Permalink
do_wait: factor out "retval != 0" checks
Browse files Browse the repository at this point in the history
Every branch if the main "if" statement does the same code at the end.  Move
it down.  Also, fix the indentation.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Feb 8, 2008
1 parent ee7c82d commit 9cbab81
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
}
allowed = 1;

retval = 0;
if (task_is_stopped_or_traced(p)) {
/*
* It's stopped now, so it might later
Expand All @@ -1524,8 +1525,6 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
retval = wait_task_stopped(p, ret == 2,
(options & WNOWAIT), infop,
stat_addr, ru);
if (retval != 0) /* He released the lock. */
goto end;
} else if (p->exit_state == EXIT_ZOMBIE) {
/*
* Eligible but we cannot release it yet:
Expand All @@ -1537,9 +1536,6 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
retval = wait_task_zombie(p,
(options & WNOWAIT), infop,
stat_addr, ru);
/* He released the lock. */
if (retval != 0)
goto end;
} else if (p->exit_state != EXIT_DEAD) {
check_continued:
/*
Expand All @@ -1552,9 +1548,9 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
retval = wait_task_continued(p,
(options & WNOWAIT), infop,
stat_addr, ru);
if (retval != 0) /* He released the lock. */
goto end;
}
if (retval != 0) /* tasklist_lock released */
goto end;
}
if (!flag) {
list_for_each_entry(p, &tsk->ptrace_children,
Expand Down Expand Up @@ -1590,7 +1586,7 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
remove_wait_queue(&current->signal->wait_chldexit,&wait);
if (infop) {
if (retval > 0)
retval = 0;
retval = 0;
else {
/*
* For a WNOHANG return, clear out all the fields
Expand Down

0 comments on commit 9cbab81

Please sign in to comment.