Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Apr 2017 20:57:16 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316687 - head/sys/vm
Message-ID:  <201704102057.v3AKvGwp040267@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Mon Apr 10 20:57:16 2017
New Revision: 316687
URL: https://svnweb.freebsd.org/changeset/base/316687

Log:
  Consistently use for-loops in vm_map_protect().
  
  No functional change.
  
  Reviewed by:	kib
  MFC after:	1 week
  Sponsored by:	Dell EMC Isilon
  X-Differential Revision:	https://reviews.freebsd.org/D10349

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==============================================================================
--- head/sys/vm/vm_map.c	Mon Apr 10 20:55:42 2017	(r316686)
+++ head/sys/vm/vm_map.c	Mon Apr 10 20:57:16 2017	(r316687)
@@ -1976,8 +1976,8 @@ vm_map_protect(vm_map_t map, vm_offset_t
 	/*
 	 * Make a first pass to check for protection violations.
 	 */
-	current = entry;
-	while ((current != &map->header) && (current->start < end)) {
+	for (current = entry; current != &map->header && current->start < end;
+	    current = current->next) {
 		if (current->eflags & MAP_ENTRY_IS_SUB_MAP) {
 			vm_map_unlock(map);
 			return (KERN_INVALID_ARGUMENT);
@@ -1986,17 +1986,15 @@ vm_map_protect(vm_map_t map, vm_offset_t
 			vm_map_unlock(map);
 			return (KERN_PROTECTION_FAILURE);
 		}
-		current = current->next;
 	}
 
-
 	/*
 	 * Do an accounting pass for private read-only mappings that
 	 * now will do cow due to allowed write (e.g. debugger sets
 	 * breakpoint on text segment)
 	 */
-	for (current = entry; (current != &map->header) &&
-	     (current->start < end); current = current->next) {
+	for (current = entry; current != &map->header && current->start < end;
+	    current = current->next) {
 
 		vm_map_clip_end(map, current, end);
 
@@ -2049,8 +2047,8 @@ vm_map_protect(vm_map_t map, vm_offset_t
 	 * Go back and fix up protections. [Note that clipping is not
 	 * necessary the second time.]
 	 */
-	current = entry;
-	while ((current != &map->header) && (current->start < end)) {
+	for (current = entry; current != &map->header && current->start < end;
+	    current = current->next) {
 		old_prot = current->protection;
 
 		if (set_max)
@@ -2084,7 +2082,6 @@ vm_map_protect(vm_map_t map, vm_offset_t
 #undef	MASK
 		}
 		vm_map_simplify_entry(map, current);
-		current = current->next;
 	}
 	vm_map_unlock(map);
 	return (KERN_SUCCESS);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704102057.v3AKvGwp040267>