Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Simplify logic: at the bottom of the loop, instead ...



details:   https://anonhg.NetBSD.org/src/rev/20bcbad30d01
branches:  trunk
changeset: 764373:20bcbad30d01
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Apr 18 00:47:24 2011 +0000

description:
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.

diffstat:

 sys/kern/vfs_lookup.c |  34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diffs (65 lines):

diff -r 8672f9a4a8ff -r 20bcbad30d01 sys/kern/vfs_lookup.c
--- a/sys/kern/vfs_lookup.c     Mon Apr 18 00:47:04 2011 +0000
+++ b/sys/kern/vfs_lookup.c     Mon Apr 18 00:47:24 2011 +0000
@@ -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) {



Home | Main Index | Thread Index | Old Index