diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-22 01:31:28 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-22 01:31:28 +0000 |
commit | b70269962b87c1ec7a7b5631b5d287d08fa3d727 (patch) | |
tree | f88e425338f54965f3082b14f64421f3484a9539 /sbin | |
parent | 9979bf4bd0f61ed3facbac526056a5eb5668ed4d (diff) |
Use u_int64_t variables to hold partition offsets when calculating
offsets and sizes of free chunks. 32 bits just won't hack new big
partitions. Simplify and clarify code while here.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/disklabel/editor.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 279d7e45c00..e8a7f8cec1b 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.162 2008/01/22 01:12:50 krw Exp $ */ +/* $OpenBSD: editor.c,v 1.163 2008/01/22 01:31:27 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.162 2008/01/22 01:12:50 krw Exp $"; +static char rcsid[] = "$OpenBSD: editor.c,v 1.163 2008/01/22 01:31:27 krw Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -1289,6 +1289,7 @@ free_chunks(struct disklabel *lp) { struct partition **spp; static struct diskchunk chunks[MAXPARTITIONS + 2]; + u_int64_t start, stop; int i, numchunks; /* Sort the in-use partitions based on offset */ @@ -1310,23 +1311,15 @@ free_chunks(struct disklabel *lp) numchunks++; } for (i = 0; spp[i] != NULL; i++) { - if (spp[i + 1] != NULL) { - u_int o1 = DL_GETPOFFSET(spp[i]) + DL_GETPSIZE(spp[i]); - u_int o2 = DL_GETPOFFSET(spp[i+1]); - if (o1 < o2) { - chunks[numchunks].start = o1; - chunks[numchunks].stop = o2; - numchunks++; - } - } else { - u_int o1 = DL_GETPOFFSET(spp[i]) + DL_GETPSIZE(spp[i]); - /* Last partition */ - if (o1 < ending_sector) { - - chunks[numchunks].start = o1; - chunks[numchunks].stop = ending_sector; - numchunks++; - } + start = DL_GETPOFFSET(spp[i]) + DL_GETPSIZE(spp[i]); + if (spp[i + 1] != NULL) + stop = DL_GETPOFFSET(spp[i+1]); + else + stop = ending_sector; + if (start < stop) { + chunks[numchunks].start = start; + chunks[numchunks].stop = stop; + numchunks++; } } |