Commit b8fe0c82 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by James Toy

task_pid_type() is only used by eligible_pid() which has to check wo_type

!= PIDTYPE_MAX anyway.  Remove this check from task_pid_type() and factor
out ->pids[type] access, this shrinks .text a bit and simplifies the code.

The matches the behaviour of other similar helpers, say get_task_pid(). 
The caller must ensure that pid_type is valid, not the callee.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent e653a591
...@@ -1101,17 +1101,15 @@ struct wait_opts { ...@@ -1101,17 +1101,15 @@ struct wait_opts {
int notask_error; int notask_error;
}; };
static struct pid *task_pid_type(struct task_struct *task, enum pid_type type) static inline
struct pid *task_pid_type(struct task_struct *task, enum pid_type type)
{ {
struct pid *pid = NULL; if (type != PIDTYPE_PID)
if (type == PIDTYPE_PID) task = task->group_leader;
pid = task->pids[type].pid; return task->pids[type].pid;
else if (type < PIDTYPE_MAX)
pid = task->group_leader->pids[type].pid;
return pid;
} }
static inline int eligible_pid(struct wait_opts *wo, struct task_struct *p) static int eligible_pid(struct wait_opts *wo, struct task_struct *p)
{ {
return wo->wo_type == PIDTYPE_MAX || return wo->wo_type == PIDTYPE_MAX ||
task_pid_type(p, wo->wo_type) == wo->wo_pid; task_pid_type(p, wo->wo_type) == wo->wo_pid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment