git: 01d3ddbfcfa5 - stable/13 - vm_mmap: Remove obsolete code and comments from vm_mmap()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 27 Jul 2022 13:52:36 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=01d3ddbfcfa5bb6b0e809b0c12ba31613bf61056

commit 01d3ddbfcfa5bb6b0e809b0c12ba31613bf61056
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-07-13 13:39:26 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-07-27 13:50:55 +0000

    vm_mmap: Remove obsolete code and comments from vm_mmap()
    
    In preparation for removing OBJT_DEFAULT, eliminate some stale/unhelpful
    comments from vm_mmap(), and remove an unused case.  In particular, the
    remaining callers of vm_mmap() in the tree do not specify OBJT_DEFAULT.
    
    It's much more common to use vm_map_find() to map an object into user
    memory, so rather than adjusting vm_mmap() to handle OBJT_SWAP objects,
    let's further discourage its use and simply remove OBJT_DEFAULT
    handling.
    
    Reviewed by:    dougm, alc, kib
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit eee9aab9cb5adfbf39ab5622b441d0021c13efea)
---
 sys/vm/vm_mmap.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 48bf364731a2..0aaa534b8ca4 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -1442,13 +1442,6 @@ vm_mmap_cdev(struct thread *td, vm_size_t objsize, vm_prot_t prot,
 	return (0);
 }
 
-/*
- * vm_mmap()
- *
- * Internal version of mmap used by exec, sys5 shared memory, and
- * various device drivers.  Handle is either a vnode pointer, a
- * character device, or NULL for MAP_ANON.
- */
 int
 vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot,
 	vm_prot_t maxprot, int flags,
@@ -1467,9 +1460,6 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot,
 	object = NULL;
 	writecounted = FALSE;
 
-	/*
-	 * Lookup/allocate object.
-	 */
 	switch (handle_type) {
 	case OBJT_DEVICE: {
 		struct cdevsw *dsw;
@@ -1489,12 +1479,6 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot,
 		error = vm_mmap_vnode(td, size, prot, &maxprot, &flags,
 		    handle, &foff, &object, &writecounted);
 		break;
-	case OBJT_DEFAULT:
-		if (handle == NULL) {
-			error = 0;
-			break;
-		}
-		/* FALLTHROUGH */
 	default:
 		error = EINVAL;
 		break;