diff options
author | ed <ed@FreeBSD.org> | 2012-01-01 20:47:33 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-01-01 20:47:33 +0000 |
commit | 2dd2060131bbfd7b617356a2384aa027270c3b9d (patch) | |
tree | 8961ac71ec869c6cb68bb78e29ccca26d39bef27 /sys/ufs | |
parent | 5f479a9ff5848e7febb91161677e846f8167d4ea (diff) | |
download | FreeBSD-src-2dd2060131bbfd7b617356a2384aa027270c3b9d.zip FreeBSD-src-2dd2060131bbfd7b617356a2384aa027270c3b9d.tar.gz |
Migrate ufs and ext2fs from skpc() to memcchr().
While there, remove a useless check from the code. memcchr() always
returns characters unequal to 0xff in this case, so inosused[i] ^ 0xff
can never be equal to zero. Also, the fact that memcchr() returns a
pointer instead of the number of bytes until the end, makes conversion
to an offset far more easy.
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 5f984b4..68ea172 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1745,9 +1745,9 @@ ffs_nodealloccg(ip, cg, ipref, mode, unused) struct cg *cgp; struct buf *bp, *ibp; struct ufsmount *ump; - u_int8_t *inosused; + u_int8_t *inosused, *loc; struct ufs2_dinode *dp2; - int error, start, len, loc, map, i; + int error, start, len, i; fs = ip->i_fs; ump = ip->i_ump; @@ -1777,25 +1777,19 @@ ffs_nodealloccg(ip, cg, ipref, mode, unused) } start = cgp->cg_irotor / NBBY; len = howmany(fs->fs_ipg - cgp->cg_irotor, NBBY); - loc = skpc(0xff, len, &inosused[start]); - if (loc == 0) { + loc = memcchr(&inosused[start], 0xff, len); + if (loc == NULL) { len = start + 1; start = 0; - loc = skpc(0xff, len, &inosused[0]); - if (loc == 0) { + loc = memcchr(&inosused[start], 0xff, len); + if (loc == NULL) { printf("cg = %d, irotor = %ld, fs = %s\n", cg, (long)cgp->cg_irotor, fs->fs_fsmnt); panic("ffs_nodealloccg: map corrupted"); /* NOTREACHED */ } } - i = start + len - loc; - map = inosused[i] ^ 0xff; - if (map == 0) { - printf("fs = %s\n", fs->fs_fsmnt); - panic("ffs_nodealloccg: block not in map"); - } - ipref = i * NBBY + ffs(map) - 1; + ipref = (loc - inosused) * NBBY + ffs(~*loc) - 1; cgp->cg_irotor = ipref; gotit: /* |