db-ctl-base: remove ctl_get_all_commands() function
authorAndy Zhou <azhou@nicira.com>
Tue, 14 Jul 2015 05:18:35 +0000 (22:18 -0700)
committerAndy Zhou <azhou@nicira.com>
Fri, 17 Jul 2015 19:42:23 +0000 (12:42 -0700)
all_commands currently is some times accessed directly, some times via
a function call. Change to always access it directly.

Signed-off-by: Andy Zhou <azhou@nicira.com>
lib/db-ctl-base.c
lib/db-ctl-base.h

index d38bf03..187bc68 100644 (file)
@@ -1762,7 +1762,7 @@ ctl_add_cmd_options(struct option **options_p, size_t *n_options_p,
     const struct shash_node *node;
     size_t n_existing_options = *n_options_p;
 
-    SHASH_FOR_EACH (node, ctl_get_all_commands()) {
+    SHASH_FOR_EACH (node, &all_commands) {
         const struct ctl_command_syntax *p = node->data;
 
         if (p->options[0]) {
@@ -1852,7 +1852,7 @@ ctl_print_commands(void)
 {
     const struct shash_node *node;
 
-    SHASH_FOR_EACH (node, ctl_get_all_commands()) {
+    SHASH_FOR_EACH (node, &all_commands) {
         const struct ctl_command_syntax *p = node->data;
         char *options = xstrdup(p->options);
         char *options_begin = options;
@@ -1908,7 +1908,8 @@ bool
 ctl_might_write_to_db(char **argv)
 {
     for (; *argv; argv++) {
-        const struct ctl_command_syntax *p = shash_find_data(&all_commands, *argv);
+        const struct ctl_command_syntax *p = shash_find_data(&all_commands,
+                                                             *argv);
         if (p && p->mode == RW) {
             return true;
         }
@@ -1997,13 +1998,6 @@ ctl_init(const struct ctl_table_class tables_[])
     ctl_register_commands(db_ctl_commands);
 }
 
-/* Returns 'all_commands'. */
-const struct shash *
-ctl_get_all_commands(void)
-{
-    return &all_commands;
-}
-
 /* Returns the text for the database commands usage.  */
 const char *
 ctl_get_db_cmd_usage(void)
index 684de11..2a66230 100644 (file)
@@ -151,7 +151,6 @@ void ctl_print_options(const struct option *);
 void ctl_add_cmd_options(struct option **, size_t *n_options_p,
                          size_t *allocated_options_p, int opt_val);
 void ctl_register_commands(const struct ctl_command_syntax *);
-const struct shash *ctl_get_all_commands(void);
 struct ctl_command *ctl_parse_commands(int argc, char *argv[],
                                        struct shash *local_options,
                                        size_t *n_commandsp);