summaryrefslogtreecommitdiff
path: root/sbin/disklabel/editor.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2018-03-01 15:35:41 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2018-03-01 15:35:41 +0000
commitce90377e1268356d5a83301bf5e35ce479d711e4 (patch)
tree68016a2cf62ddfca5ce1d6889be654ba15363a3b /sbin/disklabel/editor.c
parent98b0e67adfb1a30a124639d6c238c8b493891abf (diff)
Avoid underflow under SUN_CYLCHECK when rounding partition size to
multiple of cylinder size. Eliminate various compiler warnings by shuffling unused variables under !SUN_CYLCHECK. Consolidate two SUN_CYLCHECK blocks into one. Add D_VENDOR check inside SUN_CYLCHECK block. Tweak & ok otto@
Diffstat (limited to 'sbin/disklabel/editor.c')
-rw-r--r--sbin/disklabel/editor.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 4ae9b2c3906..5d73f6274e0 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.315 2018/03/01 15:19:05 krw Exp $ */
+/* $OpenBSD: editor.c,v 1.316 2018/03/01 15:35:40 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -620,15 +620,14 @@ again:
secs = ap->maxsz;
#ifdef SUN_CYLCHECK
cylinderalign:
- secs = ((secs + cylsecs - 1) / cylsecs) * cylsecs;
-#endif
- totsecs -= secs;
-#ifdef SUN_CYLCHECK
- while (totsecs < 0) {
- secs -= cylsecs;
- totsecs += cylsecs;
+ if (lp->d_flags & D_VENDOR) {
+ secs = ((secs + cylsecs - 1) / cylsecs) *
+ cylsecs;
+ while (secs > totsecs)
+ secs -= cylsecs;
}
#endif
+ totsecs -= secs;
}
/* Find largest chunk of free space. */
@@ -2035,9 +2034,12 @@ get_fsize(struct disklabel *lp, int partno)
int
get_bsize(struct disklabel *lp, int partno)
{
- u_int64_t adj, ui, bsize, frag, fsize, orig_offset, orig_size;
+ u_int64_t ui, frag, fsize;
struct partition *pp = &lp->d_partitions[partno];
+#ifndef SUN_CYLCHECK
+ u_int64_t adj, bsize, orig_offset, orig_size;
char *p;
+#endif
if (pp->p_fstype != FS_BSDFFS)
return (0);