[ovs-dev] [PATCH 2/3] command-line: add ovs_cmdl_ prefix

Russell Bryant rbryant at redhat.com
Mon Mar 16 16:01:55 UTC 2015


The coding style guidelines include the following:

  - Pick a unique name prefix (ending with an underscore) for each
    module, and apply that prefix to all of that module's externally
    visible names.  Names of macro parameters, struct and union members,
    and parameters in function prototypes are not considered externally
    visible for this purpose.

This patch adds the new prefix to the externally visible names.  This
makes it a bit more obvious what code is coming from common command
line handling code.

Signed-off-by: Russell Bryant <rbryant at redhat.com>
---
 lib/command-line.c                  | 26 +++++++++++++-------------
 lib/command-line.h                  | 18 +++++++++---------
 lib/daemon-unix.c                   |  6 +++---
 ovsdb/ovsdb-client.c                |  4 ++--
 ovsdb/ovsdb-server.c                |  4 ++--
 ovsdb/ovsdb-tool.c                  | 14 +++++++-------
 tests/ovstest.c                     | 14 +++++++-------
 tests/test-bitmap.c                 |  4 ++--
 tests/test-classifier.c             |  4 ++--
 tests/test-cmap.c                   |  4 ++--
 tests/test-heap.c                   |  4 ++--
 tests/test-jsonrpc.c                | 12 ++++++------
 tests/test-netflow.c                |  4 ++--
 tests/test-ovsdb.c                  | 14 +++++++-------
 tests/test-reconnect.c              |  8 ++++----
 tests/test-sflow.c                  |  4 ++--
 tests/test-util.c                   |  6 +++---
 tests/test-vconn.c                  |  4 ++--
 utilities/ovs-appctl.c              |  4 ++--
 utilities/ovs-benchmark.c           | 10 +++++-----
 utilities/ovs-dpctl.c               |  4 ++--
 utilities/ovs-ofctl.c               | 14 +++++++-------
 utilities/ovs-testcontroller.c      |  4 ++--
 utilities/ovs-vlan-bug-workaround.c |  2 +-
 utilities/ovs-vsctl.c               |  2 +-
 vswitchd/ovs-vswitchd.c             |  4 ++--
 vtep/vtep-ctl.c                     |  2 +-
 27 files changed, 100 insertions(+), 100 deletions(-)

diff --git a/lib/command-line.c b/lib/command-line.c
index 2eccdc6..d9cec0d 100644
--- a/lib/command-line.c
+++ b/lib/command-line.c
@@ -30,7 +30,7 @@ VLOG_DEFINE_THIS_MODULE(command_line);
  * passed to getopt() with the corresponding short options.  The caller is
  * responsible for freeing the string. */
 char *
-long_options_to_short_options(const struct option options[])
+ovs_cmdl_long_options_to_short_options(const struct option options[])
 {
     char short_options[UCHAR_MAX * 3 + 1];
     char *p = short_options;
@@ -52,15 +52,15 @@ long_options_to_short_options(const struct option options[])
     return xstrdup(short_options);
 }
 
-/* Given the 'struct command' array, prints the usage of all commands. */
+/* Given the 'struct ovs_cmdl_command' array, prints the usage of all commands. */
 void
-print_commands(const struct command commands[])
+ovs_cmdl_print_commands(const struct ovs_cmdl_command commands[])
 {
     struct ds ds = DS_EMPTY_INITIALIZER;
 
     ds_put_cstr(&ds, "The available commands are:\n");
     for (; commands->name; commands++) {
-        const struct command *c = commands;
+        const struct ovs_cmdl_command *c = commands;
         ds_put_format(&ds, "  %-23s %s\n", c->name, c->usage ? c->usage : "");
     }
     printf("%s", ds.string);
@@ -69,7 +69,7 @@ print_commands(const struct command commands[])
 
 /* Given the GNU-style options in 'options', prints all options. */
 void
-print_options(const struct option options[])
+ovs_cmdl_print_options(const struct option options[])
 {
     struct ds ds = DS_EMPTY_INITIALIZER;
 
@@ -94,9 +94,9 @@ print_options(const struct option options[])
  * Command-line options should be stripped off, so that a typical invocation
  * looks like "run_command(argc - optind, argv + optind, my_commands);". */
 void
-run_command(int argc, char *argv[], const struct command commands[])
+ovs_cmdl_run_command(int argc, char *argv[], const struct ovs_cmdl_command commands[])
 {
-    const struct command *p;
+    const struct ovs_cmdl_command *p;
 
     if (argc < 1) {
         ovs_fatal(0, "missing command name; use --help for help");
@@ -150,7 +150,7 @@ static char *saved_proctitle OVS_GUARDED_BY(proctitle_mutex);
  * before anything else, period, at the very beginning of program
  * execution.  */
 void
-proctitle_init(int argc, char **argv)
+ovs_cmdl_proctitle_init(int argc, char **argv)
 {
     int i;
 
@@ -190,7 +190,7 @@ proctitle_init(int argc, char **argv)
 /* Changes the name of the process, as shown by "ps", to the program name
  * followed by 'format', which is formatted as if by printf(). */
 void
-proctitle_set(const char *format, ...)
+ovs_cmdl_proctitle_set(const char *format, ...)
 {
     va_list args;
     int n;
@@ -225,7 +225,7 @@ out:
 
 /* Restores the process's original command line, as seen by "ps". */
 void
-proctitle_restore(void)
+ovs_cmdl_proctitle_restore(void)
 {
     ovs_mutex_lock(&proctitle_mutex);
     if (saved_proctitle) {
@@ -239,20 +239,20 @@ proctitle_restore(void)
 /* Stubs that don't do anything on non-Linux systems. */
 
 void
-proctitle_init(int argc OVS_UNUSED, char **argv OVS_UNUSED)
+ovs_cmdl_proctitle_init(int argc OVS_UNUSED, char **argv OVS_UNUSED)
 {
 }
 
 #if !(defined(__FreeBSD__) || defined(__NetBSD__))
 /* On these platforms we #define this to setproctitle. */
 void
-proctitle_set(const char *format OVS_UNUSED, ...)
+ovs_cmdl_proctitle_set(const char *format OVS_UNUSED, ...)
 {
 }
 #endif
 
 void
-proctitle_restore(void)
+ovs_cmdl_proctitle_restore(void)
 {
 }
 #endif  /* !__linux__ */
diff --git a/lib/command-line.h b/lib/command-line.h
index 7e68504..b6da205 100644
--- a/lib/command-line.h
+++ b/lib/command-line.h
@@ -23,7 +23,7 @@
 
 struct option;
 
-struct command {
+struct ovs_cmdl_command {
     const char *name;
     const char *usage;
     int min_args;
@@ -31,18 +31,18 @@ struct command {
     void (*handler)(int argc, char *argv[]);
 };
 
-char *long_options_to_short_options(const struct option *options);
-void print_options(const struct option *options);
-void print_commands(const struct command *commands);
-void run_command(int argc, char *argv[], const struct command[]);
+char *ovs_cmdl_long_options_to_short_options(const struct option *options);
+void ovs_cmdl_print_options(const struct option *options);
+void ovs_cmdl_print_commands(const struct ovs_cmdl_command *commands);
+void ovs_cmdl_run_command(int argc, char *argv[], const struct ovs_cmdl_command[]);
 
-void proctitle_init(int argc, char **argv);
+void ovs_cmdl_proctitle_init(int argc, char **argv);
 #if defined(__FreeBSD__) || defined(__NetBSD__)
-#define proctitle_set setproctitle
+#define ovs_cmdl_proctitle_set setproctitle
 #else
-void proctitle_set(const char *, ...)
+void ovs_cmdl_proctitle_set(const char *, ...)
     OVS_PRINTF_FORMAT(1, 2);
 #endif
-void proctitle_restore(void);
+void ovs_cmdl_proctitle_restore(void);
 
 #endif /* command-line.h */
diff --git a/lib/daemon-unix.c b/lib/daemon-unix.c
index 3b24fca..eb95521 100644
--- a/lib/daemon-unix.c
+++ b/lib/daemon-unix.c
@@ -332,8 +332,8 @@ monitor_daemon(pid_t daemon_pid)
         int retval;
         int status;
 
-        proctitle_set("monitoring pid %lu (%s)",
-                      (unsigned long int) daemon_pid, status_msg);
+        ovs_cmdl_proctitle_set("monitoring pid %lu (%s)",
+                               (unsigned long int) daemon_pid, status_msg);
 
         if (child_ready) {
             do {
@@ -399,7 +399,7 @@ monitor_daemon(pid_t daemon_pid)
     free(status_msg);
 
     /* Running in new daemon process. */
-    proctitle_restore();
+    ovs_cmdl_proctitle_restore();
     set_subprogram_name("");
 }
 
diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index e3b08c7..575cf91 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -86,7 +86,7 @@ main(int argc, char *argv[])
     const char *database;
     struct jsonrpc *rpc;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     parse_options(argc, argv);
     fatal_ignore_sigpipe();
@@ -183,7 +183,7 @@ parse_options(int argc, char *argv[])
         TABLE_LONG_OPTIONS,
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         int c;
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index d5277b1..deb2b8b 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -211,7 +211,7 @@ main(int argc, char *argv[])
     char *error;
     int i;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     service_start(&argc, &argv);
     fatal_ignore_sigpipe();
@@ -1242,7 +1242,7 @@ parse_options(int *argcp, char **argvp[],
         {"ca-cert",     required_argument, NULL, 'C'},
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
     int argc = *argcp;
     char **argv = *argvp;
 
diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c
index 1711665..f648707 100644
--- a/ovsdb/ovsdb-tool.c
+++ b/ovsdb/ovsdb-tool.c
@@ -44,7 +44,7 @@
 /* -m, --more: Verbosity level for "show-log" command output. */
 static int show_log_verbosity;
 
-static const struct command *get_all_commands(void);
+static const struct ovs_cmdl_command *get_all_commands(void);
 
 OVS_NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
@@ -58,7 +58,7 @@ main(int argc, char *argv[])
     set_program_name(argv[0]);
     parse_options(argc, argv);
     fatal_ignore_sigpipe();
-    run_command(argc - optind, argv + optind, get_all_commands());
+    ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
     return 0;
 }
 
@@ -73,7 +73,7 @@ parse_options(int argc, char *argv[])
         {"version", no_argument, NULL, 'V'},
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         int c;
@@ -92,7 +92,7 @@ parse_options(int argc, char *argv[])
             usage();
 
         case 'o':
-            print_options(long_options);
+            ovs_cmdl_print_options(long_options);
             exit(EXIT_SUCCESS);
 
         case 'V':
@@ -566,10 +566,10 @@ do_help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 static void
 do_list_commands(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 {
-     print_commands(get_all_commands());
+     ovs_cmdl_print_commands(get_all_commands());
 }
 
-static const struct command all_commands[] = {
+static const struct ovs_cmdl_command all_commands[] = {
     { "create", "[db [schema]]", 0, 2, do_create },
     { "compact", "[db [dst]]", 0, 2, do_compact },
     { "convert", "[db [schema [dst]]]", 0, 3, do_convert },
@@ -586,7 +586,7 @@ static const struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static const struct command *get_all_commands(void)
+static const struct ovs_cmdl_command *get_all_commands(void)
 {
     return all_commands;
 }
diff --git a/tests/ovstest.c b/tests/ovstest.c
index 5e985ae..f05da05 100644
--- a/tests/ovstest.c
+++ b/tests/ovstest.c
@@ -26,14 +26,14 @@
 #include "ovstest.h"
 #include "util.h"
 
-static struct command *commands = NULL;
+static struct ovs_cmdl_command *commands = NULL;
 static size_t n_commands = 0;
 static size_t allocated_commands = 0;
 
 static void
-add_command(struct command *cmd)
+add_command(struct ovs_cmdl_command *cmd)
 {
-    const struct command nil = {NULL, NULL, 0, 0, NULL};
+    const struct ovs_cmdl_command nil = {NULL, NULL, 0, 0, NULL};
 
     while (n_commands + 1 >= allocated_commands) {
         commands = x2nrealloc(commands, &allocated_commands,
@@ -62,7 +62,7 @@ flush_help_string(struct ds *ds)
 static void
 help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 {
-    const struct command *p;
+    const struct ovs_cmdl_command *p;
     struct ds test_names = DS_EMPTY_INITIALIZER;
     const int linesize = 70;
 
@@ -86,7 +86,7 @@ help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 static void
 add_top_level_commands(void)
 {
-    struct command help_cmd = {"--help", NULL, 0, 0, help};
+    struct ovs_cmdl_command help_cmd = {"--help", NULL, 0, 0, help};
 
     add_command(&help_cmd);
 }
@@ -94,7 +94,7 @@ add_top_level_commands(void)
 void
 ovstest_register(const char *test_name, ovstest_func f)
 {
-    struct command test_cmd;
+    struct ovs_cmdl_command test_cmd;
 
     test_cmd.name = test_name;
     test_cmd.usage = NULL;
@@ -125,7 +125,7 @@ main(int argc, char *argv[])
 
     add_top_level_commands();
     if (argc > 1) {
-        run_command(argc - 1, argv + 1, commands);
+        ovs_cmdl_run_command(argc - 1, argv + 1, commands);
     }
     cleanup();
 
diff --git a/tests/test-bitmap.c b/tests/test-bitmap.c
index 9321332..9c09e14 100644
--- a/tests/test-bitmap.c
+++ b/tests/test-bitmap.c
@@ -148,7 +148,7 @@ run_benchmarks(int argc OVS_UNUSED, char *argv[])
     printf("\n");
 }
 
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
     {"check", NULL, 0, 0, run_tests},
     {"benchmark", NULL, 1, 1, run_benchmarks},
     {NULL, NULL, 0, 0, NULL},
@@ -158,7 +158,7 @@ static void
 test_bitmap_main(int argc, char *argv[])
 {
     set_program_name(argv[0]);
-    run_command(argc - 1, argv + 1, commands);
+    ovs_cmdl_run_command(argc - 1, argv + 1, commands);
 }
 
 OVSTEST_REGISTER("test-bitmap", test_bitmap_main);
diff --git a/tests/test-classifier.c b/tests/test-classifier.c
index 6748da7..5d0e875 100644
--- a/tests/test-classifier.c
+++ b/tests/test-classifier.c
@@ -1400,7 +1400,7 @@ test_minimask_combine(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     minimask_destroy(&minicatchall);
 }
 
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
     /* Classifier tests. */
     {"empty", NULL, 0, 0, test_empty},
     {"destroy-null", NULL, 0, 0, test_destroy_null},
@@ -1424,7 +1424,7 @@ test_classifier_main(int argc, char *argv[])
 {
     set_program_name(argv[0]);
     init_values();
-    run_command(argc - 1, argv + 1, commands);
+    ovs_cmdl_run_command(argc - 1, argv + 1, commands);
 }
 
 OVSTEST_REGISTER("test-classifier", test_classifier_main);
diff --git a/tests/test-cmap.c b/tests/test-cmap.c
index 13f590f..f429cdd 100644
--- a/tests/test-cmap.c
+++ b/tests/test-cmap.c
@@ -636,7 +636,7 @@ benchmark_hmap(void)
     free(elements);
 }
 
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
     {"check", NULL, 0, 1, run_tests},
     {"benchmark", NULL, 3, 4, run_benchmarks},
     {NULL, NULL, 0, 0, NULL},
@@ -646,7 +646,7 @@ static void
 test_cmap_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 {
     set_program_name(argv[0]);
-    run_command(argc - optind, argv + optind, commands);
+    ovs_cmdl_run_command(argc - optind, argv + optind, commands);
 }
 
 OVSTEST_REGISTER("test-cmap", test_cmap_main);
diff --git a/tests/test-heap.c b/tests/test-heap.c
index 92ab57f..5340860 100644
--- a/tests/test-heap.c
+++ b/tests/test-heap.c
@@ -463,7 +463,7 @@ test_heap_raw_delete(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     }
 }
 
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
     { "insert-delete-same-order", NULL, 0, 0,
       test_heap_insert_delete_same_order, },
     { "insert-delete-reverse-order", NULL, 0, 0,
@@ -482,7 +482,7 @@ test_heap_main(int argc, char *argv[])
 {
     set_program_name(argv[0]);
 
-    run_command(argc - 1, argv + 1, commands);
+    ovs_cmdl_run_command(argc - 1, argv + 1, commands);
 }
 
 OVSTEST_REGISTER("test-heap", test_heap_main);
diff --git a/tests/test-jsonrpc.c b/tests/test-jsonrpc.c
index 2aad5c5..d445432 100644
--- a/tests/test-jsonrpc.c
+++ b/tests/test-jsonrpc.c
@@ -35,16 +35,16 @@
 
 OVS_NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
-static struct command *get_all_commands(void);
+static struct ovs_cmdl_command *get_all_commands(void);
 
 static void
 test_jsonrpc_main(int argc, char *argv[])
 {
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     service_start(&argc, &argv);
     parse_options(argc, argv);
-    run_command(argc - optind, argv + optind, get_all_commands());
+    ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
 }
 
 static void
@@ -62,7 +62,7 @@ parse_options(int argc, char *argv[])
         STREAM_SSL_LONG_OPTIONS,
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         int c = getopt_long(argc, argv, short_options, long_options, NULL);
@@ -327,7 +327,7 @@ do_help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     usage();
 }
 
-static struct command all_commands[] = {
+static struct ovs_cmdl_command all_commands[] = {
     { "listen", NULL, 1, 1, do_listen },
     { "request", NULL, 3, 3, do_request },
     { "notify", NULL, 3, 3, do_notify },
@@ -335,7 +335,7 @@ static struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static struct command *
+static struct ovs_cmdl_command *
 get_all_commands(void)
 {
     return all_commands;
diff --git a/tests/test-netflow.c b/tests/test-netflow.c
index d9f29d1..631d7a2 100644
--- a/tests/test-netflow.c
+++ b/tests/test-netflow.c
@@ -178,7 +178,7 @@ test_netflow_main(int argc, char *argv[])
     int sock;
     int n;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     service_start(&argc, &argv);
     parse_options(argc, argv);
@@ -248,7 +248,7 @@ parse_options(int argc, char *argv[])
         VLOG_LONG_OPTIONS,
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         int c = getopt_long(argc, argv, short_options, long_options, NULL);
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index 99f41c1..540dcda 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -53,14 +53,14 @@
 
 OVS_NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
-static struct command *get_all_commands(void);
+static struct ovs_cmdl_command *get_all_commands(void);
 
 int
 main(int argc, char *argv[])
 {
     set_program_name(argv[0]);
     parse_options(argc, argv);
-    run_command(argc - optind, argv + optind, get_all_commands());
+    ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
     return 0;
 }
 
@@ -73,7 +73,7 @@ parse_options(int argc, char *argv[])
         {"help", no_argument, NULL, 'h'},
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         unsigned long int timeout;
@@ -1507,7 +1507,7 @@ do_transact_print(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 static void
 do_transact(int argc, char *argv[])
 {
-    static const struct command do_transact_commands[] = {
+    static const struct ovs_cmdl_command do_transact_commands[] = {
         { "commit", NULL, 0, 0, do_transact_commit },
         { "abort", NULL, 0, 0, do_transact_abort },
         { "insert", NULL, 2, 3, do_transact_insert },
@@ -1569,7 +1569,7 @@ do_transact(int argc, char *argv[])
             fputs(args[j], stdout);
         }
         fputs(":", stdout);
-        run_command(n_args, args, do_transact_commands);
+        ovs_cmdl_run_command(n_args, args, do_transact_commands);
         putchar('\n');
 
         for (j = 0; j < n_args; j++) {
@@ -1962,7 +1962,7 @@ do_idl(int argc, char *argv[])
     printf("%03d: done\n", step);
 }
 
-static struct command all_commands[] = {
+static struct ovs_cmdl_command all_commands[] = {
     { "log-io", NULL, 2, INT_MAX, do_log_io },
     { "default-atoms", NULL, 0, 0, do_default_atoms },
     { "default-data", NULL, 0, 0, do_default_data },
@@ -1993,7 +1993,7 @@ static struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static struct command *
+static struct ovs_cmdl_command *
 get_all_commands(void)
 {
     return all_commands;
diff --git a/tests/test-reconnect.c b/tests/test-reconnect.c
index 7d39339..2d6f620 100644
--- a/tests/test-reconnect.c
+++ b/tests/test-reconnect.c
@@ -34,7 +34,7 @@ static int now;
 static void diff_stats(const struct reconnect_stats *old,
                        const struct reconnect_stats *new,
                        int delta);
-static const struct command *get_all_commands(void);
+static const struct ovs_cmdl_command *get_all_commands(void);
 
 static void
 test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
@@ -67,7 +67,7 @@ test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         svec_parse_words(&args, line);
         svec_terminate(&args);
         if (!svec_is_empty(&args)) {
-            run_command(args.n, args.names, get_all_commands());
+            ovs_cmdl_run_command(args.n, args.names, get_all_commands());
         }
         svec_destroy(&args);
 
@@ -268,7 +268,7 @@ do_listen_error(int argc OVS_UNUSED, char *argv[])
     reconnect_listen_error(reconnect, now, atoi(argv[1]));
 }
 
-static const struct command all_commands[] = {
+static const struct ovs_cmdl_command all_commands[] = {
     { "enable", NULL, 0, 0, do_enable },
     { "disable", NULL, 0, 0, do_disable },
     { "force-reconnect", NULL, 0, 0, do_force_reconnect },
@@ -287,7 +287,7 @@ static const struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static const struct command *
+static const struct ovs_cmdl_command *
 get_all_commands(void)
 {
     return all_commands;
diff --git a/tests/test-sflow.c b/tests/test-sflow.c
index 3e3c450..70a0372 100644
--- a/tests/test-sflow.c
+++ b/tests/test-sflow.c
@@ -634,7 +634,7 @@ test_sflow_main(int argc, char *argv[])
     int error;
     int sock;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     service_start(&argc, &argv);
     parse_options(argc, argv);
@@ -701,7 +701,7 @@ parse_options(int argc, char *argv[])
         VLOG_LONG_OPTIONS,
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         int c = getopt_long(argc, argv, short_options, long_options, NULL);
diff --git a/tests/test-util.c b/tests/test-util.c
index 2c985e7..01a1a78 100644
--- a/tests/test-util.c
+++ b/tests/test-util.c
@@ -1049,7 +1049,7 @@ test_file_name(int argc, char *argv[])
 }
 #endif /* _WIN32 */
 
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
     {"ctz", NULL, 0, 0, test_ctz},
     {"clz", NULL, 0, 0, test_clz},
     {"round_up_pow2", NULL, 0, 0, test_round_up_pow2},
@@ -1080,7 +1080,7 @@ parse_options(int argc, char *argv[])
         VLOG_LONG_OPTIONS,
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         int c = getopt_long(argc, argv, short_options, long_options, NULL);
@@ -1111,7 +1111,7 @@ test_util_main(int argc, char *argv[])
      * POSIX doesn't define the circumstances in which stderr is
      * fully buffered either. */
     setvbuf(stderr, NULL, _IONBF, 0);
-    run_command(argc - optind, argv + optind, commands);
+    ovs_cmdl_run_command(argc - optind, argv + optind, commands);
 }
 
 OVSTEST_REGISTER("test-util", test_util_main);
diff --git a/tests/test-vconn.c b/tests/test-vconn.c
index c3e8a34..6e6ec99 100644
--- a/tests/test-vconn.c
+++ b/tests/test-vconn.c
@@ -431,7 +431,7 @@ test_send_invalid_version_hello(int argc OVS_UNUSED, char *argv[])
     ofpbuf_delete(hello);
 }
 
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
     {"refuse-connection", NULL, 1, 1, test_refuse_connection},
     {"accept-then-close", NULL, 1, 1, test_accept_then_close},
     {"read-hello", NULL, 1, 1, test_read_hello},
@@ -453,7 +453,7 @@ test_vconn_main(int argc, char *argv[])
 
     time_alarm(10);
 
-    run_command(argc - 1, argv + 1, commands);
+    ovs_cmdl_run_command(argc - 1, argv + 1, commands);
 }
 
 OVSTEST_REGISTER("test-vconn", test_vconn_main);
diff --git a/utilities/ovs-appctl.c b/utilities/ovs-appctl.c
index dee2d33..f7403f7 100644
--- a/utilities/ovs-appctl.c
+++ b/utilities/ovs-appctl.c
@@ -123,7 +123,7 @@ parse_command_line(int argc, char *argv[])
         VLOG_LONG_OPTIONS,
         {NULL, 0, NULL, 0},
     };
-    char *short_options_ = long_options_to_short_options(long_options);
+    char *short_options_ = ovs_cmdl_long_options_to_short_options(long_options);
     char *short_options = xasprintf("+%s", short_options_);
     const char *target;
     int e_options;
@@ -160,7 +160,7 @@ parse_command_line(int argc, char *argv[])
             break;
 
         case 'o':
-            print_options(long_options);
+            ovs_cmdl_print_options(long_options);
             exit(EXIT_SUCCESS);
 
         case 'T':
diff --git a/utilities/ovs-benchmark.c b/utilities/ovs-benchmark.c
index 64db63e..d2f2e8b 100644
--- a/utilities/ovs-benchmark.c
+++ b/utilities/ovs-benchmark.c
@@ -49,7 +49,7 @@ static double max_rate;
 
 static double timeout;
 
-static const struct command *get_all_commands(void);
+static const struct ovs_cmdl_command *get_all_commands(void);
 
 static void parse_options(int argc, char *argv[]);
 static void usage(void);
@@ -84,7 +84,7 @@ main(int argc, char *argv[])
     set_program_name(argv[0]);
     vlog_set_levels(NULL, VLF_ANY_DESTINATION, VLL_EMER);
     parse_options(argc, argv);
-    run_command(argc - optind, argv + optind, get_all_commands());
+    ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
     return 0;
 }
 
@@ -141,7 +141,7 @@ parse_options(int argc, char *argv[])
         {"version", no_argument, NULL, 'V'},
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     local_addr.s_addr = htonl(INADDR_ANY);
     local_min_port = local_max_port = 0;
@@ -616,7 +616,7 @@ cmd_help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     usage();
 }
 
-static const struct command all_commands[] = {
+static const struct ovs_cmdl_command all_commands[] = {
     { "listen", NULL, 0, 0, cmd_listen },
     { "rate", NULL, 0, 0, cmd_rate },
     { "latency", NULL, 0, 0, cmd_latency },
@@ -624,7 +624,7 @@ static const struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static const struct command *get_all_commands(void)
+static const struct ovs_cmdl_command *get_all_commands(void)
 {
   return all_commands;
 }
diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c
index 9d279f0..c43066d 100644
--- a/utilities/ovs-dpctl.c
+++ b/utilities/ovs-dpctl.c
@@ -91,7 +91,7 @@ parse_options(int argc, char *argv[])
         VLOG_LONG_OPTIONS,
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         unsigned long int timeout;
@@ -133,7 +133,7 @@ parse_options(int argc, char *argv[])
             usage(NULL);
 
         case 'o':
-            print_options(long_options);
+            ovs_cmdl_print_options(long_options);
             exit(EXIT_SUCCESS);
 
         case 'V':
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 44c5275..89b89a9 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -105,7 +105,7 @@ struct sort_criterion {
 static struct sort_criterion *criteria;
 static size_t n_criteria, allocated_criteria;
 
-static const struct command *get_all_commands(void);
+static const struct ovs_cmdl_command *get_all_commands(void);
 
 OVS_NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
@@ -121,7 +121,7 @@ main(int argc, char *argv[])
     service_start(&argc, &argv);
     parse_options(argc, argv);
     fatal_ignore_sigpipe();
-    run_command(argc - optind, argv + optind, get_all_commands());
+    ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
     return 0;
 }
 
@@ -179,7 +179,7 @@ parse_options(int argc, char *argv[])
         STREAM_SSL_LONG_OPTIONS,
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
     uint32_t versions;
     enum ofputil_protocol version_protocols;
 
@@ -243,7 +243,7 @@ parse_options(int argc, char *argv[])
             usage();
 
         case 'o':
-            print_options(long_options);
+            ovs_cmdl_print_options(long_options);
             exit(EXIT_SUCCESS);
 
         case OPT_STRICT:
@@ -2267,7 +2267,7 @@ ofctl_help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 static void
 ofctl_list_commands(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 {
-    print_commands(get_all_commands());
+    ovs_cmdl_print_commands(get_all_commands());
 }
 
 /* replace-flows and diff-flows commands. */
@@ -3481,7 +3481,7 @@ ofctl_encode_hello(int argc OVS_UNUSED, char *argv[])
     ofpbuf_delete(hello);
 }
 
-static const struct command all_commands[] = {
+static const struct ovs_cmdl_command all_commands[] = {
     { "show", "switch",
       1, 1, ofctl_show },
     { "monitor", "switch [misslen] [invalid_ttl] [watch:[...]]",
@@ -3597,7 +3597,7 @@ static const struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static const struct command *get_all_commands(void)
+static const struct ovs_cmdl_command *get_all_commands(void)
 {
     return all_commands;
 }
diff --git a/utilities/ovs-testcontroller.c b/utilities/ovs-testcontroller.c
index bb96701..3d59adb 100644
--- a/utilities/ovs-testcontroller.c
+++ b/utilities/ovs-testcontroller.c
@@ -103,7 +103,7 @@ main(int argc, char *argv[])
     int retval;
     int i;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     parse_options(argc, argv);
     fatal_ignore_sigpipe();
@@ -277,7 +277,7 @@ parse_options(int argc, char *argv[])
         {"peer-ca-cert", required_argument, NULL, OPT_PEER_CA_CERT},
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         int indexptr;
diff --git a/utilities/ovs-vlan-bug-workaround.c b/utilities/ovs-vlan-bug-workaround.c
index 88fb2b1..add800e 100644
--- a/utilities/ovs-vlan-bug-workaround.c
+++ b/utilities/ovs-vlan-bug-workaround.c
@@ -116,7 +116,7 @@ parse_options(int argc, char *argv[])
         {"version", no_argument, NULL, 'V'},
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         int option;
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index af1cfc0..1abefb4 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -332,7 +332,7 @@ parse_options(int argc, char *argv[], struct shash *local_options)
     size_t n_options;
     size_t i;
 
-    tmp = long_options_to_short_options(global_long_options);
+    tmp = ovs_cmdl_long_options_to_short_options(global_long_options);
     short_options = xasprintf("+%s", tmp);
     free(tmp);
 
diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c
index 812c00b..eda4aab 100644
--- a/vswitchd/ovs-vswitchd.c
+++ b/vswitchd/ovs-vswitchd.c
@@ -75,7 +75,7 @@ main(int argc, char *argv[])
     argc -= retval;
     argv += retval;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     service_start(&argc, &argv);
     remote = parse_options(argc, argv, &unixctl_path);
     fatal_ignore_sigpipe();
@@ -165,7 +165,7 @@ parse_options(int argc, char *argv[], char **unixctl_pathp)
         {"dpdk", required_argument, NULL, OPT_DPDK},
         {NULL, 0, NULL, 0},
     };
-    char *short_options = long_options_to_short_options(long_options);
+    char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
 
     for (;;) {
         int c;
diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c
index 3e8066e..ead22ea 100644
--- a/vtep/vtep-ctl.c
+++ b/vtep/vtep-ctl.c
@@ -272,7 +272,7 @@ parse_options(int argc, char *argv[], struct shash *local_options)
     size_t n_options;
     size_t i;
 
-    tmp = long_options_to_short_options(global_long_options);
+    tmp = ovs_cmdl_long_options_to_short_options(global_long_options);
     short_options = xasprintf("+%s", tmp);
     free(tmp);
 
-- 
2.1.0




More information about the dev mailing list