All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@openvz.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devel@openvz.org, Matt Mackall <mpm@selenic.com>
Subject: [PATCH 2/3] Prepare pid_nr() etc functions to work with not-NULL pids
Date: Wed, 03 Oct 2007 18:20:43 +0400	[thread overview]
Message-ID: <4703A53B.9090804@openvz.org> (raw)
In-Reply-To: <4703A44F.9020402@openvz.org>

Just make the __pid_nr() etc functions that expect the argument
to always be not NULL.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/include/linux/pid.h b/include/linux/pid.h
index e29a900..50b6899 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -135,21 +135,32 @@ extern void zap_pid_ns_processes(struct 
  * see also task_xid_nr() etc in include/linux/sched.h
  */
 
+static inline pid_t __pid_nr(struct pid *pid)
+{
+	return pid->numbers[0].nr;
+}
+
 static inline pid_t pid_nr(struct pid *pid)
 {
 	pid_t nr = 0;
 	if (pid)
-		nr = pid->numbers[0].nr;
+		nr = __pid_nr(pid);
 	return nr;
 }
 
+pid_t __pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
 
+static inline pid_t __pid_vnr(struct pid *pid)
+{
+	return pid->numbers[pid->level].nr;
+}
+
 static inline pid_t pid_vnr(struct pid *pid)
 {
 	pid_t nr = 0;
 	if (pid)
-		nr = pid->numbers[pid->level].nr;
+		nr = __pid_vnr(pid);
 	return nr;
 }
 
diff --git a/kernel/pid.c b/kernel/pid.c
index d7388d7..b7a11cf 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -430,12 +441,12 @@ struct pid *find_get_pid(pid_t nr)
 	return pid;
 }
 
-pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
+pid_t __pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
 {
 	struct upid *upid;
 	pid_t nr = 0;
 
-	if (pid && ns->level <= pid->level) {
+	if (ns->level <= pid->level) {
 		upid = &pid->numbers[ns->level];
 		if (upid->ns == ns)
 			nr = upid->nr;
@@ -443,6 +454,14 @@ pid_t pid_nr_ns(struct pid *pid, struct 
 	return nr;
 }
 
+pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
+{
+	pid_t nr = 0;
+	if (pid)
+		nr = __pid_nr_ns(pid, ns);
+	return nr;
+}
+
 pid_t task_pid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
 {
 	return pid_nr_ns(task_pid(tsk), ns);


  parent reply	other threads:[~2007-10-03 14:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-03 14:16 [PATCH 0/3] Make tasks always have non-zero pids Pavel Emelyanov
2007-10-03 14:19 ` [PATCH 1/3] Introduce the dummy_pid Pavel Emelyanov
2007-10-03 18:06   ` Randy Dunlap
2007-10-04  8:56     ` Pavel Emelyanov
2007-10-03 14:20 ` Pavel Emelyanov [this message]
2007-10-03 16:42   ` [PATCH 2/3] Prepare pid_nr() etc functions to work with not-NULL pids Matt Mackall
2007-10-04  8:54     ` Pavel Emelyanov
2007-10-04 17:13       ` Matt Mackall
2007-10-05 13:16         ` Pavel Emelyanov
2007-10-03 14:23 ` [PATCH 3/3] Use the __pid_nr() calls where appropriate Pavel Emelyanov
2007-10-05  5:53 ` [PATCH 0/3] Make tasks always have non-zero pids sukadev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4703A53B.9090804@openvz.org \
    --to=xemul@openvz.org \
    --cc=akpm@osdl.org \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=sukadev@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.