Module Name:    src
Committed By:   dholland
Date:           Mon Apr 18 00:47:24 UTC 2011

Modified Files:
        src/sys/kern: vfs_lookup.c

Log Message:
Simplify logic: at the bottom of the loop, instead of checking if we
should continue and if not breaking unconditionally, check if we
should break and if not use the bottom of the loop to continue to the
next iteration.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/kern/vfs_lookup.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.182 src/sys/kern/vfs_lookup.c:1.183
--- src/sys/kern/vfs_lookup.c:1.182	Mon Apr 18 00:47:04 2011
+++ src/sys/kern/vfs_lookup.c	Mon Apr 18 00:47:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.182 2011/04/18 00:47:04 dholland Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.183 2011/04/18 00:47:24 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.182 2011/04/18 00:47:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.183 2011/04/18 00:47:24 dholland Exp $");
 
 #include "opt_magiclinks.h"
 
@@ -1229,6 +1229,8 @@
 		}
 
 		/*
+		 * Not a symbolic link.
+		 *
 		 * Check for directory, if the component was
 		 * followed by a series of slashes.
 		 */
@@ -1245,23 +1247,23 @@
 		}
 
 		/*
-		 * Not a symbolic link.  If this was not the
-		 * last component, then continue at the next
-		 * component, else return.
+		 * Stop if we've reached the last component.
 		 */
-		if (!(cnp->cn_flags & ISLASTCN)) {
-			cnp->cn_nameptr = ndp->ni_next;
-			if (searchdir == foundobj) {
-				vrele(searchdir);
-			} else {
-				vput(searchdir);
-			}
-			searchdir = foundobj;
-			foundobj = NULL;
-			continue;
+		if (cnp->cn_flags & ISLASTCN) {
+			break;
 		}
 
-		break;
+		/*
+		 * Continue with the next component.
+		 */
+		cnp->cn_nameptr = ndp->ni_next;
+		if (searchdir == foundobj) {
+			vrele(searchdir);
+		} else {
+			vput(searchdir);
+		}
+		searchdir = foundobj;
+		foundobj = NULL;
 	}
 
 	if (foundobj != NULL) {

Reply via email to