From: Sami Kerola Date: Fri, 15 Jun 2012 22:06:20 +0000 (+0200) Subject: wipefs: use exclusive_option() X-Git-Tag: v2.22-rc1~267^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58f0252a18f11f0b458845cedec43ee591ccabae;p=thirdparty%2Futil-linux.git wipefs: use exclusive_option() Signed-off-by: Sami Kerola --- 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);