diff options
author | 2007-05-31 22:06:02 +0000 | |
---|---|---|
committer | 2007-05-31 22:06:02 +0000 | |
commit | 0f34f8f079aa312cc3c94683d7dc59106b25b8b5 (patch) | |
tree | 66c6e2a52f31044504427aa4ef1c5013d8642e67 | |
parent | Redo the syncer to be a little smarter on interaction while shutting down (diff) | |
download | wireguard-openbsd-0f34f8f079aa312cc3c94683d7dc59106b25b8b5.tar.xz wireguard-openbsd-0f34f8f079aa312cc3c94683d7dc59106b25b8b5.zip |
Minor bounds_check_with_label nits.
1) Use local variable 'labelsector' not 'labelsect' to be consistant (hp300,
mac68k, mvme68k, mvme88k, vax).
2) Having checked for sz == 0, the next check needs only be sz < 0, not <= 0.
(mac68k, mvme68k, mvme88k)
3) Use lp->d_partitions + DISKPART(dev), rather than
lp->d_partitions[DISKPART(dev)] (hp300).
Assuming no typos there should be no functional change.
-rw-r--r-- | sys/arch/hp300/hp300/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/vax/vax/disksubr.c | 6 |
5 files changed, 22 insertions, 22 deletions
diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c index 9704f6a8b9d..fa1c307352d 100644 --- a/sys/arch/hp300/hp300/disksubr.c +++ b/sys/arch/hp300/hp300/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.27 2007/05/31 19:57:43 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.28 2007/05/31 22:06:02 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.9 1997/04/01 03:12:13 scottr Exp $ */ /* @@ -232,8 +232,8 @@ 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 labelsect = blockpersec(lp->d_partitions[0].p_offset, lp) + + struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); + int labelsector = blockpersec(lp->d_partitions[0].p_offset, lp) + LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); @@ -244,7 +244,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, } /* Overwriting disk label? */ - if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect && + if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector && (bp->b_flags & B_READ) == 0 && !wlabel) { bp->b_error = EROFS; goto bad; diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c index 26b7214ec91..2dca33d49d0 100644 --- a/sys/arch/mac68k/mac68k/disksubr.c +++ b/sys/arch/mac68k/mac68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.35 2007/05/31 19:57:43 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.36 2007/05/31 22:06:02 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */ /* @@ -563,7 +563,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, { #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) + + int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) + LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); @@ -581,7 +581,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, bp->b_resid = bp->b_bcount; goto done; } - if (sz <= 0) { + if (sz < 0) { /* If past end of disk, return EINVAL. */ bp->b_error = EINVAL; goto bad; @@ -592,9 +592,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ - if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect && + if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector && #if LABELSECTOR != 0 - bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsect && + bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector && #endif /* LABELSECTOR != 0 */ (bp->b_flags & B_READ) == 0 && wlabel == 0) { bp->b_error = EROFS; diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c index 2b08aaa0e83..431300b7c2e 100644 --- a/sys/arch/mvme68k/mvme68k/disksubr.c +++ b/sys/arch/mvme68k/mvme68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.40 2007/05/31 19:57:43 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.41 2007/05/31 22:06:02 krw Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -300,7 +300,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, { #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[0].p_offset, lp) + + int labelsector = blockpersec(lp->d_partitions[0].p_offset, lp) + LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); @@ -312,9 +312,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ - if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect && + if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector && #if LABELSECTOR != 0 - bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsect && + bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector && #endif (bp->b_flags & B_READ) == 0 && wlabel == 0) { bp->b_error = EROFS; @@ -329,7 +329,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, bp->b_resid = bp->b_bcount; return(0); } - if (sz <= 0) { + if (sz < 0) { /* If past end of disk, return EINVAL. */ bp->b_error = EINVAL; goto bad; diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c index 6a7209fa9a6..c888d4146f1 100644 --- a/sys/arch/mvme88k/mvme88k/disksubr.c +++ b/sys/arch/mvme88k/mvme88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.36 2007/05/31 19:57:44 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.37 2007/05/31 22:06:03 krw Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -297,7 +297,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, { #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[0].p_offset, lp) + + int labelsector = blockpersec(lp->d_partitions[0].p_offset, lp) + LABELSECTOR; int sz = howmany(bp->b_bcount, DEV_BSIZE); @@ -309,9 +309,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, /* overwriting disk label ? */ /* XXX should also protect bootstrap in first 8K */ - if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsect && + if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector && #if LABELSECTOR != 0 - bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsect && + bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector && #endif (bp->b_flags & B_READ) == 0 && wlabel == 0) { bp->b_error = EROFS; @@ -326,7 +326,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, bp->b_resid = bp->b_bcount; return(0); } - if (sz <= 0) { + if (sz < 0) { /* If past end of disk, return EINVAL. */ bp->b_error = EINVAL; goto bad; diff --git a/sys/arch/vax/vax/disksubr.c b/sys/arch/vax/vax/disksubr.c index 681ba43f1ba..7cf058206cf 100644 --- a/sys/arch/vax/vax/disksubr.c +++ b/sys/arch/vax/vax/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.36 2007/05/31 19:57:44 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.37 2007/05/31 22:06:03 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1999/06/30 18:48:06 ragge Exp $ */ /* @@ -60,7 +60,7 @@ 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; + int labelsector = lp->d_partitions[2].p_offset; int maxsz = p->p_size, sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT; @@ -71,7 +71,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, } /* overwriting disk label ? */ - if (bp->b_blkno + p->p_offset <= LABELSECTOR + labelsect && + if (bp->b_blkno + p->p_offset <= LABELSECTOR + labelsector && (bp->b_flags & B_READ) == 0 && wlabel == 0) { bp->b_error = EROFS; goto bad; |