summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2009-04-07 03:12:00 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2009-04-07 03:12:00 +0000
commit47bee9fd554074164674a3601d0ec03b4ae395d2 (patch)
treefb8608e0ff37244689bf20b6d781e83d8cdc41fd /sys/arch
parentceeac5ceac03df177efec805691a3284bedd681a (diff)
Eliminate useless loop over partitions and ignore zero length
partitions in bsd_to_sun(), even if their offsets are nonsense. Theo says if sparc64 compiles so will sparc. Fixes some useless disklabel warning messages. ok miod@ deraadt@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc/sparc/disksubr.c37
-rw-r--r--sys/arch/sparc64/sparc64/disksubr.c33
2 files changed, 36 insertions, 34 deletions
diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c
index b13058af679..b7c362308f0 100644
--- a/sys/arch/sparc/sparc/disksubr.c
+++ b/sys/arch/sparc/sparc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.77 2009/01/22 01:06:28 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.78 2009/04/07 03:11:59 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */
/*
@@ -283,7 +283,7 @@ disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
npp = &lp->d_partitions[i];
DL_SETPOFFSET(npp, spp->sdkp_cyloffset * secpercyl);
DL_SETPSIZE(npp, spp->sdkp_nsectors);
- if (DL_GETPSIZE(npp) == 0) {
+ if (DL_GETPSIZE(npp) == 0)) {
npp->p_fstype = FS_UNUSED;
} else {
npp->p_fstype = sun_fstypes[i];
@@ -325,7 +325,7 @@ disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
npp = &lp->d_partitions[i+8];
DL_SETPOFFSET(npp, spp->sdkp_cyloffset * secpercyl);
DL_SETPSIZE(npp, spp->sdkp_nsectors);
- if (DL_GETPSIZE(npp) == 0) {
+ if (DL_GETPSIZE(npp) == 0)) {
npp->p_fstype = FS_UNUSED;
continue;
}
@@ -421,27 +421,28 @@ disklabel_bsd_to_sun(struct disklabel *lp, struct sun_disklabel *sl)
for (i = 0; i < 8; i++) {
spp = &sl->sl_part[i];
npp = &lp->d_partitions[i];
-
- if (DL_GETPOFFSET(npp) % secpercyl)
- return (EINVAL);
- spp->sdkp_cyloffset = DL_GETPOFFSET(npp) / secpercyl;
- spp->sdkp_nsectors = DL_GETPSIZE(npp);
+ spp->sdkp_cyloffset = 0;
+ spp->sdkp_nsectors = 0;
+ if (DL_GETPSIZE(npp) {
+ if (DL_GETPOFFSET(npp) % secpercyl)
+ return (EINVAL);
+ spp->sdkp_cyloffset = DL_GETPOFFSET(npp) / secpercyl;
+ spp->sdkp_nsectors = DL_GETPSIZE(npp);
+ }
}
sl->sl_magic = SUN_DKMAGIC;
for (i = 0; i < SUNXPART; i++) {
- if (DL_GETPOFFSET(&lp->d_partitions[i+8]) ||
- DL_GETPSIZE(&lp->d_partitions[i+8]))
- break;
- }
- for (i = 0; i < SUNXPART; i++) {
spp = &sl->sl_xpart[i];
npp = &lp->d_partitions[i+8];
- if (DL_GETPOFFSET(npp) % secpercyl)
- return (EINVAL);
- sl->sl_xpart[i].sdkp_cyloffset =
- DL_GETPOFFSET(npp) / secpercyl;
- sl->sl_xpart[i].sdkp_nsectors = DL_GETPSIZE(npp);
+ spp->sdkp_cyloffset = 0;
+ spp->sdkp_nsectors = 0;
+ if (DL_GETPSIZE(npp) {
+ if (DL_GETPOFFSET(npp) % secpercyl)
+ return (EINVAL);
+ spp->sdkp_cyloffset = DL_GETPOFFSET(npp) / secpercyl;
+ spp->sdkp_nsectors = DL_GETPSIZE(npp);
+ }
}
for (i = 0; i < MAXPARTITIONS; i++) {
npp = &lp->d_partitions[i];
diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c
index 8532661f77e..6d43f696060 100644
--- a/sys/arch/sparc64/sparc64/disksubr.c
+++ b/sys/arch/sparc64/sparc64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.53 2009/01/22 01:06:28 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.54 2009/04/07 03:11:59 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */
/*
@@ -414,27 +414,28 @@ disklabel_bsd_to_sun(struct disklabel *lp, struct sun_disklabel *sl)
for (i = 0; i < 8; i++) {
spp = &sl->sl_part[i];
npp = &lp->d_partitions[i];
-
- if (DL_GETPOFFSET(npp) % secpercyl)
- return (EINVAL);
- spp->sdkp_cyloffset = DL_GETPOFFSET(npp) / secpercyl;
- spp->sdkp_nsectors = DL_GETPSIZE(npp);
+ spp->sdkp_cyloffset = 0;
+ spp->sdkp_nsectors = 0;
+ if (DL_GETPSIZE(npp)) {
+ if (DL_GETPOFFSET(npp) % secpercyl)
+ return (EINVAL);
+ spp->sdkp_cyloffset = DL_GETPOFFSET(npp) / secpercyl;
+ spp->sdkp_nsectors = DL_GETPSIZE(npp);
+ }
}
sl->sl_magic = SUN_DKMAGIC;
for (i = 0; i < SUNXPART; i++) {
- if (DL_GETPOFFSET(&lp->d_partitions[i+8]) ||
- DL_GETPSIZE(&lp->d_partitions[i+8]))
- break;
- }
- for (i = 0; i < SUNXPART; i++) {
spp = &sl->sl_xpart[i];
npp = &lp->d_partitions[i+8];
- if (DL_GETPOFFSET(npp) % secpercyl)
- return (EINVAL);
- sl->sl_xpart[i].sdkp_cyloffset =
- DL_GETPOFFSET(npp) / secpercyl;
- sl->sl_xpart[i].sdkp_nsectors = DL_GETPSIZE(npp);
+ spp->sdkp_cyloffset = 0;
+ spp->sdkp_nsectors = 0;
+ if (DL_GETPSIZE(npp)) {
+ if (DL_GETPOFFSET(npp) % secpercyl)
+ return (EINVAL);
+ spp->sdkp_cyloffset = DL_GETPOFFSET(npp) / secpercyl;
+ spp->sdkp_nsectors = DL_GETPSIZE(npp);
+ }
}
for (i = 0; i < MAXPARTITIONS; i++) {
npp = &lp->d_partitions[i];