Avoid printf type modifiers not supported by MSVC C runtime library.
[cascardo/ovs.git] / ovsdb / ovsdb-client.c
index 12f34d5..bfc2653 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
 
 #include <config.h>
 
-#include <assert.h>
 #include <ctype.h>
 #include <errno.h>
 #include <getopt.h>
@@ -70,7 +69,7 @@ static bool timestamp;
 /* Format for table output. */
 static struct table_style table_style = TABLE_STYLE_DEFAULT;
 
-static const struct ovsdb_client_command all_commands[];
+static const struct ovsdb_client_command *get_all_commands(void);
 
 static void usage(void) NO_RETURN;
 static void parse_options(int argc, char *argv[]);
@@ -93,7 +92,7 @@ main(int argc, char *argv[])
         ovs_fatal(0, "missing command name; use --help for help");
     }
 
-    for (command = all_commands; ; command++) {
+    for (command = get_all_commands(); ; command++) {
         if (!command->name) {
             VLOG_FATAL("unknown command '%s'; use --help for help",
                        argv[optind]);
@@ -167,7 +166,7 @@ parse_options(int argc, char *argv[])
         DAEMON_OPTION_ENUMS,
         TABLE_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"verbose", optional_argument, NULL, 'v'},
         {"help", no_argument, NULL, 'h'},
         {"version", no_argument, NULL, 'V'},
@@ -388,11 +387,12 @@ fetch_dbs(struct jsonrpc *rpc, struct svec *dbs)
         const struct json *name = reply->result->u.array.elems[i];
 
         if (name->type != JSON_STRING) {
-            ovs_fatal(0, "list_dbs response %zu is not string", i);
+            ovs_fatal(0, "list_dbs response %"PRIuSIZE" is not string", i);
         }
         svec_add(dbs, name->u.string);
     }
     jsonrpc_msg_destroy(reply);
+    svec_sort(dbs);
 }
 \f
 static void
@@ -847,7 +847,7 @@ dump_table(const struct ovsdb_table_schema *ts, struct json_array *rows)
         struct shash *row;
 
         if (rows->elems[y]->type != JSON_OBJECT) {
-            ovs_fatal(0,  "row %zu in table %s response is not a JSON object: "
+            ovs_fatal(0,  "row %"PRIuSIZE" in table %s response is not a JSON object: "
                       "%s", y, ts->name, json_to_string(rows->elems[y], 0));
         }
         row = json_object(rows->elems[y]);
@@ -856,7 +856,7 @@ dump_table(const struct ovsdb_table_schema *ts, struct json_array *rows)
         for (x = 0; x < n_columns; x++) {
             const struct json *json = shash_find_data(row, columns[x]->name);
             if (!json) {
-                ovs_fatal(0, "row %zu in table %s response lacks %s column",
+                ovs_fatal(0, "row %"PRIuSIZE" in table %s response lacks %s column",
                           y, ts->name, columns[x]->name);
             }
 
@@ -945,7 +945,7 @@ do_dump(struct jsonrpc *rpc, const char *database,
     /* Print database contents. */
     if (reply->result->type != JSON_ARRAY
         || reply->result->u.array.n != n_tables) {
-        ovs_fatal(0, "reply is not array of %zu elements: %s",
+        ovs_fatal(0, "reply is not array of %"PRIuSIZE" elements: %s",
                   n_tables, json_to_string(reply->result, 0));
     }
     for (i = 0; i < n_tables; i++) {
@@ -997,3 +997,8 @@ static const struct ovsdb_client_command all_commands[] = {
 
     { NULL,                 0,             0, 0,       NULL },
 };
+
+static const struct ovsdb_client_command *get_all_commands(void)
+{
+    return all_commands;
+}