summaryrefslogtreecommitdiffstats
path: root/sys-utils/eject.c
diff options
context:
space:
mode:
authorSami Kerola2015-02-22 15:41:39 +0100
committerKarel Zak2015-02-24 12:08:40 +0100
commit47d20536e08fd1daa7023a56d6e97ae09cb2ea1b (patch)
treecf1716f08e4a5b5701196b372db9621a566b73f7 /sys-utils/eject.c
parentlib/strutils: extend parse_switch() to accept more options (diff)
downloadkernel-qcow2-util-linux-47d20536e08fd1daa7023a56d6e97ae09cb2ea1b.tar.gz
kernel-qcow2-util-linux-47d20536e08fd1daa7023a56d6e97ae09cb2ea1b.tar.xz
kernel-qcow2-util-linux-47d20536e08fd1daa7023a56d6e97ae09cb2ea1b.zip
eject: use parse_switch()
[kzak@redhat.com: - use extended parse_switch()] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/eject.c')
-rw-r--r--sys-utils/eject.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index 4f7d6e651..008b4fe4e 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -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;