Messages in this thread |  | | Date | Mon, 30 Dec 2013 18:04:31 +0100 | From | Oleg Nesterov <> | Subject | Re: [PATCH 1/5] pid: get pid_t ppid of task in init_pid_ns |
| |
On 12/23, Richard Guy Briggs wrote: > > +static inline pid_t task_ppid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) > +{ > + pid_t pid; > + > + rcu_read_lock(); > + pid = pid_alive(tsk) ? > + task_pid_nr_ns(rcu_dereference(tsk->real_parent), ns) : 0; > + rcu_read_unlock(); > + > + return pid; > +}
I do not really mind, but perhaps
pid_t pid = 0;
rcu_read_lock(); if (pid_alive(task)) pid = task_pid_nr_ns(rcu_dereference(tsk->real_parent); rcu_read_unlock();
return pid;
looks a bit cleaner.
> +static inline pid_t task_ppid_nr(struct task_struct *tsk) > +{ > + pid_t pid; > + > + rcu_read_lock(); > + pid = pid_alive(tsk) ? > + task_pid_nr(rcu_dereference(tsk->real_parent)) : 0; > + rcu_read_unlock(); > + > + return pid; > +}
It could simply do
return task_ppid_nr_ns(tsk, init_pid_ns);
but again, I won't argue.
Oleg.
|  |