diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-22 00:19:19 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-22 00:19:19 +0000 |
commit | ffbd43576dc2c659ce5fda93e778c4b125ead54e (patch) | |
tree | bbf9a9b0f4b6e2aa10a56da37e9123f1815b537c /sbin | |
parent | 86ef476fb2be8c12f179f221074add2fc484ac9b (diff) |
Kill redundant loop to find number of partitions to sort. We no longer
calloc() the memory.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/disklabel/editor.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 8803a11b26b..30d3fc61933 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.160 2008/01/22 00:06:25 krw Exp $ */ +/* $OpenBSD: editor.c,v 1.161 2008/01/22 00:19:18 krw Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -17,7 +17,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: editor.c,v 1.160 2008/01/22 00:06:25 krw Exp $"; +static char rcsid[] = "$OpenBSD: editor.c,v 1.161 2008/01/22 00:19:18 krw Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -1146,18 +1146,6 @@ sort_partitions(struct disklabel *lp, u_int16_t *npart) memset(spp, 0, sizeof(spp)); - /* How many "real" partitions do we have? */ - for (npartitions = 0, i = 0; i < lp->d_npartitions; i++) { - if (lp->d_partitions[i].p_fstype != FS_UNUSED && - lp->d_partitions[i].p_fstype != FS_BOOT && - DL_GETPSIZE(&lp->d_partitions[i]) != 0) - npartitions++; - } - if (npartitions == 0) { - *npart = 0; - return(NULL); - } - for (npartitions = 0, i = 0; i < lp->d_npartitions; i++) { if (lp->d_partitions[i].p_fstype != FS_UNUSED && lp->d_partitions[i].p_fstype != FS_BOOT && @@ -1165,6 +1153,10 @@ sort_partitions(struct disklabel *lp, u_int16_t *npart) spp[npartitions++] = &lp->d_partitions[i]; } + *npart = npartitions; + if (npartitions == 0) + return(NULL); + /* * Sort the partitions based on starting offset. * This is safe because we guarantee no overlap. @@ -1174,7 +1166,6 @@ sort_partitions(struct disklabel *lp, u_int16_t *npart) partition_cmp)) err(4, "failed to sort partition table"); - *npart = npartitions; return(spp); } |