diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2010-08-12 04:05:04 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2010-08-12 04:05:04 +0000 |
commit | a9bd431f6a5f05e49d04975e60951c347a0875c8 (patch) | |
tree | e5a5580ffa84fb260f067bbc3ee128e40c5b7ab5 /sys | |
parent | 9628420868d694a31d68092cb5ef07b851f22f74 (diff) |
clean up some macro obfuscation and assorted styling problems.
fix a bonus off by one bug. ok matthew
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ntfs/ntfs.h | 7 | ||||
-rw-r--r-- | sys/ntfs/ntfs_ihash.c | 4 | ||||
-rw-r--r-- | sys/ntfs/ntfs_subr.c | 30 | ||||
-rw-r--r-- | sys/ntfs/ntfs_vfsops.c | 31 | ||||
-rw-r--r-- | sys/ntfs/ntfs_vnops.c | 12 |
5 files changed, 37 insertions, 47 deletions
diff --git a/sys/ntfs/ntfs.h b/sys/ntfs/ntfs.h index 6cff0d1ad6b..22901e51395 100644 --- a/sys/ntfs/ntfs.h +++ b/sys/ntfs/ntfs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs.h,v 1.8 2010/06/06 12:04:27 miod Exp $ */ +/* $OpenBSD: ntfs.h,v 1.9 2010/08/12 04:05:03 tedu Exp $ */ /* $NetBSD: ntfs.h,v 1.5 2003/04/24 07:50:19 christos Exp $ */ /*- @@ -283,11 +283,6 @@ struct ntfsmount { #define ntfs_bntob(bn) (int32_t)((bn) * (ntmp)->ntm_bps) typedef int (vop_t)(void *); -#define HASHINIT(a, b, c, d) hashinit((a), (b), (c), (d)) -#define bqrelse(bp) brelse(bp) -#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), (b), (c)) -#define VGET(a, b, c) vget((a), (b), (c)) -#define VN_LOCK(a, b, c) vn_lock((a), (b), (c)) #if defined(NTFS_DEBUG) extern int ntfs_debug; diff --git a/sys/ntfs/ntfs_ihash.c b/sys/ntfs/ntfs_ihash.c index de2f7575875..db7be3f0173 100644 --- a/sys/ntfs/ntfs_ihash.c +++ b/sys/ntfs/ntfs_ihash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_ihash.c,v 1.7 2010/04/23 19:32:57 oga Exp $ */ +/* $OpenBSD: ntfs_ihash.c,v 1.8 2010/08/12 04:05:03 tedu Exp $ */ /* $NetBSD: ntfs_ihash.c,v 1.1 2002/12/23 17:38:32 jdolecek Exp $ */ /* @@ -64,7 +64,7 @@ struct rwlock ntfs_hashlock = RWLOCK_INITIALIZER("ntfs_nthashlock"); void ntfs_nthashinit() { - ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK, + ntfs_nthashtbl = hashinit(desiredvnodes, M_NTFSNTHASH, M_WAITOK, &ntfs_nthash); } diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c index dd31056459d..01ff3f8ac5f 100644 --- a/sys/ntfs/ntfs_subr.c +++ b/sys/ntfs/ntfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_subr.c,v 1.19 2010/08/06 00:00:41 miod Exp $ */ +/* $OpenBSD: ntfs_subr.c,v 1.20 2010/08/12 04:05:03 tedu Exp $ */ /* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */ /*- @@ -204,7 +204,7 @@ ntfs_ntvattrget( } /* Scan $ATTRIBUTE_LIST for requested attribute */ len = lvap->va_datalen; - alpool = (caddr_t) malloc(len, M_TEMP, M_WAITOK); + alpool = malloc(len, M_TEMP, M_WAITOK); error = ntfs_readntvattr_plain(ntmp, ip, lvap, 0, len, alpool, &len, NULL); if (error) @@ -282,8 +282,7 @@ ntfs_loadntnode( dprintf(("ntfs_loadntnode: loading ino: %d\n",ip->i_number)); - mfrp = (struct filerec *) malloc(ntfs_bntob(ntmp->ntm_bpmftrec), - M_TEMP, M_WAITOK); + mfrp = malloc(ntfs_bntob(ntmp->ntm_bpmftrec), M_TEMP, M_WAITOK); if (ip->i_number < NTFS_SYSNODESNUM) { struct buf *bp; @@ -302,7 +301,7 @@ ntfs_loadntnode( goto out; } memcpy(mfrp, bp->b_data, ntfs_bntob(ntmp->ntm_bpmftrec)); - bqrelse(bp); + brelse(bp); } else { struct vnode *vp; @@ -584,8 +583,7 @@ ntfs_attrtontvattr( vap->va_allocated = rap->a_r.a_datalen; vap->va_vcnstart = 0; vap->va_vcnend = ntfs_btocn(vap->va_allocated); - vap->va_datap = (caddr_t) malloc(vap->va_datalen, - M_NTFSRDATA, M_WAITOK); + vap->va_datap = malloc(vap->va_datalen, M_NTFSRDATA, M_WAITOK); memcpy(vap->va_datap, (caddr_t) rap + rap->a_r.a_dataoff, rap->a_r.a_datalen); } @@ -626,8 +624,8 @@ ntfs_runtovrun( off += (run[off] & 0xF) + ((run[off] >> 4) & 0xF) + 1; cnt++; } - cn = (cn_t *) malloc(cnt * sizeof(cn_t), M_NTFSRUN, M_WAITOK); - cl = (cn_t *) malloc(cnt * sizeof(cn_t), M_NTFSRUN, M_WAITOK); + cn = malloc(cnt * sizeof(cn_t), M_NTFSRUN, M_WAITOK); + cl = malloc(cnt * sizeof(cn_t), M_NTFSRUN, M_WAITOK); off = 0; cnt = 0; @@ -831,7 +829,7 @@ ntfs_ntlookupattr( adp = ntmp->ntm_ad; for (i = 0; i < ntmp->ntm_adnum; i++, adp++){ if (syslen != adp->ad_namelen || - strncmp(sys, adp->ad_name, syslen) != 0) + strncmp(sys, adp->ad_name, syslen) != 0) continue; *attrtype = adp->ad_type; @@ -842,8 +840,8 @@ ntfs_ntlookupattr( out: if (namelen) { - *attrname = (char *) malloc(namelen, M_TEMP, M_WAITOK); - memcpy((*attrname), name, namelen); + *attrname = malloc(namelen + 1, M_TEMP, M_WAITOK); + memcpy(*attrname, name, namelen); (*attrname)[namelen] = '\0'; *attrtype = NTFS_A_DATA; } @@ -910,7 +908,7 @@ ntfs_ntlookupfile( blsize = vap->va_a_iroot->ir_size; dprintf(("ntfs_ntlookupfile: blksz: %d\n", blsize)); - rdbuf = (caddr_t) malloc(blsize, M_TEMP, M_WAITOK); + rdbuf = malloc(blsize, M_TEMP, M_WAITOK); loop: rdsize = vap->va_datalen; @@ -1188,8 +1186,8 @@ ntfs_ntreaddir( if (fp->f_dirblbuf == NULL) { fp->f_dirblsz = vap->va_a_iroot->ir_size; - fp->f_dirblbuf = (caddr_t) malloc( - MAX(vap->va_datalen,fp->f_dirblsz), M_NTFSDIR, M_WAITOK); + fp->f_dirblbuf = malloc(MAX(vap->va_datalen,fp->f_dirblsz), + M_NTFSDIR, M_WAITOK); } blsize = fp->f_dirblsz; @@ -1204,7 +1202,7 @@ ntfs_ntreaddir( error = ENOTDIR; goto fail; } - bmp = (u_int8_t *) malloc(bmvap->va_datalen, M_TEMP, M_WAITOK); + bmp = malloc(bmvap->va_datalen, M_TEMP, M_WAITOK); error = ntfs_readattr(ntmp, ip, NTFS_A_INDXBITMAP, "$I30", 0, bmvap->va_datalen, bmp, NULL); if (error) diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c index ee40a3db9f8..459d8d7a9fe 100644 --- a/sys/ntfs/ntfs_vfsops.c +++ b/sys/ntfs/ntfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_vfsops.c,v 1.18 2010/08/08 01:28:33 tedu Exp $ */ +/* $OpenBSD: ntfs_vfsops.c,v 1.19 2010/08/12 04:05:03 tedu Exp $ */ /* $NetBSD: ntfs_vfsops.c,v 1.7 2003/04/24 07:50:19 christos Exp $ */ /*- @@ -436,11 +436,10 @@ ntfs_mountfs(devvp, mp, argsp, p) goto out1; /* Count valid entries */ - for(num=0;;num++) { + for(num = 0; ; num++) { error = ntfs_readattr(ntmp, VTONT(vp), - NTFS_A_DATA, NULL, - num * sizeof(ad), sizeof(ad), - &ad, NULL); + NTFS_A_DATA, NULL, num * sizeof(ad), sizeof(ad), + &ad, NULL); if (error) goto out1; if (ad.ad_name[0] == 0) @@ -448,18 +447,16 @@ ntfs_mountfs(devvp, mp, argsp, p) } /* Alloc memory for attribute definitions */ - ntmp->ntm_ad = (struct ntvattrdef *) malloc( - num * sizeof(struct ntvattrdef), - M_NTFSMNT, M_WAITOK); + ntmp->ntm_ad = malloc(num * sizeof(struct ntvattrdef), + M_NTFSMNT, M_WAITOK); ntmp->ntm_adnum = num; /* Read them and translate */ - for(i=0;i<num;i++){ + for(i = 0; i < num; i++){ error = ntfs_readattr(ntmp, VTONT(vp), - NTFS_A_DATA, NULL, - i * sizeof(ad), sizeof(ad), - &ad, NULL); + NTFS_A_DATA, NULL, i * sizeof(ad), sizeof(ad), + &ad, NULL); if (error) goto out1; j = 0; @@ -501,9 +498,9 @@ out: } /* lock the device vnode before calling VOP_CLOSE() */ - VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); - VOP__UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, p); return (error); } @@ -634,7 +631,7 @@ ntfs_calccfree( bmsize = VTOF(vp)->f_size; - tmp = (u_int8_t *) malloc(bmsize, M_TEMP, M_WAITOK); + tmp = malloc(bmsize, M_TEMP, M_WAITOK); error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL, 0, bmsize, tmp, NULL); @@ -828,7 +825,7 @@ ntfs_vgetex( if (FTOV(fp)) { /* vget() returns error if the vnode has been recycled */ - if (VGET(FTOV(fp), lkflags, p) == 0) { + if (vget(FTOV(fp), lkflags, p) == 0) { *vpp = FTOV(fp); return (0); } @@ -851,7 +848,7 @@ ntfs_vgetex( vp->v_flag |= VROOT; if (lkflags & LK_TYPE_MASK) { - error = VN_LOCK(vp, lkflags, p); + error = vn_lock(vp, lkflags, p); if (error) { vput(vp); return (error); diff --git a/sys/ntfs/ntfs_vnops.c b/sys/ntfs/ntfs_vnops.c index bff182d7c34..660e1785436 100644 --- a/sys/ntfs/ntfs_vnops.c +++ b/sys/ntfs/ntfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_vnops.c,v 1.17 2010/04/20 22:05:44 tedu Exp $ */ +/* $OpenBSD: ntfs_vnops.c,v 1.18 2010/08/12 04:05:03 tedu Exp $ */ /* $NetBSD: ntfs_vnops.c,v 1.6 2003/04/10 21:57:26 jdolecek Exp $ */ /* @@ -192,7 +192,7 @@ ntfs_inactive(ap) vprint("ntfs_inactive: pushing active", vp); #endif - VOP__UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, p); /* XXX since we don't support any filesystem changes * right now, nothing more needs to be done @@ -658,7 +658,7 @@ ntfs_lookup(ap) dprintf(("ntfs_lookup: faking .. directory in %d\n", dip->i_number)); - VOP__UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, p); cnp->cn_flags |= PDIRUNLOCK; error = ntfs_ntvattrget(ntmp, dip, NTFS_A_NAME, NULL, 0, &vap); @@ -671,13 +671,13 @@ ntfs_lookup(ap) vap->va_a_name->n_pnumber,ap->a_vpp); ntfs_ntvattrrele(vap); if (error) { - if (VN_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p) == 0) + if (vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p) == 0) cnp->cn_flags &= ~PDIRUNLOCK; return (error); } if (lockparent && (cnp->cn_flags & ISLASTCN)) { - error = VN_LOCK(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, p); if (error) { vput( *(ap->a_vpp) ); return (error); @@ -695,7 +695,7 @@ ntfs_lookup(ap) VTONT(*ap->a_vpp)->i_number)); if(!lockparent || (cnp->cn_flags & ISLASTCN) == 0) { - VOP__UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, p); cnp->cn_flags |= PDIRUNLOCK; } } |