summaryrefslogtreecommitdiffstats
path: root/sys-utils/chcpu.c
diff options
context:
space:
mode:
authorKarel Zak2012-07-26 09:25:19 +0200
committerKarel Zak2012-07-26 09:25:19 +0200
commit20da61dc8b160922ee4e3913aed2ae3f48591cfc (patch)
tree1d1df2e3631d34446c5987ea41d88f8f82421b79 /sys-utils/chcpu.c
parentwipefs: use err_exclusive_options() (diff)
downloadkernel-qcow2-util-linux-20da61dc8b160922ee4e3913aed2ae3f48591cfc.tar.gz
kernel-qcow2-util-linux-20da61dc8b160922ee4e3913aed2ae3f48591cfc.tar.xz
kernel-qcow2-util-linux-20da61dc8b160922ee4e3913aed2ae3f48591cfc.zip
chcpu: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/chcpu.c')
-rw-r--r--sys-utils/chcpu.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/sys-utils/chcpu.c b/sys-utils/chcpu.c
index 523e9c566..0209fe9bf 100644
--- a/sys-utils/chcpu.c
+++ b/sys-utils/chcpu.c
@@ -235,16 +235,6 @@ int main(int argc, char *argv[])
int cmd = -1;
int c;
- enum {
- EXCL_NONE,
- EXCL_CONFIGURE,
- EXCL_DECONFIGURE,
- EXCL_DISABLE,
- EXCL_DISPATCH,
- EXCL_ENABLE
- };
- int excl_any = EXCL_NONE;
-
static const struct option longopts[] = {
{ "configure", required_argument, 0, 'c' },
{ "deconfigure",required_argument, 0, 'g' },
@@ -257,6 +247,12 @@ int main(int argc, char *argv[])
{ NULL, 0, 0, 0 }
};
+ static const ul_excl_t excl[] = { /* rows and cols in in ASCII order */
+ { 'c','d','e','g','p' },
+ { 0 }
+ };
+ int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
+
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@@ -273,31 +269,29 @@ int main(int argc, char *argv[])
err(EXIT_FAILURE, _("cpuset_alloc failed"));
while ((c = getopt_long(argc, argv, "c:d:e:g:hp:rV", longopts, NULL)) != -1) {
+
+ err_exclusive_options(c, longopts, excl, excl_st);
+
switch (c) {
case 'c':
- exclusive_option(&excl_any, EXCL_CONFIGURE, EXCL_ERROR);
cmd = CMD_CPU_CONFIGURE;
cpu_parse(argv[optind - 1], cpu_set, setsize);
break;
case 'd':
- exclusive_option(&excl_any, EXCL_DISABLE, EXCL_ERROR);
cmd = CMD_CPU_DISABLE;
cpu_parse(argv[optind - 1], cpu_set, setsize);
break;
case 'e':
- exclusive_option(&excl_any, EXCL_ENABLE, EXCL_ERROR);
cmd = CMD_CPU_ENABLE;
cpu_parse(argv[optind - 1], cpu_set, setsize);
break;
case 'g':
- exclusive_option(&excl_any, EXCL_DECONFIGURE, EXCL_ERROR);
cmd = CMD_CPU_DECONFIGURE;
cpu_parse(argv[optind - 1], cpu_set, setsize);
break;
case 'h':
usage(stdout);
case 'p':
- exclusive_option(&excl_any, EXCL_DISPATCH, EXCL_ERROR);
if (strcmp("horizontal", argv[optind - 1]) == 0)
cmd = CMD_CPU_DISPATCH_HORIZONTAL;
else if (strcmp("vertical", argv[optind - 1]) == 0)