diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2018-03-04 19:56:11 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2018-03-04 19:56:11 +0000 |
commit | e65b98a142f78ed32246495f2063b4a885afa357 (patch) | |
tree | 6dec77a06cd9340679067a00b8a779e4fd36c02c /sbin/disklabel/editor.c | |
parent | 0465bbefb8e9f89d94140cf05504390b9eed1988 (diff) |
Add if (D_VENDOR) check to last SUN_CYLCHECK block lacking it.
While there move local variable declaration inside the 'if' and
eliminate separate SUN_CYLCHECK block containing said local variable
declaration.
Add check for attempt to resize a partition to 0, and simplify logic a
bit by recognizing that this means the number of sectors will always
be > 0.
ok otto@
Diffstat (limited to 'sbin/disklabel/editor.c')
-rw-r--r-- | sbin/disklabel/editor.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 5ec32ff6a82..4c38c005259 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.320 2018/03/02 12:49:59 krw Exp $ */ +/* $OpenBSD: editor.c,v 1.321 2018/03/04 19:56:10 krw Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -692,9 +692,6 @@ editor_resize(struct disklabel *lp, char *p) struct disklabel label; struct partition *pp, *prev; u_int64_t secs, sz, off; -#ifdef SUN_CYLCHECK - u_int64_t cylsecs; -#endif int partno, i; label = *lp; @@ -735,14 +732,17 @@ editor_resize(struct disklabel *lp, char *p) } else if (secs == ULLONG_MAX) { fputs("Invalid entry\n", stderr); return; + } else if (secs == 0) { + fputs("The size must be > 0 sectors\n", stderr); + return; } #ifdef SUN_CYLCHECK - cylsecs = lp->d_secpercyl; - if (secs > 0) + if (lp->d_secpercyl & D_VENDOR) { + u_int64_t cylsecs; + cylsecs = lp->d_secpercyl; secs = ((secs + cylsecs - 1) / cylsecs) * cylsecs; - else - secs = ((secs - cylsecs + 1) / cylsecs) * cylsecs; + } #endif if (DL_GETPOFFSET(pp) + secs > ending_sector) { fputs("Amount too big\n", stderr); |