]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
eject: use parse_switch()
authorSami Kerola <kerolasa@iki.fi>
Sun, 22 Feb 2015 14:41:39 +0000 (14:41 +0000)
committerKarel Zak <kzak@redhat.com>
Tue, 24 Feb 2015 11:08:40 +0000 (12:08 +0100)
[kzak@redhat.com: - use extended parse_switch()]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/eject.c

index 4f7d6e6514d817e9cdae120fc1f31cbf353e7ac0..008b4fe4e6fe86d7f48b7988d42234946d06504b 100644 (file)
@@ -202,12 +202,8 @@ static void parse_args(struct eject_control *ctl, int argc, char **argv)
                switch (c) {
                case 'a':
                        ctl->a_option = 1;
-                       if (!strcmp(optarg, "0") || !strcmp(optarg, "off"))
-                               ctl->a_arg = 0;
-                       else if (!strcmp(optarg, "1") || !strcmp(optarg, "on"))
-                               ctl->a_arg = 1;
-                       else
-                               errx(EXIT_FAILURE, _("invalid argument to --auto/-a option"));
+                       ctl->a_arg = parse_switch(optarg, _("argument error"),
+                                               "on", "off",  "1", "0",  NULL);
                        break;
                case 'c':
                        ctl->c_option = 1;
@@ -231,12 +227,8 @@ static void parse_args(struct eject_control *ctl, int argc, char **argv)
                        break;
                case 'i':
                        ctl->i_option = 1;
-                       if (!strcmp(optarg, "0") || !strcmp(optarg, "off"))
-                               ctl->i_arg = 0;
-                       else if (!strcmp(optarg, "1") || !strcmp(optarg, "on"))
-                               ctl->i_arg = 1;
-                       else
-                               errx(EXIT_FAILURE, _("invalid argument to --manualeject/-i option"));
+                       ctl->i_arg = parse_switch(optarg, _("argument error"),
+                                               "on", "off",  "1", "0",  NULL);
                        break;
                case 'm':
                        ctl->m_option = 1;