Module: xenomai-3
Branch: master
Commit: 85110e10ea3a5965f46e55b53caa9fc60b751e91
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=85110e10ea3a5965f46e55b53caa9fc60b751e91

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Oct  4 17:36:48 2015 +0200

lib, utils: cleanup getopt_long option arrays

---

 lib/alchemy/init.c                |   11 ++---------
 lib/boilerplate/setup.c           |   15 ++++++++++-----
 lib/cobalt/init.c                 |   12 +++++-------
 lib/copperplate/init.c            |   12 ++++++------
 lib/copperplate/regd/regd.c       |   18 +++++++-----------
 lib/psos/init.c                   |    9 ++++-----
 lib/smokey/init.c                 |    9 +++++----
 lib/vxworks/init.c                |   11 ++---------
 utils/analogy/analogy_calibrate.c |   13 ++++---------
 utils/autotune/autotune.c         |   12 ++++++++----
 utils/corectl/corectl.c           |    4 +++-
 utils/hdb/hdb.c                   |    2 +-
 utils/slackspot/slackspot.c       |   31 +++++++------------------------
 13 files changed, 64 insertions(+), 95 deletions(-)

diff --git a/lib/alchemy/init.c b/lib/alchemy/init.c
index 14eb4d1..2efd138 100644
--- a/lib/alchemy/init.c
+++ b/lib/alchemy/init.c
@@ -49,16 +49,9 @@ static const struct option alchemy_options[] = {
        {
 #define clock_resolution_opt   0
                .name = "alchemy-clock-resolution",
-               .has_arg = 1,
-               .flag = NULL,
-               .val = 0
+               .has_arg = required_argument,
        },
-       {
-               .name = NULL,
-               .has_arg = 0,
-               .flag = NULL,
-               .val = 0
-       }
+       { /* Sentinel */ }
 };
 
 static int alchemy_parse_option(int optnum, const char *optarg)
diff --git a/lib/boilerplate/setup.c b/lib/boilerplate/setup.c
index 5273a5e..1cc66a7 100644
--- a/lib/boilerplate/setup.c
+++ b/lib/boilerplate/setup.c
@@ -56,55 +56,60 @@ static const struct option base_options[] = {
        {
 #define affinity_opt   1
                .name = "cpu-affinity",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define verbose_opt    2
                .name = "verbose",
-               .has_arg = 2,
+               .has_arg = optional_argument,
        },
        {
 #define silent_opt     3
                .name = "silent",
+               .has_arg = no_argument,
                .flag = &__base_setup_data.verbosity_level,
                .val = 0,
        },
        {
 #define quiet_opt      4
                .name = "quiet",
+               .has_arg = no_argument,
                .flag = &__base_setup_data.verbosity_level,
                .val = 0,
        },
        {
 #define version_opt    5
                .name = "version",
+               .has_arg = no_argument,
        },
        {
 #define dumpconfig_opt 6
                .name = "dump-config",
+               .has_arg = no_argument,
        },
        {
 #define no_sanity_opt  7
                .name = "no-sanity",
+               .has_arg = no_argument,
                .flag = &__base_setup_data.no_sanity,
                .val = 1
        },
        {
 #define sanity_opt     8
                .name = "sanity",
+               .has_arg = no_argument,
                .flag = &__base_setup_data.no_sanity,
        },
        {
 #define no_mlock_opt   9
 #ifdef CONFIG_XENO_MERCURY
                .name = "no-mlock",
+               .has_arg = no_argument,
                .flag = &__base_setup_data.no_mlock,
                .val = 1
 #endif
        },
-       {
-               /* sentinel */
-       }
+       { /* Sentinel */ }
 };
 
 void __weak application_version(void)
diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c
index 9d1674d..3e88d06 100644
--- a/lib/cobalt/init.c
+++ b/lib/cobalt/init.c
@@ -56,26 +56,24 @@ static const struct option cobalt_options[] = {
        {
 #define main_prio_opt          0
                .name = "main-prio",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define print_bufsz_opt        1
                .name = "print-buffer-size",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define print_bufcnt_opt       2
                .name = "print-buffer-count",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define print_syncdelay_opt    3
                .name = "print-sync-delay",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
-       {
-               /* sentinel */
-       }
+       { /* Sentinel */ }
 };
 
 static void sigill_handler(int sig)
diff --git a/lib/copperplate/init.c b/lib/copperplate/init.c
index f12bffc..3ce4584 100644
--- a/lib/copperplate/init.c
+++ b/lib/copperplate/init.c
@@ -51,33 +51,33 @@ static const struct option copperplate_options[] = {
        {
 #define mempool_opt    0
                .name = "mem-pool-size",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define regroot_opt    1
                .name = "registry-root",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define no_registry_opt        2
                .name = "no-registry",
+               .has_arg = no_argument,
                .flag = &__copperplate_setup_data.no_registry,
                .val = 1
        },
        {
 #define session_opt    3
                .name = "session",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define shared_registry_opt    4
                .name = "shared-registry",
+               .has_arg = no_argument,
                .flag = &__copperplate_setup_data.shared_registry,
                .val = 1,
        },
-       {
-               /* sentinel */
-       }
+       { /* Sentinel */ }
 };
 
 /*
diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c
index 01ecc60..25bd7a5 100644
--- a/lib/copperplate/regd/regd.c
+++ b/lib/copperplate/regd/regd.c
@@ -80,46 +80,42 @@ static const struct option options[] = {
        {
 #define help_opt       0
                .name = "help",
-               .has_arg = 0,
-               .flag = NULL,
+               .has_arg = no_argument,
        },
        {
 #define daemonize_opt  1
                .name = "daemonize",
-               .has_arg = 0,
+               .has_arg = no_argument,
                .flag = &daemonize,
                .val = 1,
        },
        {
 #define root_opt       2
                .name = "root",
-               .has_arg = 1,
-               .flag = NULL,
+               .has_arg = required_argument,
        },
        {
 #define linger_opt     3
                .name = "linger",
-               .has_arg = 0,
+               .has_arg = no_argument,
                .flag = &linger,
                .val = 1,
        },
        {
 #define shared_opt     4
                .name = "shared",
-               .has_arg = 0,
+               .has_arg = no_argument,
                .flag = &shared,
                .val = 1,
        },
        {
 #define anon_opt       5
                .name = "anon",
-               .has_arg = 0,
+               .has_arg = no_argument,
                .flag = &anon,
                .val = 1,
        },
-       {
-               .name = NULL,
-       },
+       { /* Sentinel */ },
 };
 
 static int create_directory_recursive(const char *dir) /* absolute path */
diff --git a/lib/psos/init.c b/lib/psos/init.c
index 9e0b8fd..307594e 100644
--- a/lib/psos/init.c
+++ b/lib/psos/init.c
@@ -56,22 +56,21 @@ static const struct option psos_options[] = {
        {
 #define clock_resolution_opt   0
                .name = "psos-clock-resolution",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define time_slice_opt 1
                .name = "psos-time-slice",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define long_names_opt 2
                .name = "psos-long-names",
+               .has_arg = no_argument,
                .flag = &psos_long_names,
                .val = 1
        },
-       {
-               /* sentinel */
-       }
+       { /* Sentinel */ }
 };
 
 static int psos_parse_option(int optnum, const char *optarg)
diff --git a/lib/smokey/init.c b/lib/smokey/init.c
index e98f9a0..403aa72 100644
--- a/lib/smokey/init.c
+++ b/lib/smokey/init.c
@@ -270,29 +270,30 @@ static const struct option smokey_options[] = {
        {
 #define keep_going_opt 0
                .name = "keep-going",
+               .has_arg = no_argument,
                .flag = &smokey_keep_going,
                .val = 1,
        },
        {
 #define run_opt                1
                .name = "run",
-               .has_arg = 2,
+               .has_arg = optional_argument,
        },
        {
 #define list_opt       2
                .name = "list",
+               .has_arg = no_argument,
                .flag = &do_list,
                .val = 1,
        },
        {
 #define vm_opt         3
                .name = "vm",
+               .has_arg = no_argument,
                .flag = &smokey_on_vm,
                .val = 1,
        },
-       {
-               /* sentinel */
-       }
+       { /* Sentinel */ }
 };
 
 static void smokey_help(void)
diff --git a/lib/vxworks/init.c b/lib/vxworks/init.c
index 7f1b487..9a3dcc4 100644
--- a/lib/vxworks/init.c
+++ b/lib/vxworks/init.c
@@ -46,16 +46,9 @@ static const struct option vxworks_options[] = {
        {
 #define clock_resolution_opt   0
                .name = "vxworks-clock-resolution",
-               .has_arg = 1,
-               .flag = NULL,
-               .val = 0
+               .has_arg = required_argument,
        },
-       {
-               .name = NULL,
-               .has_arg = 0,
-               .flag = NULL,
-               .val = 0
-       }
+       { /* Sentinel */ }
 };
 
 static int vxworks_parse_option(int optnum, const char *optarg)
diff --git a/utils/analogy/analogy_calibrate.c 
b/utils/analogy/analogy_calibrate.c
index fe2883d..c5990a7 100644
--- a/utils/analogy/analogy_calibrate.c
+++ b/utils/analogy/analogy_calibrate.c
@@ -37,24 +37,19 @@ static const struct option options[] = {
        {
 #define help_opt       0
                .name = "help",
-               .has_arg = 0,
-               .flag = NULL,
+               .has_arg = no_argument,
        },
        {
 #define device_opt     1
                .name = "device",
-               .has_arg = 1,
-               .flag = NULL,
+               .has_arg = required_argument,
        },
        {
 #define output_opt     2
                .name = "output",
-               .has_arg = 1,
-               .flag = NULL,
+               .has_arg = required_argument,
        },
-       {
-               .name = NULL,
-       }
+       { /* Sentinel */ }
 };
 
 static void
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index cc97aa6..5c3e0fe 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -42,47 +42,51 @@ static const struct option base_options[] = {
        {
 #define irq_opt                0
                .name = "irq",
+               .has_arg = no_argument,
                .flag = &tune_irqlat,
                .val = 1
        },
        {
 #define kernel_opt     1
                .name = "kernel",
+               .has_arg = no_argument,
                .flag = &tune_kernlat,
                .val = 1
        },
        {
 #define user_opt       2
                .name = "user",
+               .has_arg = no_argument,
                .flag = &tune_userlat,
                .val = 1
        },
        {
 #define reset_opt      3
                .name = "reset",
+               .has_arg = no_argument,
                .flag = &reset,
                .val = 1
        },
        {
 #define noload_opt     4
                .name = "noload",
+               .has_arg = no_argument,
                .flag = &noload,
                .val = 1
        },
        {
 #define period_opt     5
                .name = "period",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        {
 #define background_opt 6
                .name = "background",
+               .has_arg = no_argument,
                .flag = &background,
                .val = 1,
        },
-       {
-               .name = NULL,
-       }
+       { /* Sentinel */ }
 };
 
 static void *sampler_thread(void *arg)
diff --git a/utils/corectl/corectl.c b/utils/corectl/corectl.c
index e1d1f17..1e82e99 100644
--- a/utils/corectl/corectl.c
+++ b/utils/corectl/corectl.c
@@ -33,19 +33,21 @@ static const struct option options[] = {
        {
 #define status_opt     0       /* Set this first, default action. */
                .name = "status",
+               .has_arg = no_argument,
                .flag = &action,
                .val = status_opt,
        },
        {
 #define stop_opt       1
                .name = "stop",
+               .has_arg = optional_argument,
                .flag = &action,
                .val = stop_opt,
-               .has_arg = 2,
        },
        {
 #define start_opt      2
                .name = "start",
+               .has_arg = no_argument,
                .flag = &action,
                .val = start_opt,
        },
diff --git a/utils/hdb/hdb.c b/utils/hdb/hdb.c
index 10ee1a9..1ecce6e 100644
--- a/utils/hdb/hdb.c
+++ b/utils/hdb/hdb.c
@@ -31,7 +31,7 @@ static const struct option options[] = {
        {
 #define dump_cluster_opt       0
                .name = "dump-cluster",
-               .has_arg = 1,
+               .has_arg = required_argument,
        },
        { /* Sentinel */ }
 };
diff --git a/utils/slackspot/slackspot.c b/utils/slackspot/slackspot.c
index 45151a2..4c3c4ab 100644
--- a/utils/slackspot/slackspot.c
+++ b/utils/slackspot/slackspot.c
@@ -39,51 +39,34 @@ static const struct option base_options[] = {
        {
 #define help_opt       0
                .name = "help",
-               .has_arg = 0,
-               .flag = NULL,
-               .val = 0
+               .has_arg = no_argument,
        },
 #define file_opt       1
        {
                .name = "file",
-               .has_arg = 1,
-               .flag = NULL,
-               .val = 0
+               .has_arg = required_argument,
        },
 #define path_opt       2
        {
                .name = "path",
-               .has_arg = 1,
-               .flag = NULL,
-               .val = 0
+               .has_arg = required_argument,
        },
 #define filter_opt     3       /* Alias for filter-in */
        {
                .name = "filter",
-               .has_arg = 1,
-               .flag = NULL,
-               .val = 0
+               .has_arg = required_argument,
        },
 #define filter_in_opt  4
        {
                .name = "filter-in",
-               .has_arg = 1,
-               .flag = NULL,
-               .val = 0
+               .has_arg = required_argument,
        },
 #define filter_out_opt 5       /* Alias for !filter-in */
        {
                .name = "filter-out",
-               .has_arg = 1,
-               .flag = NULL,
-               .val = 0
+               .has_arg = required_argument,
        },
-       {
-               .name = NULL,
-               .has_arg = 0,
-               .flag = NULL,
-               .val = 0
-       }
+       { /* Sentinel */ }
 };
 
 struct relax_spot;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to