From owner-svn-src-head@FreeBSD.ORG Sat Feb 25 21:06:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6137F1065674; Sat, 25 Feb 2012 21:06:40 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 338F88FC1C; Sat, 25 Feb 2012 21:06:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1PL6er0033884; Sat, 25 Feb 2012 21:06:40 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1PL6eOi033882; Sat, 25 Feb 2012 21:06:40 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201202252106.q1PL6eOi033882@svn.freebsd.org> From: Alan Cox Date: Sat, 25 Feb 2012 21:06:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232166 - head/sys/vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Feb 2012 21:06:40 -0000 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) {