Author: alc
Date: Sat Feb 25 21:06:39 2012
New Revision: 232166
URL: http://svn.freebsd.org/changeset/base/232166

Log:
  Simplify vm_mmap()'s control flow.
  
  Add a comment describing what vm_mmap_to_errno() does.
  
  Reviewed by:  kib
  MFC after:    3 weeks
  X-MFC after:  r232071

Modified:
  head/sys/vm/vm_mmap.c

Modified: head/sys/vm/vm_mmap.c
==============================================================================
--- head/sys/vm/vm_mmap.c       Sat Feb 25 19:21:24 2012        (r232165)
+++ head/sys/vm/vm_mmap.c       Sat Feb 25 21:06:39 2012        (r232166)
@@ -1447,9 +1447,8 @@ vm_mmap(vm_map_t map, vm_offset_t *addr,
 {
        boolean_t fitit;
        vm_object_t object = NULL;
-       int rv = KERN_SUCCESS;
-       int docow, error;
        struct thread *td = curthread;
+       int docow, error, rv;
        boolean_t writecounted;
 
        if (size == 0)
@@ -1555,31 +1554,35 @@ vm_mmap(vm_map_t map, vm_offset_t *addr,
                rv = vm_map_fixed(map, object, foff, *addr, size,
                                 prot, maxprot, docow);
 
-       if (rv != KERN_SUCCESS) {
+       if (rv == KERN_SUCCESS) {
+               /*
+                * If the process has requested that all future mappings
+                * be wired, then heed this.
+                */
+               if (map->flags & MAP_WIREFUTURE)
+                       vm_map_wire(map, *addr, *addr + size,
+                           VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
+       } else {
                /*
-                * Lose the object reference. Will destroy the
-                * object if it's an unnamed anonymous mapping
-                * or named anonymous without other references.
-                *
                 * If this mapping was accounted for in the vnode's
                 * writecount, then undo that now.
                 */
                if (writecounted)
                        vnode_pager_release_writecount(object, 0, size);
+               /*
+                * Lose the object reference.  Will destroy the
+                * object if it's an unnamed anonymous mapping
+                * or named anonymous without other references.
+                */
                vm_object_deallocate(object);
        }
-
-       /*
-        * If the process has requested that all future mappings
-        * be wired, then heed this.
-        */
-       if ((rv == KERN_SUCCESS) && (map->flags & MAP_WIREFUTURE))
-               vm_map_wire(map, *addr, *addr + size,
-                   VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
-
        return (vm_mmap_to_errno(rv));
 }
 
+/*
+ * Translate a Mach VM return code to zero on success or the appropriate errno
+ * on failure.
+ */
 int
 vm_mmap_to_errno(int rv)
 {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to