summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2016-01-23 22:55:24 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2016-01-23 22:55:24 +0000
commit0eeb4117b4bb956f7a79d66ab2af45d87d9ca322 (patch)
tree4dd63d3b0b82099088f4c52043fbb991f94d7970 /sbin
parentc85b4c3df1ca241e684e5c69658b95bb1e2965ff (diff)
No need for 'default_value' parameter for get_number_argument() since we
always pass kDefault. a.k.a. -1. Nuke kDefault since it is now unused. Nuke unused #define MAXIOSIZE in passing.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/pdisk/io.c15
-rw-r--r--sbin/pdisk/io.h9
-rw-r--r--sbin/pdisk/pdisk.c21
3 files changed, 15 insertions, 30 deletions
diff --git a/sbin/pdisk/io.c b/sbin/pdisk/io.c
index 3c83c546d6a..2d27e60c012 100644
--- a/sbin/pdisk/io.c
+++ b/sbin/pdisk/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.20 2016/01/23 19:14:04 krw Exp $ */
+/* $OpenBSD: io.c,v 1.21 2016/01/23 22:55:23 krw Exp $ */
/*
* io.c - simple io and input parsing routines
@@ -39,8 +39,6 @@
#define STRING_CHUNK 16
#define UNGET_MAX_COUNT 10
-const long kDefault = -1;
-
short unget_buf[UNGET_MAX_COUNT + 1];
int unget_count;
@@ -153,7 +151,7 @@ get_command(const char *prompt, int promptBeforeGet, int *command)
}
int
-get_number_argument(const char *prompt, long *number, long default_value)
+get_number_argument(const char *prompt, long *number)
{
int c;
int result = 0;
@@ -166,14 +164,7 @@ get_number_argument(const char *prompt, long *number, long default_value)
} else if (c == ' ' || c == '\t') {
/* skip blanks and tabs */
} else if (c == '\n') {
- if (default_value == kDefault) {
- printf(prompt);
- } else {
- my_ungetch(c);
- *number = default_value;
- result = 1;
- break;
- }
+ printf(prompt);
} else if ('0' <= c && c <= '9') {
*number = get_number(c);
result = 1;
diff --git a/sbin/pdisk/io.h b/sbin/pdisk/io.h
index 2b4c944acdd..af01b14f6ca 100644
--- a/sbin/pdisk/io.h
+++ b/sbin/pdisk/io.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.h,v 1.9 2016/01/23 19:14:04 krw Exp $ */
+/* $OpenBSD: io.h,v 1.10 2016/01/23 22:55:23 krw Exp $ */
/*
* io.h - simple io and input parsing routines
@@ -30,16 +30,11 @@
#ifndef __io__
#define __io__
-
-#define MAXIOSIZE 2048
-
-extern const long kDefault;
-
void bad_input(const char *, ...);
void flush_to_newline(int);
int get_command(const char *, int, int *);
unsigned long get_multiplier(long);
-int get_number_argument(const char *, long *, long);
+int get_number_argument(const char *, long *);
int get_okay(const char *, int);
int get_partition_modifier(void);
int get_string_argument(const char *, char **);
diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c
index a6f48193f6c..8965f688ad6 100644
--- a/sbin/pdisk/pdisk.c
+++ b/sbin/pdisk/pdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pdisk.c,v 1.63 2016/01/23 19:14:04 krw Exp $ */
+/* $OpenBSD: pdisk.c,v 1.64 2016/01/23 22:55:23 krw Exp $ */
/*
* pdisk - an editor for Apple format partition tables
@@ -299,7 +299,7 @@ get_base_argument(long *number, struct partition_map_header * map)
struct partition_map *entry;
int result = 0;
- if (get_number_argument("First block: ", number, kDefault) == 0) {
+ if (get_number_argument("First block: ", number) == 0) {
bad_input("Bad block number");
} else {
result = 1;
@@ -324,7 +324,7 @@ get_size_argument(long *number, struct partition_map_header * map)
unsigned long multiple;
int result = 0;
- if (get_number_argument("Length in blocks: ", number, kDefault) == 0) {
+ if (get_number_argument("Length in blocks: ", number) == 0) {
bad_input("Bad length");
} else {
multiple = get_multiplier(map->logical_block);
@@ -360,7 +360,7 @@ do_rename_partition(struct partition_map_header * map)
bad_input("No partition map exists");
return;
}
- if (get_number_argument("Partition number: ", &ix, kDefault) == 0) {
+ if (get_number_argument("Partition number: ", &ix) == 0) {
bad_input("Bad partition number");
return;
}
@@ -392,7 +392,7 @@ do_change_type(struct partition_map_header * map)
bad_input("No partition map exists");
return;
}
- if (get_number_argument("Partition number: ", &ix, kDefault) == 0) {
+ if (get_number_argument("Partition number: ", &ix) == 0) {
bad_input("Bad partition number");
return;
}
@@ -426,7 +426,7 @@ do_delete_partition(struct partition_map_header * map)
bad_input("No partition map exists");
return;
}
- if (get_number_argument("Partition number: ", &ix, kDefault) == 0) {
+ if (get_number_argument("Partition number: ", &ix) == 0) {
bad_input("Bad partition number");
return;
}
@@ -449,12 +449,11 @@ do_reorder(struct partition_map_header * map)
bad_input("No partition map exists");
return;
}
- if (get_number_argument("Partition number: ", &old_index, kDefault) ==
- 0) {
+ if (get_number_argument("Partition number: ", &old_index) == 0) {
bad_input("Bad partition number");
return;
}
- if (get_number_argument("New number: ", &ix, kDefault) == 0) {
+ if (get_number_argument("New number: ", &ix) == 0) {
bad_input("Bad partition number");
return;
}
@@ -492,7 +491,7 @@ do_change_map_size(struct partition_map_header * map)
{
long size;
- if (get_number_argument("New size: ", &size, kDefault) == 0) {
+ if (get_number_argument("New size: ", &size) == 0) {
bad_input("Bad size");
return;
}
@@ -505,7 +504,7 @@ do_display_entry(struct partition_map_header * map)
{
long number;
- if (get_number_argument("Partition number: ", &number, kDefault) == 0) {
+ if (get_number_argument("Partition number: ", &number) == 0) {
bad_input("Bad partition number");
return;
}