diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-18 07:09:26 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-18 07:09:26 +0000 |
commit | 589a66af41f445f6030a2aa432ca038ea578d70d (patch) | |
tree | dff9935a1d9c66a8dd1f42e6ec14bbba06039c3c /sys/arch | |
parent | ea79ce5a66fb430f0635b68bd23274aaaee0de3b (diff) |
simplify error return case from writedisklabel()
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/i386/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/landisk/landisk/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/disksubr.c | 18 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/disksubr.c | 12 |
6 files changed, 21 insertions, 41 deletions
diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c index 7d047a3cafa..bd5ee824c59 100644 --- a/sys/arch/amd64/amd64/disksubr.c +++ b/sys/arch/amd64/amd64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.51 2007/06/18 05:25:06 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.52 2007/06/18 07:09:25 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -128,7 +128,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { - int error, partoff = -1, cyl = 0; + int error = EIO, partoff = -1, cyl = 0; struct disklabel *dlp; struct buf *bp = NULL; @@ -136,10 +136,8 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; - if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) { - error = EIO; + if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) goto done; - } /* Read it in, slap the new label in, and write it back out */ bp->b_blkno = partoff + LABELSECTOR; diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c index 264607311af..e2df4d501f2 100644 --- a/sys/arch/aviion/aviion/disksubr.c +++ b/sys/arch/aviion/aviion/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.37 2007/06/18 05:25:07 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.38 2007/06/18 07:09:25 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -101,7 +101,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { - int error, partoff = -1, cyl = 0; + int error = EIO, partoff = -1, cyl = 0; struct disklabel *dlp; struct buf *bp = NULL; @@ -109,10 +109,8 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; - if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) { - error = EIO; + if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) goto done; - } /* Read it in, slap the new label in, and write it back out */ bp->b_blkno = partoff + LABELSECTOR; diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index ce625ccb614..28895d0329e 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.92 2007/06/18 05:25:07 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.93 2007/06/18 07:09:24 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -128,7 +128,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { - int error, partoff = -1, cyl = 0; + int error = EIO, partoff = -1, cyl = 0; struct disklabel *dlp; struct buf *bp = NULL; @@ -136,10 +136,8 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; - if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) { - error = EIO; + if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) goto done; - } /* Read it in, slap the new label in, and write it back out */ bp->b_blkno = partoff + LABELSECTOR; diff --git a/sys/arch/landisk/landisk/disksubr.c b/sys/arch/landisk/landisk/disksubr.c index b81d23e8b83..e99738d3ead 100644 --- a/sys/arch/landisk/landisk/disksubr.c +++ b/sys/arch/landisk/landisk/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.34 2007/06/18 05:25:07 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.35 2007/06/18 07:09:25 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -101,7 +101,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { - int error, partoff = -1, cyl = 0; + int error = EIO, partoff = -1, cyl = 0; struct disklabel *dlp; struct buf *bp = NULL; @@ -109,10 +109,8 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; - if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) { - error = EIO; + if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) goto done; - } /* Read it in, slap the new label in, and write it back out */ bp->b_blkno = partoff + LABELSECTOR; diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c index 0136f8fbd7e..33d8eaa73d0 100644 --- a/sys/arch/mips64/mips64/disksubr.c +++ b/sys/arch/mips64/mips64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.60 2007/06/17 10:29:10 miod Exp $ */ +/* $OpenBSD: disksubr.c,v 1.61 2007/06/18 07:09:25 deraadt Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -209,7 +209,6 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *), lp->d_checksum = 0; lp->d_checksum = dkcksum(lp); - finished: if (partoffp) *partoffp = fsoffs; @@ -244,7 +243,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { - int error, partoff = -1, cyl = 0; + int error = EIO, partoff = -1, cyl = 0; struct buf *bp = NULL; struct disklabel *dlp; @@ -252,17 +251,10 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; - /* find where the disklabel label should be placed */ - if (readsgilabel(bp, strat, lp, osdep, &partoff, &cyl, 1) == NULL) - goto writeit; - - if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) == NULL) - goto writeit; - - error = EIO; - goto done; + if (readsgilabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL && + readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) + goto done; -writeit: /* Read it in, slap the new label in, and write it back out */ bp->b_blkno = partoff + LABELSECTOR; bp->b_cylinder = cyl; diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c index 2a6ac597ae6..dee5db1c376 100644 --- a/sys/arch/mvmeppc/mvmeppc/disksubr.c +++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.52 2007/06/18 05:25:07 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.53 2007/06/18 07:09:25 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -101,7 +101,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { - int error, partoff = -1, cyl = 0; + int error = EIO, partoff = -1, cyl = 0; struct disklabel *dlp; struct buf *bp = NULL; @@ -109,13 +109,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; - if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) == NULL) - goto writeit; - - error = EIO; - goto done; + if (readdoslabel(bp, strat, lp, osdep, &partoff, &cyl, 1) != NULL) + goto done; -writeit: /* Read it in, slap the new label in, and write it back out */ bp->b_blkno = partoff + LABELSECTOR; bp->b_cylinder = cyl; |