min() -> MIN(), max() -> MAX().

fixes more problems with file offsets > 4GB.
This commit is contained in:
chs 2001-02-27 04:37:44 +00:00
parent d65f44a1a5
commit 060e70db41
7 changed files with 33 additions and 35 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: advnops.c,v 1.56 2001/01/22 12:17:36 jdolecek Exp $ */
/* $NetBSD: advnops.c,v 1.57 2001/02/27 04:37:44 chs Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -273,7 +273,7 @@ adosfs_read(v)
error = 0;
while (uio->uio_resid > 0) {
void *win;
vsize_t bytelen = min(ap->fsize - uio->uio_offset,
vsize_t bytelen = MIN(ap->fsize - uio->uio_offset,
uio->uio_resid);
if (bytelen == 0) {
@ -298,7 +298,7 @@ adosfs_read(v)
size = amp->dbsize;
lbn = uio->uio_offset / size;
on = uio->uio_offset % size;
n = min((u_int)(size - on), uio->uio_resid);
n = MIN(size - on, uio->uio_resid);
diff = ap->fsize - uio->uio_offset;
/*
* check for EOF
@ -346,7 +346,7 @@ adosfs_read(v)
#ifdef ADOSFS_DIAGNOSTIC
printf(" %d+%d-%d+%d", lbn, on, lbn, n);
#endif
n = min(n, (u_int)size - bp->b_resid);
n = MIN(n, size - bp->b_resid);
error = uiomove(bp->b_data + on +
amp->bsize - amp->dbsize, (int)n, uio);
brelse(bp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: filecore_vnops.c,v 1.11 2001/01/22 13:32:23 jdolecek Exp $ */
/* $NetBSD: filecore_vnops.c,v 1.12 2001/02/27 04:37:45 chs Exp $ */
/*-
* Copyright (c) 1998 Andrew McMurry
@ -167,7 +167,7 @@ filecore_read(v)
error = 0;
while (uio->uio_resid > 0) {
void *win;
vsize_t bytelen = min(ip->i_size - uio->uio_offset,
vsize_t bytelen = MIN(ip->i_size - uio->uio_offset,
uio->uio_resid);
if (bytelen == 0) {
@ -187,8 +187,7 @@ filecore_read(v)
do {
lbn = lblkno(fcmp, uio->uio_offset);
on = blkoff(fcmp, uio->uio_offset);
n = min((u_int)(blksize(fcmp, ip, lbn) - on),
uio->uio_resid);
n = MIN(blksize(fcmp, ip, lbn) - on, uio->uio_resid);
diff = (off_t)ip->i_size - uio->uio_offset;
if (diff <= 0)
return (0);
@ -199,7 +198,7 @@ filecore_read(v)
if (ip->i_dirent.attr & FILECORE_ATTR_DIR) {
error = filecore_dbread(ip, &bp);
on = uio->uio_offset;
n = min(FILECORE_DIR_SIZE-on, uio->uio_resid);
n = MIN(FILECORE_DIR_SIZE - on, uio->uio_resid);
size = FILECORE_DIR_SIZE;
} else {
if (vp->v_lastr + 1 == lbn &&
@ -220,7 +219,7 @@ filecore_read(v)
}
}
vp->v_lastr = lbn;
n = min(n, size - bp->b_resid);
n = MIN(n, size - bp->b_resid);
if (error) {
#ifdef FILECORE_DEBUG_BR
printf("brelse(%p) vn1\n", bp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660_vnops.c,v 1.62 2001/01/22 13:18:29 jdolecek Exp $ */
/* $NetBSD: cd9660_vnops.c,v 1.63 2001/02/27 04:37:45 chs Exp $ */
/*-
* Copyright (c) 1994
@ -283,7 +283,7 @@ cd9660_read(v)
error = 0;
while (uio->uio_resid > 0) {
void *win;
vsize_t bytelen = min(ip->i_size - uio->uio_offset,
vsize_t bytelen = MIN(ip->i_size - uio->uio_offset,
uio->uio_resid);
if (bytelen == 0)
@ -301,8 +301,7 @@ cd9660_read(v)
do {
lbn = lblkno(imp, uio->uio_offset);
on = blkoff(imp, uio->uio_offset);
n = min((u_int)(imp->logical_block_size - on),
uio->uio_resid);
n = MIN(imp->logical_block_size - on, uio->uio_resid);
diff = (off_t)ip->i_size - uio->uio_offset;
if (diff <= 0)
return (0);
@ -326,7 +325,7 @@ cd9660_read(v)
error = bread(vp, lbn, size, NOCRED, &bp);
}
vp->v_lastr = lbn;
n = min(n, size - bp->b_resid);
n = MIN(n, size - bp->b_resid);
if (error) {
brelse(bp);
return (error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: msdosfs_vnops.c,v 1.106 2001/01/22 12:17:36 jdolecek Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.107 2001/02/27 04:37:46 chs Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@ -486,7 +486,7 @@ msdosfs_read(v)
if (vp->v_type == VREG) {
while (uio->uio_resid > 0) {
bytelen = min(dep->de_FileSize - uio->uio_offset,
bytelen = MIN(dep->de_FileSize - uio->uio_offset,
uio->uio_resid);
if (bytelen == 0)
@ -506,7 +506,7 @@ msdosfs_read(v)
do {
lbn = de_cluster(pmp, uio->uio_offset);
on = uio->uio_offset & pmp->pm_crbomask;
n = min((u_long) (pmp->pm_bpcluster - on), uio->uio_resid);
n = MIN(pmp->pm_bpcluster - on, uio->uio_resid);
if (uio->uio_offset >= dep->de_FileSize)
return (0);
/* file size (and hence diff) may be up to 4GB */
@ -525,7 +525,7 @@ msdosfs_read(v)
* vnode for the directory.
*/
error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
n = min(n, pmp->pm_bpcluster - bp->b_resid);
n = MIN(n, pmp->pm_bpcluster - bp->b_resid);
if (error) {
brelse(bp);
return (error);
@ -646,7 +646,7 @@ msdosfs_write(v)
error = ENOSPC;
break;
}
bytelen = min(dep->de_FileSize - oldoff, uio->uio_resid);
bytelen = MIN(dep->de_FileSize - oldoff, uio->uio_resid);
/*
* XXXUBC if file is mapped and this is the last block,
@ -1549,11 +1549,11 @@ msdosfs_readdir(v)
while (uio->uio_resid > 0) {
lbn = de_cluster(pmp, offset - bias);
on = (offset - bias) & pmp->pm_crbomask;
n = min(pmp->pm_bpcluster - on, uio->uio_resid);
n = MIN(pmp->pm_bpcluster - on, uio->uio_resid);
diff = dep->de_FileSize - (offset - bias);
if (diff <= 0)
break;
n = min(n, diff);
n = MIN(n, diff);
if ((error = pcbmap(dep, lbn, &bn, &cn, &blsize)) != 0)
break;
error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
@ -1561,7 +1561,7 @@ msdosfs_readdir(v)
brelse(bp);
return (error);
}
n = min(n, blsize - bp->b_resid);
n = MIN(n, blsize - bp->b_resid);
/*
* Convert from dos directory entries to fs-independent

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_bio.c,v 1.62 2001/02/18 15:52:32 chs Exp $ */
/* $NetBSD: nfs_bio.c,v 1.63 2001/02/27 04:37:46 chs Exp $ */
/*
* Copyright (c) 1989, 1993
@ -259,7 +259,7 @@ nfs_bioread(vp, uio, ioflag, cred, cflag)
return (error);
}
}
n = min(uio->uio_resid, NFS_MAXPATHLEN - bp->b_resid);
n = MIN(uio->uio_resid, NFS_MAXPATHLEN - bp->b_resid);
got_buf = 1;
on = 0;
break;
@ -894,7 +894,7 @@ nfs_doio(bp, p)
len = np->n_size - ((((off_t)bp->b_blkno) << DEV_BSHIFT)
+ diff);
if (len > 0) {
len = min(len, uiop->uio_resid);
len = MIN(len, uiop->uio_resid);
memset((char *)bp->b_data + diff, 0, len);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_readwrite.c,v 1.15 2000/12/01 07:02:40 chs Exp $ */
/* $NetBSD: ext2fs_readwrite.c,v 1.16 2001/02/27 04:37:47 chs Exp $ */
/*-
* Copyright (c) 1997 Manuel Bouyer.
@ -113,7 +113,7 @@ ext2fs_read(v)
error = 0;
while (uio->uio_resid > 0) {
bytelen = min(ip->i_e2fs_size - uio->uio_offset,
bytelen = MIN(ip->i_e2fs_size - uio->uio_offset,
uio->uio_resid);
if (bytelen == 0) {
@ -268,7 +268,7 @@ ext2fs_write(v)
while (uio->uio_resid > 0) {
oldoff = uio->uio_offset;
blkoffset = blkoff(fs, uio->uio_offset);
bytelen = min(fs->e2fs_bsize - blkoffset,
bytelen = MIN(fs->e2fs_bsize - blkoffset,
uio->uio_resid);
/*
@ -309,7 +309,7 @@ ext2fs_write(v)
for (error = 0; uio->uio_resid > 0;) {
lbn = lblkno(fs, uio->uio_offset);
blkoffset = blkoff(fs, uio->uio_offset);
xfersize = min(fs->e2fs_bsize - blkoffset, uio->uio_resid);
xfersize = MIN(fs->e2fs_bsize - blkoffset, uio->uio_resid);
if (xfersize < fs->e2fs_bsize)
flags |= B_CLRBUF;
else

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_readwrite.c,v 1.29 2001/02/26 17:12:08 lukem Exp $ */
/* $NetBSD: ufs_readwrite.c,v 1.30 2001/02/27 04:37:47 chs Exp $ */
/*-
* Copyright (c) 1993
@ -111,7 +111,7 @@ READ(void *v)
#ifndef LFS_READWRITE
if (vp->v_type == VREG) {
while (uio->uio_resid > 0) {
bytelen = min(ip->i_ffs_size - uio->uio_offset,
bytelen = MIN(ip->i_ffs_size - uio->uio_offset,
uio->uio_resid);
if (bytelen == 0)
break;
@ -135,7 +135,7 @@ READ(void *v)
nextlbn = lbn + 1;
size = BLKSIZE(fs, ip, lbn);
blkoffset = blkoff(fs, uio->uio_offset);
xfersize = min(min(fs->fs_bsize - blkoffset, uio->uio_resid),
xfersize = MIN(MIN(fs->fs_bsize - blkoffset, uio->uio_resid),
bytesinfile);
#ifdef LFS_READWRITE
@ -275,7 +275,7 @@ WRITE(void *v)
while (uio->uio_resid > 0) {
oldoff = uio->uio_offset;
blkoffset = blkoff(fs, uio->uio_offset);
bytelen = min(fs->fs_bsize - blkoffset, uio->uio_resid);
bytelen = MIN(fs->fs_bsize - blkoffset, uio->uio_resid);
/*
* XXXUBC if file is mapped and this is the last block,
@ -323,7 +323,7 @@ WRITE(void *v)
while (uio->uio_resid > 0) {
lbn = lblkno(fs, uio->uio_offset);
blkoffset = blkoff(fs, uio->uio_offset);
xfersize = min(fs->fs_bsize - blkoffset, uio->uio_resid);
xfersize = MIN(fs->fs_bsize - blkoffset, uio->uio_resid);
if (fs->fs_bsize > xfersize)
flags |= B_CLRBUF;
else