]> git.ozlabs.org Git - ccan/commitdiff
opt: remove gratuitous { } in initializers.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 7 Oct 2010 03:35:20 +0000 (14:05 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 7 Oct 2010 03:35:20 +0000 (14:05 +1030)
A little less typing for users.

ccan/opt/opt.h
ccan/opt/test/utils.c

index 89fa77ed37a7a6d06d3a271376659733d106178d..879833652d320cd1f4e0fd67d0dea3521f78a5fc 100644 (file)
@@ -48,7 +48,7 @@ struct opt_table {
  *     OPT_WITH_ARG()
  */
 #define OPT_WITHOUT_ARG(names, cb, arg, desc)  \
-       (names), OPT_CB_NOARG((cb), (arg)), (desc)
+       { (names), OPT_CB_NOARG((cb), (arg)), (desc) }
 
 /**
  * OPT_WITH_ARG() - macro for initializing long and short option (with arg)
@@ -83,7 +83,7 @@ struct opt_table {
  *     OPT_WITHOUT_ARG()
  */
 #define OPT_WITH_ARG(name, cb, show, arg, desc)        \
-       (name), OPT_CB_ARG((cb), (show), (arg)), (desc)
+       { (name), OPT_CB_ARG((cb), (show), (arg)), (desc) }
 
 /**
  * OPT_SUBTABLE() - macro for including another table inside a table.
@@ -111,13 +111,13 @@ struct opt_table {
  * Example:
  * static int verbose = 0;
  * static struct opt_table opts[] = {
- *     OPT_WITHOUT_ARG("--verbose", opt_inc_intval, &verbose,
- *       "Verbose mode (can be specified more than once)") },
- *     OPT_WITHOUT_ARG("-v", opt_inc_intval, &verbose,
- *       "Verbose mode (can be specified more than once)") },
- *     OPT_WITHOUT_ARG("--usage", opt_usage_and_exit,
- *                       "args...\nA silly test program.",
- *       "Print this message.") },
+ *     OPT_WITHOUT_ARG("--verbose", opt_inc_intval, &verbose,
+ *                     "Verbose mode (can be specified more than once)"),
+ *     OPT_WITHOUT_ARG("-v", opt_inc_intval, &verbose,
+ *                     "Verbose mode (can be specified more than once)"),
+ *     OPT_WITHOUT_ARG("--usage", opt_usage_and_exit,
+ *                     "args...\nA silly test program.",
+ *                     "Print this message."),
  *     OPT_ENDTABLE
  * };
  *
index 4e5b4d77a310c1b2bf9476d43f1de6be4d226b56..2a310495fba5cd96eff4d45c8a96446430a0e7c6 100644 (file)
@@ -70,33 +70,31 @@ bool parse_args(int *argc, char ***argv, ...)
 
 struct opt_table short_table[] = {
        /* Short opts, different args. */
-       { OPT_WITHOUT_ARG("-a", test_noarg, "a", "Description of a") },
-       { OPT_WITH_ARG("-b", test_arg, show_arg, "b", "Description of b") },
+       OPT_WITHOUT_ARG("-a", test_noarg, "a", "Description of a"),
+       OPT_WITH_ARG("-b", test_arg, show_arg, "b", "Description of b"),
        OPT_ENDTABLE
 };
 
 struct opt_table long_table[] = {
        /* Long opts, different args. */
-       { OPT_WITHOUT_ARG("--ddd", test_noarg, "ddd", "Description of ddd") },
-       { OPT_WITH_ARG("--eee <filename>", test_arg, show_arg, "eee", "") },
+       OPT_WITHOUT_ARG("--ddd", test_noarg, "ddd", "Description of ddd"),
+       OPT_WITH_ARG("--eee <filename>", test_arg, show_arg, "eee", ""),
        OPT_ENDTABLE
 };
 
 struct opt_table long_and_short_table[] = {
        /* Short and long, different args. */
-       { OPT_WITHOUT_ARG("--ggg/-g", test_noarg, "ggg",
-                         "Description of ggg") },
-       { OPT_WITH_ARG("-h/--hhh", test_arg, NULL, "hhh",
-                      "Description of hhh") },
+       OPT_WITHOUT_ARG("--ggg/-g", test_noarg, "ggg", "Description of ggg"),
+       OPT_WITH_ARG("-h/--hhh", test_arg, NULL, "hhh", "Description of hhh"),
        OPT_ENDTABLE
 };
 
 /* Sub-table test. */
 struct opt_table subtables[] = {
        /* Two short, and two long long, no description */
-       { OPT_WITH_ARG("--jjj/-j/--lll/-l", test_arg, show_arg, "jjj", "") },
+       OPT_WITH_ARG("--jjj/-j/--lll/-l", test_arg, show_arg, "jjj", ""),
        /* Hidden option */
-       { OPT_WITH_ARG("--mmm/-m", test_arg, show_arg, "mmm", opt_hidden) },
+       OPT_WITH_ARG("--mmm/-m", test_arg, show_arg, "mmm", opt_hidden),
        OPT_SUBTABLE(short_table, NULL),
        OPT_SUBTABLE(long_table, "long table options"),
        OPT_SUBTABLE(long_and_short_table, NULL),