Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Make cache_lookup return bool for clarity.
details: https://anonhg.NetBSD.org/src/rev/afd616598990
branches: trunk
changeset: 352151:afd616598990
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Mar 18 19:43:31 2017 +0000
description:
Make cache_lookup return bool for clarity.
diffstat:
sys/kern/vfs_cache.c | 41 +++++++++++++++++++++--------------------
sys/sys/namei.src | 6 +++---
2 files changed, 24 insertions(+), 23 deletions(-)
diffs (192 lines):
diff -r 6f20d35c0b66 -r afd616598990 sys/kern/vfs_cache.c
--- a/sys/kern/vfs_cache.c Sat Mar 18 19:05:38 2017 +0000
+++ b/sys/kern/vfs_cache.c Sat Mar 18 19:43:31 2017 +0000
@@ -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 @@
* 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 @@
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 @@
*vn_ret = NULL;
if (__predict_false(!doingcache)) {
- return 0;
+ return false;
}
cpup = curcpu()->ci_data.cpu_nch;
@@ -527,7 +528,7 @@
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 @@
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 @@
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 @@
(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_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 @@
*/
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 @@
if (__predict_false(!doingcache)) {
/* found nothing */
- return 0;
+ return false;
}
cpup = curcpu()->ci_data.cpu_nch;
@@ -639,14 +640,14 @@
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 @@
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 @@
*/
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;
}
/*
diff -r 6f20d35c0b66 -r afd616598990 sys/sys/namei.src
--- a/sys/sys/namei.src Sat Mar 18 19:05:38 2017 +0000
+++ b/sys/sys/namei.src Sat Mar 18 19:43:31 2017 +0000
@@ -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 @@
#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 *,
Home |
Main Index |
Thread Index |
Old Index