diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-07-09 17:19:56 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-07-09 17:19:56 +0000 |
commit | 1ff419ef9c1c5f7bc2a055c5e03874113ba7c0c5 (patch) | |
tree | 83a62f5d284e7e94bb179b46840b660dac506688 /sbin | |
parent | 27c996996e42e404ae86faf02f437527fad373e6 (diff) |
We always want to do unit conversions. So flags parameter of getuint()
is now superflous. With rounding gone the offset parameter is
similarly superfluous. Simply getuint() accordingly.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fdisk/cmd.c | 6 | ||||
-rw-r--r-- | sbin/fdisk/misc.c | 65 | ||||
-rw-r--r-- | sbin/fdisk/misc.h | 5 |
3 files changed, 35 insertions, 41 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index dc7e30e9d0c..db54b48b300 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.56 2012/07/09 17:07:35 krw Exp $ */ +/* $OpenBSD: cmd.c,v 1.57 2012/07/09 17:19:55 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -199,7 +199,7 @@ Xedit(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset) do { pp->bs = getuint(disk, "offset", "Starting sector for this partition.", d, - disk->real->size, 0, DO_CONVERSIONS); + disk->real->size); if (pp->bs == UINT_MAX) printf("Invalid offset.\n"); } while (pp->bs == UINT_MAX); @@ -212,7 +212,7 @@ Xedit(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset) d = pp->ns; do { pp->ns = getuint(disk, "size", "Size of the partition.", - d, m, pp->bs, DO_CONVERSIONS); + d, m); if (pp->ns == UINT_MAX || pp->ns == 0) printf("Invalid size.\n"); } while (pp->ns == UINT_MAX || pp->ns == 0); diff --git a/sbin/fdisk/misc.c b/sbin/fdisk/misc.c index 1563e3e0e4b..e594f623a7b 100644 --- a/sbin/fdisk/misc.c +++ b/sbin/fdisk/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.27 2012/07/09 17:07:35 krw Exp $ */ +/* $OpenBSD: misc.c,v 1.28 2012/07/09 17:19:55 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -236,7 +236,7 @@ putlong(void *p, u_int32_t l) */ u_int32_t getuint(disk_t *disk, char *prompt, char *helpstring, u_int32_t oval, - u_int32_t maxval, u_int32_t offset, int flags) + u_int32_t maxval) { char buf[BUFSIZ], *endptr, *p, operator = '\0'; u_int32_t rval = oval; @@ -247,9 +247,6 @@ getuint(disk_t *disk, char *prompt, char *helpstring, u_int32_t oval, secpercyl = disk->real->sectors * disk->real->heads; - /* We only care about the remainder */ - offset = offset % secpercyl; - buf[0] = '\0'; do { printf("%s: [%u] ", prompt, oval); @@ -267,36 +264,34 @@ getuint(disk_t *disk, char *prompt, char *helpstring, u_int32_t oval, } else { /* deal with units */ if (buf[0] != '\0' && n > 0) { - if ((flags & DO_CONVERSIONS)) { - switch (tolower(buf[n-1])) { - - case 'c': - mult = secpercyl; - buf[--n] = '\0'; - break; - case 'b': - mult = -secsize; - buf[--n] = '\0'; - break; - case 's': - buf[--n] = '\0'; - break; - case 'k': - if (secsize > 1024) - mult = -secsize / 1024; - else - mult = 1024 / secsize; - buf[--n] = '\0'; - break; - case 'm': - mult = 1048576 / secsize; - buf[--n] = '\0'; - break; - case 'g': - mult = 1073741824 / secsize; - buf[--n] = '\0'; - break; - } + switch (tolower(buf[n-1])) { + + case 'c': + mult = secpercyl; + buf[--n] = '\0'; + break; + case 'b': + mult = -secsize; + buf[--n] = '\0'; + break; + case 's': + buf[--n] = '\0'; + break; + case 'k': + if (secsize > 1024) + mult = -secsize / 1024; + else + mult = 1024 / secsize; + buf[--n] = '\0'; + break; + case 'm': + mult = 1048576 / secsize; + buf[--n] = '\0'; + break; + case 'g': + mult = 1073741824 / secsize; + buf[--n] = '\0'; + break; } /* Did they give us an operator? */ diff --git a/sbin/fdisk/misc.h b/sbin/fdisk/misc.h index 45a02215100..cf86e87052f 100644 --- a/sbin/fdisk/misc.h +++ b/sbin/fdisk/misc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.h,v 1.15 2012/07/09 17:07:35 krw Exp $ */ +/* $OpenBSD: misc.h,v 1.16 2012/07/09 17:19:55 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -46,7 +46,6 @@ extern struct unit_type unit_types[]; #define ASK_HEX 0x01 #define ASK_DEC 0x02 #define UNIT_TYPE_DEFAULT 1 -#define DO_CONVERSIONS 0x00000001 /* Prototypes */ int unit_lookup(char *); @@ -58,7 +57,7 @@ u_int16_t getshort(void *); u_int32_t getlong(void *); void putshort(void *, u_int16_t); void putlong(void *, u_int32_t); -u_int32_t getuint(disk_t *, char *, char *, u_int32_t, u_int32_t, u_int32_t, int); +u_int32_t getuint(disk_t *, char *, char *, u_int32_t, u_int32_t); #endif /* _MISC_H */ |