summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfs_vnops.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-06-13 05:24:27 +0000
committerkib <kib@FreeBSD.org>2010-06-13 05:24:27 +0000
commit9100139edc3976c40b4dd05903c61be5c5fc333d (patch)
tree1577a85dd66937c640490d5a03b9962a2385299f /sys/nfsclient/nfs_vnops.c
parent82a6368b8628b24215cb22de6039e60e2fad7aff (diff)
downloadFreeBSD-src-9100139edc3976c40b4dd05903c61be5c5fc333d.zip
FreeBSD-src-9100139edc3976c40b4dd05903c61be5c5fc333d.tar.gz
In NFS clients, instead of inconsistently using #ifdef
DIAGNOSTIC and #ifndef DIAGNOSTIC for debug assertions, prefer KASSERT(). Also change one #ifdef DIAGNOSTIC in the new nfs server. Submitted by: Mikolaj Golub <to.my.trociny gmail com> MFC after: 2 weeks
Diffstat (limited to 'sys/nfsclient/nfs_vnops.c')
-rw-r--r--sys/nfsclient/nfs_vnops.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index 7ca015f..163a67e 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -1348,10 +1348,7 @@ nfs_writerpc(struct vnode *vp, struct uio *uiop, struct ucred *cred,
int v3 = NFS_ISV3(vp), committed = NFSV3WRITE_FILESYNC;
int wsize;
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1)
- panic("nfs: writerpc iovcnt > 1");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1, ("nfs: writerpc iovcnt > 1"));
*must_commit = 0;
tsiz = uiop->uio_resid;
mtx_lock(&nmp->nm_mtx);
@@ -1708,12 +1705,8 @@ nfs_remove(struct vop_remove_args *ap)
int error = 0;
struct vattr vattr;
-#ifndef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("nfs_remove: no name");
- if (vrefcnt(vp) < 1)
- panic("nfs_remove: bad v_usecount");
-#endif
+ KASSERT((cnp->cn_flags & HASBUF) != 0, ("nfs_remove: no name"));
+ KASSERT(vrefcnt(vp) > 0, ("nfs_remove: bad v_usecount"));
if (vp->v_type == VDIR)
error = EPERM;
else if (vrefcnt(vp) == 1 || (np->n_sillyrename &&
@@ -1814,11 +1807,8 @@ nfs_rename(struct vop_rename_args *ap)
struct componentname *fcnp = ap->a_fcnp;
int error;
-#ifndef DIAGNOSTIC
- if ((tcnp->cn_flags & HASBUF) == 0 ||
- (fcnp->cn_flags & HASBUF) == 0)
- panic("nfs_rename: no name");
-#endif
+ KASSERT((tcnp->cn_flags & HASBUF) != 0 &&
+ (fcnp->cn_flags & HASBUF) != 0, ("nfs_rename: no name"));
/* Check for cross-device rename */
if ((fvp->v_mount != tdvp->v_mount) ||
(tvp && (fvp->v_mount != tvp->v_mount))) {
@@ -2277,11 +2267,10 @@ nfs_readdirrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred)
int attrflag;
int v3 = NFS_ISV3(vp);
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uiop->uio_offset & (DIRBLKSIZ - 1)) ||
- (uiop->uio_resid & (DIRBLKSIZ - 1)))
- panic("nfs readdirrpc bad uio");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1 &&
+ (uiop->uio_offset & (DIRBLKSIZ - 1)) == 0 &&
+ (uiop->uio_resid & (DIRBLKSIZ - 1)) == 0,
+ ("nfs readdirrpc bad uio"));
/*
* If there is no cookie, assume directory was stale.
@@ -2482,11 +2471,10 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred)
#ifndef nolint
dp = NULL;
#endif
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uiop->uio_offset & (DIRBLKSIZ - 1)) ||
- (uiop->uio_resid & (DIRBLKSIZ - 1)))
- panic("nfs readdirplusrpc bad uio");
-#endif
+ KASSERT(uiop->uio_iovcnt == 1 &&
+ (uiop->uio_offset & (DIRBLKSIZ - 1)) == 0 &&
+ (uiop->uio_resid & (DIRBLKSIZ - 1)) == 0,
+ ("nfs readdirplusrpc bad uio"));
ndp->ni_dvp = vp;
newvp = NULLVP;
@@ -2752,10 +2740,7 @@ nfs_sillyrename(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
cache_purge(dvp);
np = VTONFS(vp);
-#ifndef DIAGNOSTIC
- if (vp->v_type == VDIR)
- panic("nfs: sillyrename dir");
-#endif
+ KASSERT(vp->v_type != VDIR, ("nfs: sillyrename dir"));
sp = malloc(sizeof (struct sillyrename),
M_NFSREQ, M_WAITOK);
sp->s_cred = crhold(cnp->cn_cred);
OpenPOWER on IntegriCloud