From 938838feb102d9d4dec3db873f47344b5944d65a Mon Sep 17 00:00:00 2001 From: David Schultz Date: Fri, 18 Mar 2005 21:23:32 +0000 Subject: [PATCH] Don't brelse(bp) if bp is null. Also, eliminate some redundancy and dead code. Found by: Coverity Prevent analysis tool --- sys/nfsclient/nfs_bio.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c index f8778502806b..17c3c3d9516a 100644 --- a/sys/nfsclient/nfs_bio.c +++ b/sys/nfsclient/nfs_bio.c @@ -356,7 +356,7 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) { struct nfsnode *np = VTONFS(vp); int biosize, i; - struct buf *bp = 0, *rabp; + struct buf *bp, *rabp; struct vattr vattr; struct thread *td; struct nfsmount *nmp = VFSTONFS(vp->v_mount); @@ -682,24 +682,17 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) break; default: printf(" nfs_bioread: type %x unexpected\n", vp->v_type); + bp = NULL; break; }; if (n > 0) { error = uiomove(bp->b_data + on, (int)n, uio); } - switch (vp->v_type) { - case VREG: - break; - case VLNK: + if (vp->v_type == VLNK) n = 0; - break; - case VDIR: - break; - default: - printf(" nfs_bioread: type %x unexpected\n", vp->v_type); - } - brelse(bp); + if (bp != NULL) + brelse(bp); } while (error == 0 && uio->uio_resid > 0 && n > 0); return (error); } @@ -1055,12 +1048,6 @@ nfs_write(struct vop_write_args *ap) break; } } - if (!bp) { - error = nfs_sigintr(nmp, NULL, td); - if (!error) - error = EINTR; - break; - } if (bp->b_wcred == NOCRED) bp->b_wcred = crhold(cred); np->n_flag |= NMODIFIED;