From a5e62f3760468b6e48695fa241c465491eae55bc Mon Sep 17 00:00:00 2001 From: Mike Karels Date: Thu, 20 Feb 1986 23:21:05 -0800 Subject: [PATCH] lint and cleanups from Sam SCCS-vsn: sys/kern/vfs_bio.c 6.9 SCCS-vsn: sys/kern/vfs_cluster.c 6.9 SCCS-vsn: sys/ufs/ffs/ffs_inode.c 6.18 SCCS-vsn: sys/ufs/ffs/ufs_inode.c 6.18 SCCS-vsn: sys/ufs/lfs/lfs_inode.c 6.18 SCCS-vsn: sys/ufs/ufs/ufs_inode.c 6.18 SCCS-vsn: sys/kern/vfs_lookup.c 6.26 SCCS-vsn: sys/ufs/ffs/ufs_lookup.c 6.26 SCCS-vsn: sys/ufs/ufs/ufs_lookup.c 6.26 SCCS-vsn: sys/ufs/ffs/ffs_subr.c 6.9 --- usr/src/sys/kern/vfs_bio.c | 26 +++--- usr/src/sys/kern/vfs_cluster.c | 26 +++--- usr/src/sys/kern/vfs_lookup.c | 144 ++++++++++++------------------- usr/src/sys/ufs/ffs/ffs_inode.c | 9 +- usr/src/sys/ufs/ffs/ffs_subr.c | 9 +- usr/src/sys/ufs/ffs/ufs_inode.c | 9 +- usr/src/sys/ufs/ffs/ufs_lookup.c | 144 ++++++++++++------------------- usr/src/sys/ufs/lfs/lfs_inode.c | 9 +- usr/src/sys/ufs/ufs/ufs_inode.c | 9 +- usr/src/sys/ufs/ufs/ufs_lookup.c | 144 ++++++++++++------------------- 10 files changed, 215 insertions(+), 314 deletions(-) diff --git a/usr/src/sys/kern/vfs_bio.c b/usr/src/sys/kern/vfs_bio.c index fff0289dd2..db917ad5d2 100644 --- a/usr/src/sys/kern/vfs_bio.c +++ b/usr/src/sys/kern/vfs_bio.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)vfs_bio.c 6.8 (Berkeley) %G% + * @(#)vfs_bio.c 6.9 (Berkeley) %G% */ #include "../machine/pte.h" @@ -35,7 +35,7 @@ bread(dev, blkno, size) bp = getblk(dev, blkno, size); if (bp->b_flags&B_DONE) { trace(TR_BREADHIT, pack(dev, size), blkno); - return(bp); + return (bp); } bp->b_flags |= B_READ; if (bp->b_bcount > bp->b_bufsize) @@ -44,7 +44,7 @@ bread(dev, blkno, size) trace(TR_BREADMISS, pack(dev, size), blkno); u.u_ru.ru_inblock++; /* pay for read */ biowait(bp); - return(bp); + return (bp); } /* @@ -202,7 +202,7 @@ brelse(bp) /* * Stick the buffer back on a free list. */ - s = spl6(); + s = splbio(); if (bp->b_bufsize <= 0) { /* block has no buffer ... put at front of unused buffer list */ flist = &bfreelist[BQ_EMPTY]; @@ -296,7 +296,7 @@ loop: if (bp->b_blkno != blkno || bp->b_dev != dev || bp->b_flags&B_INVAL) continue; - s = spl6(); + s = splbio(); if (bp->b_flags&B_BUSY) { bp->b_flags |= B_WANTED; sleep((caddr_t)bp, PRIBIO+1); @@ -308,7 +308,7 @@ loop: if (bp->b_bcount != size && brealloc(bp, size) == 0) goto loop; bp->b_flags |= B_CACHE; - return(bp); + return (bp); } if (major(dev) >= nblkdev) panic("blkdev"); @@ -321,7 +321,7 @@ loop: bp->b_error = 0; if (brealloc(bp, size) == 0) goto loop; - return(bp); + return (bp); } /* @@ -347,7 +347,7 @@ loop: bp->b_error = 0; if (brealloc(bp, size) == 0) goto loop; - return(bp); + return (bp); } /* @@ -402,7 +402,7 @@ loop: if (ep->b_bcount == 0 || ep->b_blkno > last || ep->b_blkno + btodb(ep->b_bcount) <= start) continue; - s = spl6(); + s = splbio(); if (ep->b_flags&B_BUSY) { ep->b_flags |= B_WANTED; sleep((caddr_t)ep, PRIBIO+1); @@ -433,7 +433,7 @@ getnewbuf() int s; loop: - s = spl6(); + s = splbio(); for (dp = &bfreelist[BQ_AGE]; dp > bfreelist; dp--) if (dp->av_forw != dp) break; @@ -465,7 +465,7 @@ biowait(bp) { int s; - s = spl6(); + s = splbio(); while ((bp->b_flags&B_DONE)==0) sleep((caddr_t)bp, PRIBIO); splx(s); @@ -523,7 +523,7 @@ loop: if (ep->b_bcount == 0 || ep->b_blkno > last || ep->b_blkno + btodb(ep->b_bcount) <= start) continue; - s = spl6(); + s = splbio(); if (ep->b_flags&B_BUSY) { ep->b_flags |= B_WANTED; sleep((caddr_t)ep, PRIBIO+1); @@ -554,7 +554,7 @@ bflush(dev) int s; loop: - s = spl6(); + s = splbio(); for (flist = bfreelist; flist < &bfreelist[BQ_EMPTY]; flist++) for (bp = flist->av_forw; bp != flist; bp = bp->av_forw) { if ((bp->b_flags & B_DELWRI) == 0) diff --git a/usr/src/sys/kern/vfs_cluster.c b/usr/src/sys/kern/vfs_cluster.c index 76a67724aa..30c295fda8 100644 --- a/usr/src/sys/kern/vfs_cluster.c +++ b/usr/src/sys/kern/vfs_cluster.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)vfs_cluster.c 6.8 (Berkeley) %G% + * @(#)vfs_cluster.c 6.9 (Berkeley) %G% */ #include "../machine/pte.h" @@ -35,7 +35,7 @@ bread(dev, blkno, size) bp = getblk(dev, blkno, size); if (bp->b_flags&B_DONE) { trace(TR_BREADHIT, pack(dev, size), blkno); - return(bp); + return (bp); } bp->b_flags |= B_READ; if (bp->b_bcount > bp->b_bufsize) @@ -44,7 +44,7 @@ bread(dev, blkno, size) trace(TR_BREADMISS, pack(dev, size), blkno); u.u_ru.ru_inblock++; /* pay for read */ biowait(bp); - return(bp); + return (bp); } /* @@ -202,7 +202,7 @@ brelse(bp) /* * Stick the buffer back on a free list. */ - s = spl6(); + s = splbio(); if (bp->b_bufsize <= 0) { /* block has no buffer ... put at front of unused buffer list */ flist = &bfreelist[BQ_EMPTY]; @@ -296,7 +296,7 @@ loop: if (bp->b_blkno != blkno || bp->b_dev != dev || bp->b_flags&B_INVAL) continue; - s = spl6(); + s = splbio(); if (bp->b_flags&B_BUSY) { bp->b_flags |= B_WANTED; sleep((caddr_t)bp, PRIBIO+1); @@ -308,7 +308,7 @@ loop: if (bp->b_bcount != size && brealloc(bp, size) == 0) goto loop; bp->b_flags |= B_CACHE; - return(bp); + return (bp); } if (major(dev) >= nblkdev) panic("blkdev"); @@ -321,7 +321,7 @@ loop: bp->b_error = 0; if (brealloc(bp, size) == 0) goto loop; - return(bp); + return (bp); } /* @@ -347,7 +347,7 @@ loop: bp->b_error = 0; if (brealloc(bp, size) == 0) goto loop; - return(bp); + return (bp); } /* @@ -402,7 +402,7 @@ loop: if (ep->b_bcount == 0 || ep->b_blkno > last || ep->b_blkno + btodb(ep->b_bcount) <= start) continue; - s = spl6(); + s = splbio(); if (ep->b_flags&B_BUSY) { ep->b_flags |= B_WANTED; sleep((caddr_t)ep, PRIBIO+1); @@ -433,7 +433,7 @@ getnewbuf() int s; loop: - s = spl6(); + s = splbio(); for (dp = &bfreelist[BQ_AGE]; dp > bfreelist; dp--) if (dp->av_forw != dp) break; @@ -465,7 +465,7 @@ biowait(bp) { int s; - s = spl6(); + s = splbio(); while ((bp->b_flags&B_DONE)==0) sleep((caddr_t)bp, PRIBIO); splx(s); @@ -523,7 +523,7 @@ loop: if (ep->b_bcount == 0 || ep->b_blkno > last || ep->b_blkno + btodb(ep->b_bcount) <= start) continue; - s = spl6(); + s = splbio(); if (ep->b_flags&B_BUSY) { ep->b_flags |= B_WANTED; sleep((caddr_t)ep, PRIBIO+1); @@ -554,7 +554,7 @@ bflush(dev) int s; loop: - s = spl6(); + s = splbio(); for (flist = bfreelist; flist < &bfreelist[BQ_EMPTY]; flist++) for (bp = flist->av_forw; bp != flist; bp = bp->av_forw) { if ((bp->b_flags & B_DELWRI) == 0) diff --git a/usr/src/sys/kern/vfs_lookup.c b/usr/src/sys/kern/vfs_lookup.c index 5f7aba1245..cc0dc98533 100644 --- a/usr/src/sys/kern/vfs_lookup.c +++ b/usr/src/sys/kern/vfs_lookup.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)vfs_lookup.c 6.25 (Berkeley) %G% + * @(#)vfs_lookup.c 6.26 (Berkeley) %G% */ #include "param.h" @@ -33,14 +33,14 @@ int dirchk = 0; #define NHASH(h, i, d) ((unsigned)((h) + (i) + 13 * (int)(d)) & ((NCHHASH)-1)) #endif -union nchash { - union nchash *nch_head[2]; - struct nch *nch_chain[2]; +union nchash { + union nchash *nch_head[2]; + struct nch *nch_chain[2]; } nchash[NCHHASH]; #define nch_forw nch_chain[0] #define nch_back nch_chain[1] -struct nch *nchhead, **nchtail; /* LRU chain pointers */ +struct nch *nchhead, **nchtail; /* LRU chain pointers */ struct nchstats nchstats; /* cache effectiveness statistics */ /* @@ -66,25 +66,25 @@ struct nchstats nchstats; /* cache effectiveness statistics */ * * Name caching works as follows: * - * names found by directory scans are retained in a cache - * for future reference. It is managed LRU, so frequently - * used names will hang around. Cache is indexed by hash value - * obtained from (ino,dev,name) where ino & dev refer to the - * directory containing name. + * Names found by directory scans are retained in a cache + * for future reference. It is managed LRU, so frequently + * used names will hang around. Cache is indexed by hash value + * obtained from (ino,dev,name) where ino & dev refer to the + * directory containing name. * - * For simplicity (and economy of storage), names longer than - * some (small) maximum length are not cached, they occur - * infrequently in any case, and are almost never of interest. + * For simplicity (and economy of storage), names longer than + * some (small) maximum length are not cached, they occur + * infrequently in any case, and are almost never of interest. * - * Upon reaching the last segment of a path, if the reference - * is for DELETE, or NOCACHE is set (rewrite), and the - * name is located in the cache, it will be dropped. + * Upon reaching the last segment of a path, if the reference + * is for DELETE, or NOCACHE is set (rewrite), and the + * name is located in the cache, it will be dropped. * - * We must be sure never to enter the name ".." into the cache - * because of the extremely kludgey way that rename() alters - * ".." in a situation like - * mv a/x b/x - * where x is a directory, and x/.. is the ".." in question. + * We must be sure never to enter the name ".." into the cache + * because of the extremely kludgey way that rename() alters + * ".." in a situation like + * mv a/x b/x + * where x is a directory, and x/.. is the ".." in question. * * Overall outline of namei: * @@ -270,10 +270,9 @@ dirloop2: ncp->nc_dev == dp->i_dev && ncp->nc_nlen == ndp->ni_dent.d_namlen && !bcmp(ncp->nc_name, ndp->ni_dent.d_name, - ncp->nc_nlen)) + (unsigned)ncp->nc_nlen)) break; } - if (ncp == (struct nch *)nhp) { nchstats.ncs_miss++; ncp = NULL; @@ -283,17 +282,16 @@ dirloop2: } else if (!makeentry) { nchstats.ncs_badhits++; } else { - - /* - * move this slot to end of LRU - * chain, if not already there - */ + /* + * move this slot to end of LRU + * chain, if not already there + */ if (ncp->nc_nxt) { - /* remove from LRU chain */ + /* remove from LRU chain */ *ncp->nc_prev = ncp->nc_nxt; ncp->nc_nxt->nc_prev = ncp->nc_prev; - /* and replace at end of it */ + /* and replace at end of it */ ncp->nc_nxt = NULL; ncp->nc_prev = nchtail; *nchtail = ncp; @@ -343,27 +341,21 @@ dirloop2: * the cache entry is invalid, or otherwise don't * want cache entry to exist. */ - - /* remove from LRU chain */ + /* remove from LRU chain */ *ncp->nc_prev = ncp->nc_nxt; if (ncp->nc_nxt) ncp->nc_nxt->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; - - /* remove from hash chain */ - remque(ncp); - - /* insert at head of LRU list (first to grab) */ + remque(ncp); /* remove from hash chain */ + /* insert at head of LRU list (first to grab) */ ncp->nc_nxt = nchhead; ncp->nc_prev = &nchhead; nchhead->nc_prev = &ncp->nc_nxt; nchhead = ncp; - - /* and make a dummy hash chain */ + /* and make a dummy hash chain */ ncp->nc_forw = ncp; ncp->nc_back = ncp; - ncp = NULL; } } @@ -430,7 +422,6 @@ searchloop: goto bad; entryoffsetinblock = 0; } - /* * If still looking for a slot, and at a DIRBLKSIZE * boundary, have to start looking for free space again. @@ -440,7 +431,6 @@ searchloop: slotoffset = -1; slotfreespace = 0; } - /* * Get pointer to next entry. * Full validation checks are slow, so we only check @@ -449,7 +439,7 @@ searchloop: * "dirchk" to be true. */ ep = (struct direct *)(bp->b_un.b_addr + entryoffsetinblock); - if (ep->d_reclen <= 0 || + if (ep->d_reclen == 0 || dirchk && dirbadentry(ep, entryoffsetinblock)) { dirbad(dp, ndp->ni_offset, "mangled entry"); i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)); @@ -493,7 +483,7 @@ searchloop: if (ep->d_ino) { if (ep->d_namlen == ndp->ni_dent.d_namlen && !bcmp(ndp->ni_dent.d_name, ep->d_name, - ep->d_namlen)) + (unsigned)ep->d_namlen)) goto found; } prevoff = ndp->ni_offset; @@ -738,44 +728,38 @@ found: } /* - * insert name into cache if appropriate + * Insert name into cache if appropriate. */ if (makeentry) { if (ncp != NULL) panic("nami: duplicating cache"); - - /* - * free the cache slot at head of lru chain - */ + /* + * Free the cache slot at head of lru chain. + */ if (ncp = nchhead) { - /* remove from lru chain */ + /* remove from lru chain */ *ncp->nc_prev = ncp->nc_nxt; if (ncp->nc_nxt) ncp->nc_nxt->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; - - /* remove from old hash chain */ - remque(ncp); - - /* grab the inode we just found */ + remque(ncp); /* remove from old hash chain */ + /* grab the inode we just found */ ncp->nc_ip = dp; - - /* fill in cache info */ + /* fill in cache info */ ncp->nc_ino = pdp->i_number; /* parents inum */ ncp->nc_dev = pdp->i_dev; /* & device */ ncp->nc_idev = dp->i_dev; /* our device */ ncp->nc_id = dp->i_id; /* identifier */ ncp->nc_nlen = ndp->ni_dent.d_namlen; - bcopy(ndp->ni_dent.d_name, ncp->nc_name, ncp->nc_nlen); - - /* link at end of lru chain */ + bcopy(ndp->ni_dent.d_name, ncp->nc_name, + (unsigned)ncp->nc_nlen); + /* link at end of lru chain */ ncp->nc_nxt = NULL; ncp->nc_prev = nchtail; *nchtail = ncp; nchtail = &ncp->nc_nxt; - - /* and insert on hash chain */ + /* and insert on hash chain */ insque(ncp, nhp); } } @@ -865,7 +849,6 @@ dirbad(ip, offset, how) /* * Do consistency checking on a directory entry: * record length must be multiple of 4 - * record length must not be non-negative * entry must fit in rest of its DIRBLKSIZ block * record must be large enough to contain entry * name is not longer than MAXNAMLEN @@ -877,7 +860,7 @@ dirbadentry(ep, entryoffsetinblock) { register int i; - if ((ep->d_reclen & 0x3) != 0 || ep->d_reclen <= 0 || + if ((ep->d_reclen & 0x3) != 0 || ep->d_reclen > DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)) || ep->d_reclen < DIRSIZ(ep) || ep->d_namlen > MAXNAMLEN) return (1); @@ -947,7 +930,6 @@ direnter(ip, ndp) */ if (ndp->ni_offset + ndp->ni_count > dp->i_size) dp->i_size = ndp->ni_offset + ndp->ni_count; - /* * Get the block containing the space for the new directory * entry. Should return error by result instead of u.u_error. @@ -957,7 +939,6 @@ direnter(ip, ndp) iput(dp); return (u.u_error); } - /* * Find space for the new entry. In the simple case, the * entry at offset base will have the space. If it does @@ -1001,7 +982,7 @@ direnter(ip, ndp) bwrite(bp); dp->i_flag |= IUPD|ICHG; if (ndp->ni_endoff && ndp->ni_endoff < dp->i_size) - itrunc(dp, ndp->ni_endoff); + itrunc(dp, (u_long)ndp->ni_endoff); iput(dp); return (error); } @@ -1127,7 +1108,7 @@ dirempty(ip, parentino) if (error || count != 0) return (0); /* avoid infinite loops */ - if (dp->d_reclen <= 0) + if (dp->d_reclen == 0) return (0); /* skip empty entries */ if (dp->d_ino == 0) @@ -1218,19 +1199,15 @@ nchinit() nchhead = 0; nchtail = &nchhead; - for (ncp = nch; ncp < &nch[nchsize]; ncp++) { ncp->nc_forw = ncp; /* hash chain */ ncp->nc_back = ncp; - ncp->nc_nxt = NULL; /* lru chain */ *nchtail = ncp; ncp->nc_prev = nchtail; nchtail = &ncp->nc_nxt; - /* all else is zero already */ } - for (nchp = nchash; nchp < &nchash[NCHHASH]; nchp++) { nchp->nch_head[0] = nchp; nchp->nch_head[1] = nchp; @@ -1252,35 +1229,27 @@ nchinval(dev) for (ncp = nchhead; ncp; ncp = nxtcp) { nxtcp = ncp->nc_nxt; - if (ncp->nc_ip == NULL || (ncp->nc_idev != dev && ncp->nc_dev != dev)) continue; - - /* free the resources we had */ + /* free the resources we had */ ncp->nc_idev = NODEV; ncp->nc_dev = NODEV; ncp->nc_id = NULL; ncp->nc_ino = 0; ncp->nc_ip = NULL; - - - /* remove the entry from its hash chain */ - remque(ncp); - /* and make a dummy one */ - ncp->nc_forw = ncp; + remque(ncp); /* remove entry from its hash chain */ + ncp->nc_forw = ncp; /* and make a dummy one */ ncp->nc_back = ncp; - - /* delete this entry from LRU chain */ + /* delete this entry from LRU chain */ *ncp->nc_prev = nxtcp; if (nxtcp) nxtcp->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; - - /* cause rescan of list, it may have altered */ + /* cause rescan of list, it may have altered */ nxtcp = nchhead; - /* put the now-free entry at head of LRU */ + /* put the now-free entry at head of LRU */ ncp->nc_nxt = nxtcp; ncp->nc_prev = &nchhead; nxtcp->nc_prev = &ncp->nc_nxt; @@ -1295,7 +1264,6 @@ cacheinvalall() { register struct nch *ncp; - for (ncp = nch; ncp < &nch[nchsize]; ncp++) { + for (ncp = nch; ncp < &nch[nchsize]; ncp++) ncp->nc_id = 0; - } } diff --git a/usr/src/sys/ufs/ffs/ffs_inode.c b/usr/src/sys/ufs/ffs/ffs_inode.c index b86a499b87..34559b513b 100644 --- a/usr/src/sys/ufs/ffs/ffs_inode.c +++ b/usr/src/sys/ufs/ffs/ffs_inode.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)ffs_inode.c 6.17 (Berkeley) %G% + * @(#)ffs_inode.c 6.18 (Berkeley) %G% */ #include "param.h" @@ -114,7 +114,6 @@ iget(dev, fs, ino) register struct dinode *dp; register struct inode *iq; - loop: ih = &ihead[INOHASH(dev, ino)]; for (ip = ih->ih_chain[0]; ip != (struct inode *)ih; ip = ip->i_forw) @@ -379,11 +378,11 @@ itrunc(oip, length) u_long length; { register daddr_t lastblock; - daddr_t bn, lastiblock[NIADDR]; + daddr_t bn, lbn, lastiblock[NIADDR]; register struct fs *fs; register struct inode *ip; struct buf *bp; - int offset, lbn, osize, size, count, level, s; + int offset, osize, size, count, level, s; long nblocks, blocksreleased = 0; register int i; dev_t dev; @@ -440,7 +439,7 @@ itrunc(oip, length) brelse(bp); return; } - bzero(bp->b_un.b_addr + offset, size - offset); + bzero(bp->b_un.b_addr + offset, (unsigned)(size - offset)); bdwrite(bp); } /* diff --git a/usr/src/sys/ufs/ffs/ffs_subr.c b/usr/src/sys/ufs/ffs/ffs_subr.c index 86d01736d3..472d685229 100644 --- a/usr/src/sys/ufs/ffs/ffs_subr.c +++ b/usr/src/sys/ufs/ffs/ffs_subr.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)ffs_subr.c 6.8 (Berkeley) %G% + * @(#)ffs_subr.c 6.9 (Berkeley) %G% */ #ifdef KERNEL @@ -109,7 +109,8 @@ syncip(ip) register struct fs *fs; register struct buf *bp; struct buf *lastbufp; - long lbn, lastlbn, s; + long lbn, lastlbn; + int s; daddr_t blkno; fs = ip->i_fs; @@ -125,7 +126,7 @@ syncip(ip) if (bp->b_dev != ip->i_dev || (bp->b_flags & B_DELWRI) == 0) continue; - s = spl6(); + s = splbio(); if (bp->b_flags & B_BUSY) { bp->b_flags |= B_WANTED; sleep((caddr_t)bp, PRIBIO+1); @@ -357,7 +358,7 @@ bufstats() count = 0; for (j = 0; j <= MAXBSIZE/CLBYTES; j++) counts[j] = 0; - s = spl6(); + s = splbio(); for (dp = bp->av_forw; dp != bp; dp = dp->av_forw) { counts[dp->b_bufsize/CLBYTES]++; count++; diff --git a/usr/src/sys/ufs/ffs/ufs_inode.c b/usr/src/sys/ufs/ffs/ufs_inode.c index 04a594e5df..a8362ddb62 100644 --- a/usr/src/sys/ufs/ffs/ufs_inode.c +++ b/usr/src/sys/ufs/ffs/ufs_inode.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)ufs_inode.c 6.17 (Berkeley) %G% + * @(#)ufs_inode.c 6.18 (Berkeley) %G% */ #include "param.h" @@ -114,7 +114,6 @@ iget(dev, fs, ino) register struct dinode *dp; register struct inode *iq; - loop: ih = &ihead[INOHASH(dev, ino)]; for (ip = ih->ih_chain[0]; ip != (struct inode *)ih; ip = ip->i_forw) @@ -379,11 +378,11 @@ itrunc(oip, length) u_long length; { register daddr_t lastblock; - daddr_t bn, lastiblock[NIADDR]; + daddr_t bn, lbn, lastiblock[NIADDR]; register struct fs *fs; register struct inode *ip; struct buf *bp; - int offset, lbn, osize, size, count, level, s; + int offset, osize, size, count, level, s; long nblocks, blocksreleased = 0; register int i; dev_t dev; @@ -440,7 +439,7 @@ itrunc(oip, length) brelse(bp); return; } - bzero(bp->b_un.b_addr + offset, size - offset); + bzero(bp->b_un.b_addr + offset, (unsigned)(size - offset)); bdwrite(bp); } /* diff --git a/usr/src/sys/ufs/ffs/ufs_lookup.c b/usr/src/sys/ufs/ffs/ufs_lookup.c index dabbe74ba0..e5b60105dc 100644 --- a/usr/src/sys/ufs/ffs/ufs_lookup.c +++ b/usr/src/sys/ufs/ffs/ufs_lookup.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)ufs_lookup.c 6.25 (Berkeley) %G% + * @(#)ufs_lookup.c 6.26 (Berkeley) %G% */ #include "param.h" @@ -33,14 +33,14 @@ int dirchk = 0; #define NHASH(h, i, d) ((unsigned)((h) + (i) + 13 * (int)(d)) & ((NCHHASH)-1)) #endif -union nchash { - union nchash *nch_head[2]; - struct nch *nch_chain[2]; +union nchash { + union nchash *nch_head[2]; + struct nch *nch_chain[2]; } nchash[NCHHASH]; #define nch_forw nch_chain[0] #define nch_back nch_chain[1] -struct nch *nchhead, **nchtail; /* LRU chain pointers */ +struct nch *nchhead, **nchtail; /* LRU chain pointers */ struct nchstats nchstats; /* cache effectiveness statistics */ /* @@ -66,25 +66,25 @@ struct nchstats nchstats; /* cache effectiveness statistics */ * * Name caching works as follows: * - * names found by directory scans are retained in a cache - * for future reference. It is managed LRU, so frequently - * used names will hang around. Cache is indexed by hash value - * obtained from (ino,dev,name) where ino & dev refer to the - * directory containing name. + * Names found by directory scans are retained in a cache + * for future reference. It is managed LRU, so frequently + * used names will hang around. Cache is indexed by hash value + * obtained from (ino,dev,name) where ino & dev refer to the + * directory containing name. * - * For simplicity (and economy of storage), names longer than - * some (small) maximum length are not cached, they occur - * infrequently in any case, and are almost never of interest. + * For simplicity (and economy of storage), names longer than + * some (small) maximum length are not cached, they occur + * infrequently in any case, and are almost never of interest. * - * Upon reaching the last segment of a path, if the reference - * is for DELETE, or NOCACHE is set (rewrite), and the - * name is located in the cache, it will be dropped. + * Upon reaching the last segment of a path, if the reference + * is for DELETE, or NOCACHE is set (rewrite), and the + * name is located in the cache, it will be dropped. * - * We must be sure never to enter the name ".." into the cache - * because of the extremely kludgey way that rename() alters - * ".." in a situation like - * mv a/x b/x - * where x is a directory, and x/.. is the ".." in question. + * We must be sure never to enter the name ".." into the cache + * because of the extremely kludgey way that rename() alters + * ".." in a situation like + * mv a/x b/x + * where x is a directory, and x/.. is the ".." in question. * * Overall outline of namei: * @@ -270,10 +270,9 @@ dirloop2: ncp->nc_dev == dp->i_dev && ncp->nc_nlen == ndp->ni_dent.d_namlen && !bcmp(ncp->nc_name, ndp->ni_dent.d_name, - ncp->nc_nlen)) + (unsigned)ncp->nc_nlen)) break; } - if (ncp == (struct nch *)nhp) { nchstats.ncs_miss++; ncp = NULL; @@ -283,17 +282,16 @@ dirloop2: } else if (!makeentry) { nchstats.ncs_badhits++; } else { - - /* - * move this slot to end of LRU - * chain, if not already there - */ + /* + * move this slot to end of LRU + * chain, if not already there + */ if (ncp->nc_nxt) { - /* remove from LRU chain */ + /* remove from LRU chain */ *ncp->nc_prev = ncp->nc_nxt; ncp->nc_nxt->nc_prev = ncp->nc_prev; - /* and replace at end of it */ + /* and replace at end of it */ ncp->nc_nxt = NULL; ncp->nc_prev = nchtail; *nchtail = ncp; @@ -343,27 +341,21 @@ dirloop2: * the cache entry is invalid, or otherwise don't * want cache entry to exist. */ - - /* remove from LRU chain */ + /* remove from LRU chain */ *ncp->nc_prev = ncp->nc_nxt; if (ncp->nc_nxt) ncp->nc_nxt->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; - - /* remove from hash chain */ - remque(ncp); - - /* insert at head of LRU list (first to grab) */ + remque(ncp); /* remove from hash chain */ + /* insert at head of LRU list (first to grab) */ ncp->nc_nxt = nchhead; ncp->nc_prev = &nchhead; nchhead->nc_prev = &ncp->nc_nxt; nchhead = ncp; - - /* and make a dummy hash chain */ + /* and make a dummy hash chain */ ncp->nc_forw = ncp; ncp->nc_back = ncp; - ncp = NULL; } } @@ -430,7 +422,6 @@ searchloop: goto bad; entryoffsetinblock = 0; } - /* * If still looking for a slot, and at a DIRBLKSIZE * boundary, have to start looking for free space again. @@ -440,7 +431,6 @@ searchloop: slotoffset = -1; slotfreespace = 0; } - /* * Get pointer to next entry. * Full validation checks are slow, so we only check @@ -449,7 +439,7 @@ searchloop: * "dirchk" to be true. */ ep = (struct direct *)(bp->b_un.b_addr + entryoffsetinblock); - if (ep->d_reclen <= 0 || + if (ep->d_reclen == 0 || dirchk && dirbadentry(ep, entryoffsetinblock)) { dirbad(dp, ndp->ni_offset, "mangled entry"); i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)); @@ -493,7 +483,7 @@ searchloop: if (ep->d_ino) { if (ep->d_namlen == ndp->ni_dent.d_namlen && !bcmp(ndp->ni_dent.d_name, ep->d_name, - ep->d_namlen)) + (unsigned)ep->d_namlen)) goto found; } prevoff = ndp->ni_offset; @@ -738,44 +728,38 @@ found: } /* - * insert name into cache if appropriate + * Insert name into cache if appropriate. */ if (makeentry) { if (ncp != NULL) panic("nami: duplicating cache"); - - /* - * free the cache slot at head of lru chain - */ + /* + * Free the cache slot at head of lru chain. + */ if (ncp = nchhead) { - /* remove from lru chain */ + /* remove from lru chain */ *ncp->nc_prev = ncp->nc_nxt; if (ncp->nc_nxt) ncp->nc_nxt->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; - - /* remove from old hash chain */ - remque(ncp); - - /* grab the inode we just found */ + remque(ncp); /* remove from old hash chain */ + /* grab the inode we just found */ ncp->nc_ip = dp; - - /* fill in cache info */ + /* fill in cache info */ ncp->nc_ino = pdp->i_number; /* parents inum */ ncp->nc_dev = pdp->i_dev; /* & device */ ncp->nc_idev = dp->i_dev; /* our device */ ncp->nc_id = dp->i_id; /* identifier */ ncp->nc_nlen = ndp->ni_dent.d_namlen; - bcopy(ndp->ni_dent.d_name, ncp->nc_name, ncp->nc_nlen); - - /* link at end of lru chain */ + bcopy(ndp->ni_dent.d_name, ncp->nc_name, + (unsigned)ncp->nc_nlen); + /* link at end of lru chain */ ncp->nc_nxt = NULL; ncp->nc_prev = nchtail; *nchtail = ncp; nchtail = &ncp->nc_nxt; - - /* and insert on hash chain */ + /* and insert on hash chain */ insque(ncp, nhp); } } @@ -865,7 +849,6 @@ dirbad(ip, offset, how) /* * Do consistency checking on a directory entry: * record length must be multiple of 4 - * record length must not be non-negative * entry must fit in rest of its DIRBLKSIZ block * record must be large enough to contain entry * name is not longer than MAXNAMLEN @@ -877,7 +860,7 @@ dirbadentry(ep, entryoffsetinblock) { register int i; - if ((ep->d_reclen & 0x3) != 0 || ep->d_reclen <= 0 || + if ((ep->d_reclen & 0x3) != 0 || ep->d_reclen > DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)) || ep->d_reclen < DIRSIZ(ep) || ep->d_namlen > MAXNAMLEN) return (1); @@ -947,7 +930,6 @@ direnter(ip, ndp) */ if (ndp->ni_offset + ndp->ni_count > dp->i_size) dp->i_size = ndp->ni_offset + ndp->ni_count; - /* * Get the block containing the space for the new directory * entry. Should return error by result instead of u.u_error. @@ -957,7 +939,6 @@ direnter(ip, ndp) iput(dp); return (u.u_error); } - /* * Find space for the new entry. In the simple case, the * entry at offset base will have the space. If it does @@ -1001,7 +982,7 @@ direnter(ip, ndp) bwrite(bp); dp->i_flag |= IUPD|ICHG; if (ndp->ni_endoff && ndp->ni_endoff < dp->i_size) - itrunc(dp, ndp->ni_endoff); + itrunc(dp, (u_long)ndp->ni_endoff); iput(dp); return (error); } @@ -1127,7 +1108,7 @@ dirempty(ip, parentino) if (error || count != 0) return (0); /* avoid infinite loops */ - if (dp->d_reclen <= 0) + if (dp->d_reclen == 0) return (0); /* skip empty entries */ if (dp->d_ino == 0) @@ -1218,19 +1199,15 @@ nchinit() nchhead = 0; nchtail = &nchhead; - for (ncp = nch; ncp < &nch[nchsize]; ncp++) { ncp->nc_forw = ncp; /* hash chain */ ncp->nc_back = ncp; - ncp->nc_nxt = NULL; /* lru chain */ *nchtail = ncp; ncp->nc_prev = nchtail; nchtail = &ncp->nc_nxt; - /* all else is zero already */ } - for (nchp = nchash; nchp < &nchash[NCHHASH]; nchp++) { nchp->nch_head[0] = nchp; nchp->nch_head[1] = nchp; @@ -1252,35 +1229,27 @@ nchinval(dev) for (ncp = nchhead; ncp; ncp = nxtcp) { nxtcp = ncp->nc_nxt; - if (ncp->nc_ip == NULL || (ncp->nc_idev != dev && ncp->nc_dev != dev)) continue; - - /* free the resources we had */ + /* free the resources we had */ ncp->nc_idev = NODEV; ncp->nc_dev = NODEV; ncp->nc_id = NULL; ncp->nc_ino = 0; ncp->nc_ip = NULL; - - - /* remove the entry from its hash chain */ - remque(ncp); - /* and make a dummy one */ - ncp->nc_forw = ncp; + remque(ncp); /* remove entry from its hash chain */ + ncp->nc_forw = ncp; /* and make a dummy one */ ncp->nc_back = ncp; - - /* delete this entry from LRU chain */ + /* delete this entry from LRU chain */ *ncp->nc_prev = nxtcp; if (nxtcp) nxtcp->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; - - /* cause rescan of list, it may have altered */ + /* cause rescan of list, it may have altered */ nxtcp = nchhead; - /* put the now-free entry at head of LRU */ + /* put the now-free entry at head of LRU */ ncp->nc_nxt = nxtcp; ncp->nc_prev = &nchhead; nxtcp->nc_prev = &ncp->nc_nxt; @@ -1295,7 +1264,6 @@ cacheinvalall() { register struct nch *ncp; - for (ncp = nch; ncp < &nch[nchsize]; ncp++) { + for (ncp = nch; ncp < &nch[nchsize]; ncp++) ncp->nc_id = 0; - } } diff --git a/usr/src/sys/ufs/lfs/lfs_inode.c b/usr/src/sys/ufs/lfs/lfs_inode.c index 22cff69298..eff33ba32b 100644 --- a/usr/src/sys/ufs/lfs/lfs_inode.c +++ b/usr/src/sys/ufs/lfs/lfs_inode.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)lfs_inode.c 6.17 (Berkeley) %G% + * @(#)lfs_inode.c 6.18 (Berkeley) %G% */ #include "param.h" @@ -114,7 +114,6 @@ iget(dev, fs, ino) register struct dinode *dp; register struct inode *iq; - loop: ih = &ihead[INOHASH(dev, ino)]; for (ip = ih->ih_chain[0]; ip != (struct inode *)ih; ip = ip->i_forw) @@ -379,11 +378,11 @@ itrunc(oip, length) u_long length; { register daddr_t lastblock; - daddr_t bn, lastiblock[NIADDR]; + daddr_t bn, lbn, lastiblock[NIADDR]; register struct fs *fs; register struct inode *ip; struct buf *bp; - int offset, lbn, osize, size, count, level, s; + int offset, osize, size, count, level, s; long nblocks, blocksreleased = 0; register int i; dev_t dev; @@ -440,7 +439,7 @@ itrunc(oip, length) brelse(bp); return; } - bzero(bp->b_un.b_addr + offset, size - offset); + bzero(bp->b_un.b_addr + offset, (unsigned)(size - offset)); bdwrite(bp); } /* diff --git a/usr/src/sys/ufs/ufs/ufs_inode.c b/usr/src/sys/ufs/ufs/ufs_inode.c index 04a594e5df..a8362ddb62 100644 --- a/usr/src/sys/ufs/ufs/ufs_inode.c +++ b/usr/src/sys/ufs/ufs/ufs_inode.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)ufs_inode.c 6.17 (Berkeley) %G% + * @(#)ufs_inode.c 6.18 (Berkeley) %G% */ #include "param.h" @@ -114,7 +114,6 @@ iget(dev, fs, ino) register struct dinode *dp; register struct inode *iq; - loop: ih = &ihead[INOHASH(dev, ino)]; for (ip = ih->ih_chain[0]; ip != (struct inode *)ih; ip = ip->i_forw) @@ -379,11 +378,11 @@ itrunc(oip, length) u_long length; { register daddr_t lastblock; - daddr_t bn, lastiblock[NIADDR]; + daddr_t bn, lbn, lastiblock[NIADDR]; register struct fs *fs; register struct inode *ip; struct buf *bp; - int offset, lbn, osize, size, count, level, s; + int offset, osize, size, count, level, s; long nblocks, blocksreleased = 0; register int i; dev_t dev; @@ -440,7 +439,7 @@ itrunc(oip, length) brelse(bp); return; } - bzero(bp->b_un.b_addr + offset, size - offset); + bzero(bp->b_un.b_addr + offset, (unsigned)(size - offset)); bdwrite(bp); } /* diff --git a/usr/src/sys/ufs/ufs/ufs_lookup.c b/usr/src/sys/ufs/ufs/ufs_lookup.c index dabbe74ba0..e5b60105dc 100644 --- a/usr/src/sys/ufs/ufs/ufs_lookup.c +++ b/usr/src/sys/ufs/ufs/ufs_lookup.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)ufs_lookup.c 6.25 (Berkeley) %G% + * @(#)ufs_lookup.c 6.26 (Berkeley) %G% */ #include "param.h" @@ -33,14 +33,14 @@ int dirchk = 0; #define NHASH(h, i, d) ((unsigned)((h) + (i) + 13 * (int)(d)) & ((NCHHASH)-1)) #endif -union nchash { - union nchash *nch_head[2]; - struct nch *nch_chain[2]; +union nchash { + union nchash *nch_head[2]; + struct nch *nch_chain[2]; } nchash[NCHHASH]; #define nch_forw nch_chain[0] #define nch_back nch_chain[1] -struct nch *nchhead, **nchtail; /* LRU chain pointers */ +struct nch *nchhead, **nchtail; /* LRU chain pointers */ struct nchstats nchstats; /* cache effectiveness statistics */ /* @@ -66,25 +66,25 @@ struct nchstats nchstats; /* cache effectiveness statistics */ * * Name caching works as follows: * - * names found by directory scans are retained in a cache - * for future reference. It is managed LRU, so frequently - * used names will hang around. Cache is indexed by hash value - * obtained from (ino,dev,name) where ino & dev refer to the - * directory containing name. + * Names found by directory scans are retained in a cache + * for future reference. It is managed LRU, so frequently + * used names will hang around. Cache is indexed by hash value + * obtained from (ino,dev,name) where ino & dev refer to the + * directory containing name. * - * For simplicity (and economy of storage), names longer than - * some (small) maximum length are not cached, they occur - * infrequently in any case, and are almost never of interest. + * For simplicity (and economy of storage), names longer than + * some (small) maximum length are not cached, they occur + * infrequently in any case, and are almost never of interest. * - * Upon reaching the last segment of a path, if the reference - * is for DELETE, or NOCACHE is set (rewrite), and the - * name is located in the cache, it will be dropped. + * Upon reaching the last segment of a path, if the reference + * is for DELETE, or NOCACHE is set (rewrite), and the + * name is located in the cache, it will be dropped. * - * We must be sure never to enter the name ".." into the cache - * because of the extremely kludgey way that rename() alters - * ".." in a situation like - * mv a/x b/x - * where x is a directory, and x/.. is the ".." in question. + * We must be sure never to enter the name ".." into the cache + * because of the extremely kludgey way that rename() alters + * ".." in a situation like + * mv a/x b/x + * where x is a directory, and x/.. is the ".." in question. * * Overall outline of namei: * @@ -270,10 +270,9 @@ dirloop2: ncp->nc_dev == dp->i_dev && ncp->nc_nlen == ndp->ni_dent.d_namlen && !bcmp(ncp->nc_name, ndp->ni_dent.d_name, - ncp->nc_nlen)) + (unsigned)ncp->nc_nlen)) break; } - if (ncp == (struct nch *)nhp) { nchstats.ncs_miss++; ncp = NULL; @@ -283,17 +282,16 @@ dirloop2: } else if (!makeentry) { nchstats.ncs_badhits++; } else { - - /* - * move this slot to end of LRU - * chain, if not already there - */ + /* + * move this slot to end of LRU + * chain, if not already there + */ if (ncp->nc_nxt) { - /* remove from LRU chain */ + /* remove from LRU chain */ *ncp->nc_prev = ncp->nc_nxt; ncp->nc_nxt->nc_prev = ncp->nc_prev; - /* and replace at end of it */ + /* and replace at end of it */ ncp->nc_nxt = NULL; ncp->nc_prev = nchtail; *nchtail = ncp; @@ -343,27 +341,21 @@ dirloop2: * the cache entry is invalid, or otherwise don't * want cache entry to exist. */ - - /* remove from LRU chain */ + /* remove from LRU chain */ *ncp->nc_prev = ncp->nc_nxt; if (ncp->nc_nxt) ncp->nc_nxt->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; - - /* remove from hash chain */ - remque(ncp); - - /* insert at head of LRU list (first to grab) */ + remque(ncp); /* remove from hash chain */ + /* insert at head of LRU list (first to grab) */ ncp->nc_nxt = nchhead; ncp->nc_prev = &nchhead; nchhead->nc_prev = &ncp->nc_nxt; nchhead = ncp; - - /* and make a dummy hash chain */ + /* and make a dummy hash chain */ ncp->nc_forw = ncp; ncp->nc_back = ncp; - ncp = NULL; } } @@ -430,7 +422,6 @@ searchloop: goto bad; entryoffsetinblock = 0; } - /* * If still looking for a slot, and at a DIRBLKSIZE * boundary, have to start looking for free space again. @@ -440,7 +431,6 @@ searchloop: slotoffset = -1; slotfreespace = 0; } - /* * Get pointer to next entry. * Full validation checks are slow, so we only check @@ -449,7 +439,7 @@ searchloop: * "dirchk" to be true. */ ep = (struct direct *)(bp->b_un.b_addr + entryoffsetinblock); - if (ep->d_reclen <= 0 || + if (ep->d_reclen == 0 || dirchk && dirbadentry(ep, entryoffsetinblock)) { dirbad(dp, ndp->ni_offset, "mangled entry"); i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)); @@ -493,7 +483,7 @@ searchloop: if (ep->d_ino) { if (ep->d_namlen == ndp->ni_dent.d_namlen && !bcmp(ndp->ni_dent.d_name, ep->d_name, - ep->d_namlen)) + (unsigned)ep->d_namlen)) goto found; } prevoff = ndp->ni_offset; @@ -738,44 +728,38 @@ found: } /* - * insert name into cache if appropriate + * Insert name into cache if appropriate. */ if (makeentry) { if (ncp != NULL) panic("nami: duplicating cache"); - - /* - * free the cache slot at head of lru chain - */ + /* + * Free the cache slot at head of lru chain. + */ if (ncp = nchhead) { - /* remove from lru chain */ + /* remove from lru chain */ *ncp->nc_prev = ncp->nc_nxt; if (ncp->nc_nxt) ncp->nc_nxt->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; - - /* remove from old hash chain */ - remque(ncp); - - /* grab the inode we just found */ + remque(ncp); /* remove from old hash chain */ + /* grab the inode we just found */ ncp->nc_ip = dp; - - /* fill in cache info */ + /* fill in cache info */ ncp->nc_ino = pdp->i_number; /* parents inum */ ncp->nc_dev = pdp->i_dev; /* & device */ ncp->nc_idev = dp->i_dev; /* our device */ ncp->nc_id = dp->i_id; /* identifier */ ncp->nc_nlen = ndp->ni_dent.d_namlen; - bcopy(ndp->ni_dent.d_name, ncp->nc_name, ncp->nc_nlen); - - /* link at end of lru chain */ + bcopy(ndp->ni_dent.d_name, ncp->nc_name, + (unsigned)ncp->nc_nlen); + /* link at end of lru chain */ ncp->nc_nxt = NULL; ncp->nc_prev = nchtail; *nchtail = ncp; nchtail = &ncp->nc_nxt; - - /* and insert on hash chain */ + /* and insert on hash chain */ insque(ncp, nhp); } } @@ -865,7 +849,6 @@ dirbad(ip, offset, how) /* * Do consistency checking on a directory entry: * record length must be multiple of 4 - * record length must not be non-negative * entry must fit in rest of its DIRBLKSIZ block * record must be large enough to contain entry * name is not longer than MAXNAMLEN @@ -877,7 +860,7 @@ dirbadentry(ep, entryoffsetinblock) { register int i; - if ((ep->d_reclen & 0x3) != 0 || ep->d_reclen <= 0 || + if ((ep->d_reclen & 0x3) != 0 || ep->d_reclen > DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)) || ep->d_reclen < DIRSIZ(ep) || ep->d_namlen > MAXNAMLEN) return (1); @@ -947,7 +930,6 @@ direnter(ip, ndp) */ if (ndp->ni_offset + ndp->ni_count > dp->i_size) dp->i_size = ndp->ni_offset + ndp->ni_count; - /* * Get the block containing the space for the new directory * entry. Should return error by result instead of u.u_error. @@ -957,7 +939,6 @@ direnter(ip, ndp) iput(dp); return (u.u_error); } - /* * Find space for the new entry. In the simple case, the * entry at offset base will have the space. If it does @@ -1001,7 +982,7 @@ direnter(ip, ndp) bwrite(bp); dp->i_flag |= IUPD|ICHG; if (ndp->ni_endoff && ndp->ni_endoff < dp->i_size) - itrunc(dp, ndp->ni_endoff); + itrunc(dp, (u_long)ndp->ni_endoff); iput(dp); return (error); } @@ -1127,7 +1108,7 @@ dirempty(ip, parentino) if (error || count != 0) return (0); /* avoid infinite loops */ - if (dp->d_reclen <= 0) + if (dp->d_reclen == 0) return (0); /* skip empty entries */ if (dp->d_ino == 0) @@ -1218,19 +1199,15 @@ nchinit() nchhead = 0; nchtail = &nchhead; - for (ncp = nch; ncp < &nch[nchsize]; ncp++) { ncp->nc_forw = ncp; /* hash chain */ ncp->nc_back = ncp; - ncp->nc_nxt = NULL; /* lru chain */ *nchtail = ncp; ncp->nc_prev = nchtail; nchtail = &ncp->nc_nxt; - /* all else is zero already */ } - for (nchp = nchash; nchp < &nchash[NCHHASH]; nchp++) { nchp->nch_head[0] = nchp; nchp->nch_head[1] = nchp; @@ -1252,35 +1229,27 @@ nchinval(dev) for (ncp = nchhead; ncp; ncp = nxtcp) { nxtcp = ncp->nc_nxt; - if (ncp->nc_ip == NULL || (ncp->nc_idev != dev && ncp->nc_dev != dev)) continue; - - /* free the resources we had */ + /* free the resources we had */ ncp->nc_idev = NODEV; ncp->nc_dev = NODEV; ncp->nc_id = NULL; ncp->nc_ino = 0; ncp->nc_ip = NULL; - - - /* remove the entry from its hash chain */ - remque(ncp); - /* and make a dummy one */ - ncp->nc_forw = ncp; + remque(ncp); /* remove entry from its hash chain */ + ncp->nc_forw = ncp; /* and make a dummy one */ ncp->nc_back = ncp; - - /* delete this entry from LRU chain */ + /* delete this entry from LRU chain */ *ncp->nc_prev = nxtcp; if (nxtcp) nxtcp->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; - - /* cause rescan of list, it may have altered */ + /* cause rescan of list, it may have altered */ nxtcp = nchhead; - /* put the now-free entry at head of LRU */ + /* put the now-free entry at head of LRU */ ncp->nc_nxt = nxtcp; ncp->nc_prev = &nchhead; nxtcp->nc_prev = &ncp->nc_nxt; @@ -1295,7 +1264,6 @@ cacheinvalall() { register struct nch *ncp; - for (ncp = nch; ncp < &nch[nchsize]; ncp++) { + for (ncp = nch; ncp < &nch[nchsize]; ncp++) ncp->nc_id = 0; - } } -- 2.20.1