mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: nkiesel@tbdnetworks.com (Norbert Kiesel)
To: linux-kernel@vger.kernel.org
Cc: hch@lst.de
Subject: [Patch] kernel/ptrace.c minor cleanup
Date: Sat, 19 Nov 2005 23:58:18 -0800	[thread overview]
Message-ID: <20051120075818.GA5200@defiant.tbdnetworks.com> (raw)

Hi,

this patch
 - removes a (basically) unused variable
 - removes some tailing whitepsace
 - converts 2 "if (x) BUG()" to "BUG_ON(x)"
 - fixes one comment

Best,
  Norbert


diff -ru a/kernel/ptrace.c b/kernel/ptrace.c
--- a/kernel/ptrace.c	2005-11-19 23:01:16.000000000 -0800
+++ b/kernel/ptrace.c	2005-11-19 23:44:04.000000000 -0800
@@ -29,8 +29,7 @@
  */
 void __ptrace_link(task_t *child, task_t *new_parent)
 {
-	if (!list_empty(&child->ptrace_list))
-		BUG();
+	BUG_ON(!list_empty(&child->ptrace_list));
 	if (child->parent == new_parent)
 		return;
 	list_add(&child->ptrace_list, &child->parent->ptrace_children);
@@ -38,7 +37,7 @@
 	child->parent = new_parent;
 	SET_LINKS(child);
 }
- 
+
 /*
  * Turn a tracing stop into a normal stop now, since with no tracer there
  * would be no way to wake it up with SIGCONT or SIGKILL.  If there was a
@@ -71,8 +70,7 @@
  */
 void __ptrace_unlink(task_t *child)
 {
-	if (!child->ptrace)
-		BUG();
+	BUG_ON(!child->ptrace);
 	child->ptrace = 0;
 	if (!list_empty(&child->ptrace_list)) {
 		list_del_init(&child->ptrace_list);
@@ -113,9 +111,8 @@
 	}
 	read_unlock(&tasklist_lock);
 
-	if (!ret && !kill) {
+	if (!ret && !kill)
 		wait_task_inactive(child);
-	}
 
 	/* All systems go.. */
 	return ret;
@@ -150,9 +147,8 @@
 
 int ptrace_attach(struct task_struct *task)
 {
-	int retval;
+	int retval = -EPERM;
 	task_lock(task);
-	retval = -EPERM;
 	if (task->pid <= 1)
 		goto bad;
 	if (task->tgid == current->tgid)
@@ -206,7 +202,7 @@
 
 /*
  * Access another process' address space.
- * Source/target buffer must be kernel space, 
+ * Source/target buffer must be kernel space,
  * Do not walk the page table directly, use get_user_pages
  */
 
@@ -254,7 +250,7 @@
 	}
 	up_read(&mm->mmap_sem);
 	mmput(mm);
-	
+
 	return buf - old_buf;
 }
 
@@ -278,7 +274,7 @@
 		copied += retval;
 		src += retval;
 		dst += retval;
-		len -= retval;			
+		len -= retval;
 	}
 	return copied;
 }
@@ -303,7 +299,7 @@
 		copied += retval;
 		src += retval;
 		dst += retval;
-		len -= retval;			
+		len -= retval;
 	}
 	return copied;
 }
@@ -412,11 +408,10 @@
 		struct task_struct **childp)
 {
 	struct task_struct *child;
-	int ret;
 
 	/*
 	 * Callers use child == NULL as an indication to exit early even
-	 * when the return value is 0, so make sure it is non-NULL here.
+	 * when the return value is 0, so make sure it is NULL here.
 	 */
 	*childp = NULL;
 
@@ -426,8 +421,7 @@
 		 */
 		if (current->ptrace & PT_PTRACED)
 			return -EPERM;
-		ret = security_ptrace(current->parent, current);
-		if (ret)
+		if (security_ptrace(current->parent, current))
 			return -EPERM;
 		/*
 		 * Set the ptrace bit in the process ptrace flags.
@@ -442,7 +436,6 @@
 	if (pid == 1)
 		return -EPERM;
 
-	ret = -ESRCH;
 	read_lock(&tasklist_lock);
 	child = find_task_by_pid(pid);
 	if (child)

                 reply	other threads:[~2005-11-20  7:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20051120075818.GA5200@defiant.tbdnetworks.com \
    --to=nkiesel@tbdnetworks.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®