Remove some unnecessary (int32_t) casts that would cause us to screw up the

top bit in block addresses.

Also, change some daddr_t->int32_t casts (mostly as arguments to ufs_rw32(),
where they would get promoted anyway) to u_int32_t.
This commit is contained in:
mycroft 2004-12-15 07:11:51 +00:00
parent a00ad2295a
commit 5ac91d4849
5 changed files with 26 additions and 30 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_bmap.c,v 1.16 2004/08/15 07:19:56 mycroft Exp $ */
/* $NetBSD: ext2fs_bmap.c,v 1.17 2004/12/15 07:11:51 mycroft Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.16 2004/08/15 07:19:56 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.17 2004/12/15 07:11:51 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -176,7 +176,7 @@ ext2fs_bmaparray(vp, bn, bnp, ap, nump, runp)
if (bn >= 0 && bn < NDADDR) {
/* XXX ondisk32 */
*bnp = blkptrtodb(ump, (daddr_t)fs2h32(ip->i_e2fs_blocks[bn]));
*bnp = blkptrtodb(ump, fs2h32(ip->i_e2fs_blocks[bn]));
if (*bnp == 0)
*bnp = -1;
else if (runp)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_alloc.c,v 1.79 2004/10/11 17:15:36 dbj Exp $ */
/* $NetBSD: ffs_alloc.c,v 1.80 2004/12/15 07:11:51 mycroft Exp $ */
/*
* Copyright (c) 2002 Networks Associates Technology, Inc.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.79 2004/10/11 17:15:36 dbj Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.80 2004/12/15 07:11:51 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -566,7 +566,7 @@ ffs_reallocblks(v)
ba, buflist->bs_children[i]);
}
/* XXX ondisk32 */
*bap++ = ufs_rw32((int32_t)blkno, UFS_FSNEEDSWAP(fs));
*bap++ = ufs_rw32((u_int32_t)blkno, UFS_FSNEEDSWAP(fs));
}
/*
* Next we must write out the modified inode and indirect blocks.

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_balloc.c,v 1.36 2004/08/14 01:30:56 mycroft Exp $ */
/* $NetBSD: ffs_balloc.c,v 1.37 2004/12/15 07:11:51 mycroft Exp $ */
/*
* Copyright (c) 2002 Networks Associates Technology, Inc.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_balloc.c,v 1.36 2004/08/14 01:30:56 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_balloc.c,v 1.37 2004/12/15 07:11:51 mycroft Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -103,13 +103,12 @@ ffs_balloc_ufs1(v)
int size;
struct ucred *cred;
int flags;
int32_t nb;
struct buf *bp, *nbp;
struct vnode *vp = ap->a_vp;
struct inode *ip = VTOI(vp);
struct fs *fs = ip->i_fs;
struct indir indirs[NIADDR + 2];
daddr_t newb, pref;
daddr_t newb, pref, nb;
int32_t *bap; /* XXX ondisk32 */
int deallocated, osize, nsize, num, i, error;
int32_t *blkp, *allocblk, allociblk[NIADDR + 1];
@ -160,7 +159,7 @@ ffs_balloc_ufs1(v)
ip->i_size = lblktosize(fs, nb + 1);
ip->i_ffs1_size = ip->i_size;
uvm_vnp_setsize(vp, ip->i_ffs1_size);
ip->i_ffs1_db[nb] = ufs_rw32((int32_t)newb, needswap);
ip->i_ffs1_db[nb] = ufs_rw32((u_int32_t)newb, needswap);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp) {
if (flags & B_SYNC)
@ -268,7 +267,7 @@ ffs_balloc_ufs1(v)
nsize, 0, bpp ? *bpp : NULL);
}
}
ip->i_ffs1_db[lbn] = ufs_rw32((int32_t)newb, needswap);
ip->i_ffs1_db[lbn] = ufs_rw32((u_int32_t)newb, needswap);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_softdep.c,v 1.60 2004/08/29 10:13:48 hannken Exp $ */
/* $NetBSD: ffs_softdep.c,v 1.61 2004/12/15 07:11:51 mycroft Exp $ */
/*
* Copyright 1998 Marshall Kirk McKusick. All Rights Reserved.
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_softdep.c,v 1.60 2004/08/29 10:13:48 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_softdep.c,v 1.61 2004/12/15 07:11:51 mycroft Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@ -3623,7 +3623,7 @@ initiate_write_inodeblock_ufs1(inodedep, bp)
lastadp = adp, adp = TAILQ_NEXT(adp, ad_next)) {
if (adp->ad_lbn >= NDADDR)
break;
dp->di_db[adp->ad_lbn] = ufs_rw32((int32_t)adp->ad_oldblkno,
dp->di_db[adp->ad_lbn] = ufs_rw32((u_int32_t)adp->ad_oldblkno,
needswap);
/* keep going until hitting a rollback to a frag */
if (adp->ad_oldsize == 0 || adp->ad_oldsize == fs->fs_bsize)
@ -4220,7 +4220,7 @@ handle_written_inodeblock(inodedep, bp)
needswap),
adp->ad_oldblkno);
dp1->di_db[adp->ad_lbn] =
ufs_rw32((int32_t)adp->ad_newblkno,
ufs_rw32((u_int32_t)adp->ad_newblkno,
needswap);
} else {
if (dp1->di_ib[adp->ad_lbn - NDADDR] != 0)
@ -4232,7 +4232,7 @@ handle_written_inodeblock(inodedep, bp)
- NDADDR],
needswap));
dp1->di_ib[adp->ad_lbn - NDADDR] =
ufs_rw32((int32_t)adp->ad_newblkno,
ufs_rw32((u_int32_t)adp->ad_newblkno,
needswap);
}
} else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_bmap.c,v 1.33 2004/09/15 09:52:49 yamt Exp $ */
/* $NetBSD: ufs_bmap.c,v 1.34 2004/12/15 07:11:51 mycroft Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.33 2004/09/15 09:52:49 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.34 2004/12/15 07:11:51 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -157,7 +157,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, is_sequential)
if (nump != NULL)
*nump = 0;
if (ump->um_fstype == UFS1)
daddr = (int32_t)ufs_rw32(ip->i_ffs1_db[bn],
daddr = ufs_rw32(ip->i_ffs1_db[bn],
UFS_MPNEEDSWAP(ump));
else
daddr = ufs_rw64(ip->i_ffs2_db[bn],
@ -184,9 +184,9 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, is_sequential)
if (ump->um_fstype == UFS1) {
for (++bn; bn < NDADDR && *runp < maxrun &&
is_sequential(ump,
(int32_t)ufs_rw32(ip->i_ffs1_db[bn - 1],
ufs_rw32(ip->i_ffs1_db[bn - 1],
UFS_MPNEEDSWAP(ump)),
(int32_t)ufs_rw32(ip->i_ffs1_db[bn],
ufs_rw32(ip->i_ffs1_db[bn],
UFS_MPNEEDSWAP(ump)));
++bn, ++*runp);
} else {
@ -212,7 +212,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, is_sequential)
/* Get disk address out of indirect block array */
if (ump->um_fstype == UFS1)
daddr = (int32_t)ufs_rw32(ip->i_ffs1_ib[xap->in_off],
daddr = ufs_rw32(ip->i_ffs1_ib[xap->in_off],
UFS_MPNEEDSWAP(ump));
else
daddr = ufs_rw64(ip->i_ffs2_ib[xap->in_off],
@ -267,23 +267,20 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, is_sequential)
}
}
if (ump->um_fstype == UFS1) {
daddr = (int32_t)ufs_rw32(
((int32_t *)bp->b_data)[xap->in_off],
daddr = ufs_rw32(((u_int32_t *)bp->b_data)[xap->in_off],
UFS_MPNEEDSWAP(ump));
if (num == 1 && daddr && runp) {
for (bn = xap->in_off + 1;
bn < MNINDIR(ump) && *runp < maxrun &&
is_sequential(ump,
(int32_t)ufs_rw32(
((int32_t *)bp->b_data)[bn-1],
ufs_rw32(((int32_t *)bp->b_data)[bn-1],
UFS_MPNEEDSWAP(ump)),
(int32_t)ufs_rw32(
((int32_t *)bp->b_data)[bn],
ufs_rw32(((int32_t *)bp->b_data)[bn],
UFS_MPNEEDSWAP(ump)));
++bn, ++*runp);
}
} else {
daddr = ufs_rw64(((int64_t *)bp->b_data)[xap->in_off],
daddr = ufs_rw64(((u_int64_t *)bp->b_data)[xap->in_off],
UFS_MPNEEDSWAP(ump));
if (num == 1 && daddr && runp) {
for (bn = xap->in_off + 1;