From 58f0252a18f11f0b458845cedec43ee591ccabae Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 16 Jun 2012 00:06:20 +0200 Subject: [PATCH] wipefs: use exclusive_option() Signed-off-by: Sami Kerola --- misc-utils/wipefs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index 259ca3766c..f10b5ee4e2 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -39,6 +39,7 @@ #include "match.h" #include "c.h" #include "closestream.h" +#include "optutils.h" struct wipe_desc { loff_t offset; /* magic string offset */ @@ -382,6 +383,13 @@ main(int argc, char **argv) int c, all = 0, has_offset = 0, noact = 0, quiet = 0; int mode = WP_MODE_PRETTY; + enum { + EXCL_NONE, + EXCL_ALL, + EXCL_OFFSET + }; + int excl_any = EXCL_NONE; + static const struct option longopts[] = { { "all", 0, 0, 'a' }, { "help", 0, 0, 'h' }, @@ -402,6 +410,7 @@ main(int argc, char **argv) while ((c = getopt_long(argc, argv, "ahno:pqt:V", longopts, NULL)) != -1) { switch(c) { case 'a': + exclusive_option(&excl_any, EXCL_ALL, "--{all,offset}"); all++; break; case 'h': @@ -411,6 +420,7 @@ main(int argc, char **argv) noact++; break; case 'o': + exclusive_option(&excl_any, EXCL_OFFSET, "--{all,offset}"); wp0 = add_offset(wp0, strtosize_or_err(optarg, _("invalid offset argument")), 1); has_offset++; @@ -434,9 +444,6 @@ main(int argc, char **argv) } } - if (wp0 && all) - errx(EXIT_FAILURE, _("--offset and --all are mutually exclusive")); - if (optind == argc) usage(stderr); -- 2.47.3