Module Name:    src
Committed By:   riastradh
Date:           Sat Mar 18 19:43:31 UTC 2017

Modified Files:
        src/sys/kern: vfs_cache.c
        src/sys/sys: namei.src

Log Message:
Make cache_lookup return bool for clarity.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.37 -r1.38 src/sys/sys/namei.src

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_cache.c
diff -u src/sys/kern/vfs_cache.c:1.112 src/sys/kern/vfs_cache.c:1.113
--- src/sys/kern/vfs_cache.c:1.112	Wed Jan 11 09:04:37 2017
+++ src/sys/kern/vfs_cache.c	Sat Mar 18 19:43:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_cache.c,v 1.112 2017/01/11 09:04:37 hannken Exp $	*/
+/*	$NetBSD: vfs_cache.c,v 1.113 2017/03/18 19:43:31 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.112 2017/01/11 09:04:37 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.113 2017/03/18 19:43:31 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -498,7 +498,7 @@ cache_lookup_entry(const struct vnode *d
  * other errors, and the value of VN might or might not have been set
  * depending on what error occurred.)
  */
-int
+bool
 cache_lookup(struct vnode *dvp, const char *name, size_t namelen,
 	     uint32_t nameiop, uint32_t cnflags,
 	     int *iswht_ret, struct vnode **vn_ret)
@@ -506,7 +506,8 @@ cache_lookup(struct vnode *dvp, const ch
 	struct namecache *ncp;
 	struct vnode *vp;
 	struct nchcpu *cpup;
-	int error, ret_value;
+	int error;
+	bool hit;
 
 
 	/* Establish default result values */
@@ -516,7 +517,7 @@ cache_lookup(struct vnode *dvp, const ch
 	*vn_ret = NULL;
 
 	if (__predict_false(!doingcache)) {
-		return 0;
+		return false;
 	}
 
 	cpup = curcpu()->ci_data.cpu_nch;
@@ -527,7 +528,7 @@ cache_lookup(struct vnode *dvp, const ch
 		COUNT(cpup, ncs_long);
 		mutex_exit(&cpup->cpu_lock);
 		/* found nothing */
-		return 0;
+		return false;
 	}
 
 	ncp = cache_lookup_entry(dvp, name, namelen);
@@ -535,7 +536,7 @@ cache_lookup(struct vnode *dvp, const ch
 		COUNT(cpup, ncs_miss);
 		mutex_exit(&cpup->cpu_lock);
 		/* found nothing */
-		return 0;
+		return false;
 	}
 	if ((cnflags & MAKEENTRY) == 0) {
 		COUNT(cpup, ncs_badhits);
@@ -548,7 +549,7 @@ cache_lookup(struct vnode *dvp, const ch
 		mutex_exit(&ncp->nc_lock);
 		mutex_exit(&cpup->cpu_lock);
 		/* found nothing */
-		return 0;
+		return false;
 	}
 	if (ncp->nc_vp == NULL) {
 		if (iswht_ret != NULL) {
@@ -565,7 +566,7 @@ cache_lookup(struct vnode *dvp, const ch
 		    (cnflags & ISLASTCN) == 0)) {
 			COUNT(cpup, ncs_neghits);
 			/* found neg entry; vn is already null from above */
-			ret_value = 1;
+			hit = true;
 		} else {
 			COUNT(cpup, ncs_badhits);
 			/*
@@ -575,11 +576,11 @@ cache_lookup(struct vnode *dvp, const ch
 			 */
 			cache_invalidate(ncp);
 			/* found nothing */
-			ret_value = 0;
+			hit = false;
 		}
 		mutex_exit(&ncp->nc_lock);
 		mutex_exit(&cpup->cpu_lock);
-		return ret_value;
+		return hit;
 	}
 
 	vp = ncp->nc_vp;
@@ -599,20 +600,20 @@ cache_lookup(struct vnode *dvp, const ch
 		 */
 		COUNT_UNL(cpup, ncs_falsehits);
 		/* found nothing */
-		return 0;
+		return false;
 	}
 
 	COUNT_UNL(cpup, ncs_goodhits);
 	/* found it */
 	*vn_ret = vp;
-	return 1;
+	return true;
 }
 
 
 /*
  * Cut-'n-pasted version of the above without the nameiop argument.
  */
-int
+bool
 cache_lookup_raw(struct vnode *dvp, const char *name, size_t namelen,
 		 uint32_t cnflags,
 		 int *iswht_ret, struct vnode **vn_ret)
@@ -630,7 +631,7 @@ cache_lookup_raw(struct vnode *dvp, cons
 
 	if (__predict_false(!doingcache)) {
 		/* found nothing */
-		return 0;
+		return false;
 	}
 
 	cpup = curcpu()->ci_data.cpu_nch;
@@ -639,14 +640,14 @@ cache_lookup_raw(struct vnode *dvp, cons
 		COUNT(cpup, ncs_long);
 		mutex_exit(&cpup->cpu_lock);
 		/* found nothing */
-		return 0;
+		return false;
 	}
 	ncp = cache_lookup_entry(dvp, name, namelen);
 	if (__predict_false(ncp == NULL)) {
 		COUNT(cpup, ncs_miss);
 		mutex_exit(&cpup->cpu_lock);
 		/* found nothing */
-		return 0;
+		return false;
 	}
 	vp = ncp->nc_vp;
 	if (vp == NULL) {
@@ -662,7 +663,7 @@ cache_lookup_raw(struct vnode *dvp, cons
 		mutex_exit(&ncp->nc_lock);
 		mutex_exit(&cpup->cpu_lock);
 		/* found negative entry; vn is already null from above */
-		return 1;
+		return true;
 	}
 	mutex_enter(vp->v_interlock);
 	mutex_exit(&ncp->nc_lock);
@@ -680,13 +681,13 @@ cache_lookup_raw(struct vnode *dvp, cons
 		 */
 		COUNT_UNL(cpup, ncs_falsehits);
 		/* found nothing */
-		return 0;
+		return false;
 	}
 
 	COUNT_UNL(cpup, ncs_goodhits); /* XXX can be "badhits" */
 	/* found it */
 	*vn_ret = vp;
-	return 1;
+	return true;
 }
 
 /*

Index: src/sys/sys/namei.src
diff -u src/sys/sys/namei.src:1.37 src/sys/sys/namei.src:1.38
--- src/sys/sys/namei.src:1.37	Tue Apr 21 03:18:21 2015
+++ src/sys/sys/namei.src	Sat Mar 18 19:43:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: namei.src,v 1.37 2015/04/21 03:18:21 riastradh Exp $	*/
+/*	$NetBSD: namei.src,v 1.38 2017/03/18 19:43:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1985, 1989, 1991, 1993
@@ -274,9 +274,9 @@ void	cache_purge1(struct vnode *, const 
 #define	PURGE_PARENTS	1
 #define	PURGE_CHILDREN	2
 #define	cache_purge(vp)	cache_purge1((vp),NULL,0,PURGE_PARENTS|PURGE_CHILDREN)
-int	cache_lookup(struct vnode *, const char *, size_t, uint32_t, uint32_t,
+bool	cache_lookup(struct vnode *, const char *, size_t, uint32_t, uint32_t,
 			int *, struct vnode **);
-int	cache_lookup_raw(struct vnode *, const char *, size_t, uint32_t,
+bool	cache_lookup_raw(struct vnode *, const char *, size_t, uint32_t,
 			int *, struct vnode **);
 int	cache_revlookup(struct vnode *, struct vnode **, char **, char *);
 void	cache_enter(struct vnode *, struct vnode *,

Reply via email to