diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-05-31 19:57:45 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-05-31 19:57:45 +0000 |
commit | f0646dd190203a23d2994fe048d94b73b2b4240f (patch) | |
tree | b761d67865eedb832715a59a431435310e458a27 /sys | |
parent | 4ce4767776c759f2905628af590a0b41814b6647 (diff) |
KNF, whitespace and comment rectification to make all
bounds_check_with_label() routines as identical as possible without
changing any code. Code nits and adjustments to come.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/alpha/alpha/disksubr.c | 13 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/disksubr.c | 4 | ||||
-rw-r--r-- | sys/arch/arm/arm/disksubr.c | 11 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/disksubr.c | 11 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/disksubr.c | 12 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/disksubr.c | 13 | ||||
-rw-r--r-- | sys/arch/hppa64/hppa64/disksubr.c | 13 | ||||
-rw-r--r-- | sys/arch/i386/i386/disksubr.c | 4 | ||||
-rw-r--r-- | sys/arch/landisk/landisk/disksubr.c | 11 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/disksubr.c | 14 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/disksubr.c | 16 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/disksubr.c | 3 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/disksubr.c | 13 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/disksubr.c | 18 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/disksubr.c | 18 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/disksubr.c | 13 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/disksubr.c | 13 | ||||
-rw-r--r-- | sys/arch/vax/vax/disksubr.c | 18 |
19 files changed, 94 insertions, 134 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c index 297c29235e8..484ac9aabf0 100644 --- a/sys/arch/alpha/alpha/disksubr.c +++ b/sys/arch/alpha/alpha/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.70 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.71 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -535,16 +535,13 @@ writedisklabel(dev, strat, lp, osdep) * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); - int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, - lp) + osdep->labelsector; + int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) + + osdep->labelsector; int sz = howmany(bp->b_bcount, DEV_BSIZE); /* avoid division by zero */ diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c index 41270136799..de0b58008f8 100644 --- a/sys/arch/amd64/amd64/disksubr.c +++ b/sys/arch/amd64/amd64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.34 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.35 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -509,7 +509,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, /* calculate cylinder for disksort to order transfers with */ bp->b_cylinder = (bp->b_blkno + blockpersec(p->p_offset, lp)) / - lp->d_secpercyl; + lp->d_secpercyl; return (1); bad: diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c index 063e56629b5..94cb1399a53 100644 --- a/sys/arch/arm/arm/disksubr.c +++ b/sys/arch/arm/arm/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.29 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.30 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -446,11 +446,8 @@ done: * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); @@ -493,7 +490,7 @@ bounds_check_with_label(bp, lp, osdep, wlabel) /* calculate cylinder for disksort to order transfers with */ bp->b_cylinder = (bp->b_blkno + blockpersec(p->p_offset, lp)) / - lp->d_secpercyl; + lp->d_secpercyl; return (1); bad: diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c index c3d334c1dcd..e0b979c8fa8 100644 --- a/sys/arch/aviion/aviion/disksubr.c +++ b/sys/arch/aviion/aviion/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.20 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.21 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -445,11 +445,8 @@ done: * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); @@ -492,7 +489,7 @@ bounds_check_with_label(bp, lp, osdep, wlabel) /* calculate cylinder for disksort to order transfers with */ bp->b_cylinder = (bp->b_blkno + blockpersec(p->p_offset, lp)) / - lp->d_secpercyl; + lp->d_secpercyl; return (1); bad: diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c index e66ebbf667e..9704f6a8b9d 100644 --- a/sys/arch/hp300/hp300/disksubr.c +++ b/sys/arch/hp300/hp300/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.26 2007/05/31 02:57:53 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.27 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.9 1997/04/01 03:12:13 scottr Exp $ */ /* @@ -228,11 +228,8 @@ done: * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = &lp->d_partitions[DISKPART(bp->b_dev)]; @@ -262,10 +259,11 @@ bounds_check_with_label(bp, lp, osdep, wlabel) return (0); } if (sz < 0) { + /* If past end of disk, return EINVAL. */ bp->b_error = EINVAL; goto bad; } - /* ... or truncate if part of it fits */ + /* Otherwise, truncate request. */ bp->b_bcount = sz << DEV_BSHIFT; } diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c index 73252102375..43dcba75781 100644 --- a/sys/arch/hppa/hppa/disksubr.c +++ b/sys/arch/hppa/hppa/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.50 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.51 2007/05/31 19:57:43 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -689,16 +689,13 @@ writedisklabel(dev, strat, lp, osdep) * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); - int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, - lp) + osdep->labelsector; + int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) + + osdep->labelsector; int sz = howmany(bp->b_bcount, DEV_BSIZE); /* avoid division by zero */ diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c index 55c1190e3d2..e795309981d 100644 --- a/sys/arch/hppa64/hppa64/disksubr.c +++ b/sys/arch/hppa64/hppa64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.33 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.34 2007/05/31 19:57:43 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -685,16 +685,13 @@ writedisklabel(dev, strat, lp, osdep) * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); - int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, - lp) + osdep->labelsector; + int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) + + osdep->labelsector; int sz = howmany(bp->b_bcount, DEV_BSIZE); /* avoid division by zero */ diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index f16d43931e4..d1f26ecd91c 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.74 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.75 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -509,7 +509,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, /* calculate cylinder for disksort to order transfers with */ bp->b_cylinder = (bp->b_blkno + blockpersec(p->p_offset, lp)) / - lp->d_secpercyl; + lp->d_secpercyl; return (1); bad: diff --git a/sys/arch/landisk/landisk/disksubr.c b/sys/arch/landisk/landisk/disksubr.c index 18db52b2f33..925547d3f84 100644 --- a/sys/arch/landisk/landisk/disksubr.c +++ b/sys/arch/landisk/landisk/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.17 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.18 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -446,11 +446,8 @@ done: * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); @@ -493,7 +490,7 @@ bounds_check_with_label(bp, lp, osdep, wlabel) /* calculate cylinder for disksort to order transfers with */ bp->b_cylinder = (bp->b_blkno + blockpersec(p->p_offset, lp)) / - lp->d_secpercyl; + lp->d_secpercyl; return (1); bad: diff --git a/sys/arch/luna88k/luna88k/disksubr.c b/sys/arch/luna88k/luna88k/disksubr.c index 1112ef4a592..07d38871ee3 100644 --- a/sys/arch/luna88k/luna88k/disksubr.c +++ b/sys/arch/luna88k/luna88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.12 2007/05/29 06:28:15 otto Exp $ */ +/* $OpenBSD: disksubr.c,v 1.13 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.12 2002/02/19 17:09:44 wiz Exp $ */ /* @@ -306,11 +306,8 @@ writedisklabel(dev, strat, lp, clp) * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); @@ -335,15 +332,16 @@ bounds_check_with_label(bp, lp, osdep, wlabel) if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { - /* if exactly at end of disk, return an EOF */ + /* If exactly at end of disk, return EOF. */ bp->b_resid = bp->b_bcount; return (0); } if (sz < 0) { + /* If past end of disk, return EINVAL. */ bp->b_error = EINVAL; goto bad; } - /* or truncate if part of it fits */ + /* Otherwise, truncate request. */ bp->b_bcount = sz << DEV_BSHIFT; } diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c index 4455c2014c5..26b7214ec91 100644 --- a/sys/arch/mac68k/mac68k/disksubr.c +++ b/sys/arch/mac68k/mac68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.34 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.35 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */ /* @@ -558,13 +558,10 @@ done: * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { -#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) +#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); int labelsect = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) + LABELSECTOR; @@ -580,15 +577,16 @@ bounds_check_with_label(bp, lp, osdep, wlabel) if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { - /* if exactly at end of disk, return an EOF */ + /* If exactly at end of disk, return EOF. */ bp->b_resid = bp->b_bcount; goto done; } if (sz <= 0) { + /* If past end of disk, return EINVAL. */ bp->b_error = EINVAL; goto bad; } - /* or truncate if part of it fits */ + /* Otherwise, truncate request. */ bp->b_bcount = sz << DEV_BSHIFT; } diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c index 54ac0440990..ead869a5465 100644 --- a/sys/arch/macppc/macppc/disksubr.c +++ b/sys/arch/macppc/macppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.39 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.40 2007/05/31 19:57:43 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -567,6 +567,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, goto bad; } + /* beyond partition? */ if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c index c60fe7cdd08..fa1f6becf0e 100644 --- a/sys/arch/mips64/mips64/disksubr.c +++ b/sys/arch/mips64/mips64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.39 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.40 2007/05/31 19:57:43 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -635,16 +635,13 @@ writedisklabel(dev, strat, lp, osdep) * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); - int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, - lp) + osdep->labelsector; + int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) + + osdep->labelsector; int sz = howmany(bp->b_bcount, DEV_BSIZE); /* avoid division by zero */ diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c index 13ceb97c242..2b08aaa0e83 100644 --- a/sys/arch/mvme68k/mvme68k/disksubr.c +++ b/sys/arch/mvme68k/mvme68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.39 2007/05/29 06:28:15 otto Exp $ */ +/* $OpenBSD: disksubr.c,v 1.40 2007/05/31 19:57:43 krw Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -295,11 +295,8 @@ writedisklabel(dev, strat, lp, clp) int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); @@ -328,26 +325,27 @@ bounds_check_with_label(bp, lp, osdep, wlabel) if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { - /* if exactly at end of disk, return an EOF */ + /* If exactly at end of disk, return EOF. */ bp->b_resid = bp->b_bcount; return(0); } if (sz <= 0) { + /* If past end of disk, return EINVAL. */ bp->b_error = EINVAL; goto bad; } - /* or truncate if part of it fits */ + /* Otherwise, truncate request. */ bp->b_bcount = sz << DEV_BSHIFT; } /* calculate cylinder for disksort to order transfers with */ bp->b_cylinder = (bp->b_blkno + blockpersec(p->p_offset, lp)) / lp->d_secpercyl; - return(1); + return (1); bad: bp->b_flags |= B_ERROR; - return(-1); + return (-1); } diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c index bd9535d72d7..6a7209fa9a6 100644 --- a/sys/arch/mvme88k/mvme88k/disksubr.c +++ b/sys/arch/mvme88k/mvme88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.35 2007/05/29 06:28:15 otto Exp $ */ +/* $OpenBSD: disksubr.c,v 1.36 2007/05/31 19:57:44 krw Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -292,11 +292,8 @@ writedisklabel(dev, strat, lp, clp) int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); @@ -325,26 +322,27 @@ bounds_check_with_label(bp, lp, osdep, wlabel) if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { - /* if exactly at end of disk, return an EOF */ + /* If exactly at end of disk, return EOF. */ bp->b_resid = bp->b_bcount; return(0); } if (sz <= 0) { + /* If past end of disk, return EINVAL. */ bp->b_error = EINVAL; goto bad; } - /* or truncate if part of it fits */ + /* Otherwise, truncate request. */ bp->b_bcount = sz << DEV_BSHIFT; } /* calculate cylinder for disksort to order transfers with */ bp->b_cylinder = (bp->b_blkno + blockpersec(p->p_offset, lp)) / lp->d_secpercyl; - return(1); + return (1); bad: bp->b_flags |= B_ERROR; - return(-1); + return (-1); } diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c index 56f00803135..2faaa2aa657 100644 --- a/sys/arch/mvmeppc/mvmeppc/disksubr.c +++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.35 2007/05/31 16:05:50 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.36 2007/05/31 19:57:44 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -448,11 +448,8 @@ done: * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); @@ -466,6 +463,7 @@ bounds_check_with_label(bp, lp, osdep, wlabel) goto bad; } + /* beyond partition? */ if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c index d36a0b1d93e..943546b1aac 100644 --- a/sys/arch/sparc/sparc/disksubr.c +++ b/sys/arch/sparc/sparc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.46 2007/05/31 02:57:53 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.47 2007/05/31 19:57:44 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */ /* @@ -282,11 +282,8 @@ writedisklabel(dev, strat, lp, clp) * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); @@ -312,7 +309,7 @@ bounds_check_with_label(bp, lp, osdep, wlabel) if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { - /* If exactly at end of disk, return an EOF */ + /* If exactly at end of disk, return EOF. */ bp->b_resid = bp->b_bcount; return (0); } @@ -321,7 +318,7 @@ bounds_check_with_label(bp, lp, osdep, wlabel) bp->b_error = EINVAL; goto bad; } - /* Or truncate if part of it fits */ + /* Otherwise, truncate request. */ bp->b_bcount = sz << DEV_BSHIFT; } diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c index 92b65f73e2e..0b85b5f3463 100644 --- a/sys/arch/sparc64/sparc64/disksubr.c +++ b/sys/arch/sparc64/sparc64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.25 2007/05/31 02:57:53 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.26 2007/05/31 19:57:44 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */ /* @@ -279,11 +279,8 @@ writedisklabel(dev, strat, lp, clp) * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { #define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); @@ -309,7 +306,7 @@ bounds_check_with_label(bp, lp, osdep, wlabel) if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { - /* If exactly at end of disk, return an EOF */ + /* If exactly at end of disk, return EOF. */ bp->b_resid = bp->b_bcount; return (0); } @@ -318,7 +315,7 @@ bounds_check_with_label(bp, lp, osdep, wlabel) bp->b_error = EINVAL; goto bad; } - /* Or truncate if part of it fits */ + /* Otherwise, truncate request. */ bp->b_bcount = sz << DEV_BSHIFT; } diff --git a/sys/arch/vax/vax/disksubr.c b/sys/arch/vax/vax/disksubr.c index c94fd2c0ff2..681ba43f1ba 100644 --- a/sys/arch/vax/vax/disksubr.c +++ b/sys/arch/vax/vax/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.35 2007/05/29 06:28:15 otto Exp $ */ +/* $OpenBSD: disksubr.c,v 1.36 2007/05/31 19:57:44 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1999/06/30 18:48:06 ragge Exp $ */ /* @@ -56,11 +56,8 @@ * if needed, and signal errors or early completion. */ int -bounds_check_with_label(bp, lp, osdep, wlabel) - struct buf *bp; - struct disklabel *lp; - struct cpu_disklabel *osdep; - int wlabel; +bounds_check_with_label(struct buf *bp, struct disklabel *lp, + struct cpu_disklabel *osdep, int wlabel) { struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); int labelsect = lp->d_partitions[2].p_offset; @@ -82,27 +79,28 @@ bounds_check_with_label(bp, lp, osdep, wlabel) /* beyond partition? */ if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) { - /* if exactly at end of disk, return an EOF */ + /* if exactly at end of disk, return EOF. */ if (bp->b_blkno == maxsz) { bp->b_resid = bp->b_bcount; return(0); } - /* or truncate if part of it fits */ + /* Otherwise, truncate request. */ sz = maxsz - bp->b_blkno; if (sz <= 0) { bp->b_error = EINVAL; goto bad; } + /* Otherwise, truncate request. */ bp->b_bcount = sz << DEV_BSHIFT; } /* calculate cylinder for disksort to order transfers with */ bp->b_cylinder = (bp->b_blkno + p->p_offset) / lp->d_secpercyl; - return(1); + return (1); bad: bp->b_flags |= B_ERROR; - return(-1); + return (-1); } /* |