diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-18 00:19:30 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-18 00:19:30 +0000 |
commit | f19703a3fcbc68b9d4d7192d994bae6183815ff1 (patch) | |
tree | 95b4167eeab2a49d54b897b4cecd0bd9fb6749c9 | |
parent | 8d008094dddfee2b86239c4466fb332eda3e5452 (diff) |
Fold get_options() into main() and eliminate unneeded nFLAG_DEFAULT
#defines. Zero is a well known and acceptable number.
-rw-r--r-- | sbin/pdisk/pdisk.c | 67 |
1 files changed, 23 insertions, 44 deletions
diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c index da3e3a1a420..fa9ed91c840 100644 --- a/sbin/pdisk/pdisk.c +++ b/sbin/pdisk/pdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pdisk.c,v 1.45 2016/01/18 00:04:36 krw Exp $ */ +/* $OpenBSD: pdisk.c,v 1.46 2016/01/18 00:19:29 krw Exp $ */ /* * pdisk - an editor for Apple format partition tables @@ -45,13 +45,9 @@ #include "validate.h" #include "file_media.h" -#define DFLAG_DEFAULT 0 -#define LFLAG_DEFAULT 0 -#define RFLAG_DEFAULT 0 - -int lflag = LFLAG_DEFAULT; /* list the device */ -int dflag = DFLAG_DEFAULT; /* turn on debugging commands and printout */ -int rflag = RFLAG_DEFAULT; /* open device read Only */ +int lflag; /* list the device */ +int dflag; /* turn on debugging commands and printout */ +int rflag; /* open device read Only */ static int first_get = 1; @@ -70,7 +66,6 @@ void edit(char *); int get_base_argument(long *, struct partition_map_header *); int get_command_line(int *, char ***); int get_size_argument(long *, struct partition_map_header *); -int get_options(int, char **); void print_edit_notes(void); void print_expert_notes(void); @@ -79,7 +74,7 @@ __dead static void usage(void); int main(int argc, char **argv) { - int name_index; + int c, name_index; if (sizeof(struct dpme) != DEV_BSIZE) { errx(1, "Size of partition map entry (%zu) " @@ -92,7 +87,24 @@ main(int argc, char **argv) sizeof(struct block0), DEV_BSIZE); } - name_index = get_options(argc, argv); + while ((c = getopt(argc, argv, "ldr")) != -1) { + switch (c) { + case 'l': + lflag = 1; + break; + case 'd': + dflag = 1; + break; + case 'r': + rflag = 1; + break; + default: + usage(); + break; + } + } + + name_index = optind; if (lflag) { if (name_index < argc) { @@ -113,39 +125,6 @@ main(int argc, char **argv) } -int -get_options(int argc, char **argv) -{ - int c; - extern int optind; - extern char *optarg; - - lflag = LFLAG_DEFAULT; - dflag = DFLAG_DEFAULT; - rflag = RFLAG_DEFAULT; - - optind = 1; /* reset option scanner logic */ - while ((c = getopt(argc, argv, "ldr")) != -1) { - switch (c) { - case 'l': - lflag = (LFLAG_DEFAULT)?0:1; - break; - case 'd': - dflag = (DFLAG_DEFAULT)?0:1; - break; - case 'r': - rflag = (RFLAG_DEFAULT)?0:1; - break; - default: - usage(); - break; - } - } - - return optind; -} - - void print_edit_notes() { |