svn commit: r232842 - head/sys/amd64/amd64

Alan Cox alc at FreeBSD.org
Mon Mar 12 00:47:14 UTC 2012


Author: alc
Date: Mon Mar 12 00:47:13 2012
New Revision: 232842
URL: http://svn.freebsd.org/changeset/base/232842

Log:
  Simplify the error checking in one branch of trap_pfault() and update
  the nearby comment.
  
  Add missing whitespace to a return statement in trap_pfault().
  
  Submitted by:	kib [2]

Modified:
  head/sys/amd64/amd64/trap.c

Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c	Sun Mar 11 22:30:06 2012	(r232841)
+++ head/sys/amd64/amd64/trap.c	Mon Mar 12 00:47:13 2012	(r232842)
@@ -645,7 +645,7 @@ trap_pfault(frame, usermode)
 	int usermode;
 {
 	vm_offset_t va;
-	struct vmspace *vm = NULL;
+	struct vmspace *vm;
 	vm_map_t map;
 	int rv = 0;
 	vm_prot_t ftype;
@@ -664,14 +664,10 @@ trap_pfault(frame, usermode)
 		map = kernel_map;
 	} else {
 		/*
-		 * This is a fault on non-kernel virtual memory.
-		 * vm is initialized above to NULL. If curproc is NULL
-		 * or curproc->p_vmspace is NULL the fault is fatal.
+		 * This is a fault on non-kernel virtual memory.  If either
+		 * p or p->p_vmspace is NULL, then the fault is fatal.
 		 */
-		if (p != NULL)
-			vm = p->p_vmspace;
-
-		if (vm == NULL)
+		if (p == NULL || (vm = p->p_vmspace) == NULL)
 			goto nogo;
 
 		map = &vm->vm_map;
@@ -735,8 +731,7 @@ nogo:
 		trap_fatal(frame, eva);
 		return (-1);
 	}
-
-	return((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV);
+	return ((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV);
 }
 
 static void


More information about the svn-src-all mailing list