Make most "struct option" instances "const".
authorBen Pfaff <blp@nicira.com>
Tue, 23 Apr 2013 23:40:56 +0000 (16:40 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 3 May 2013 20:29:46 +0000 (13:29 -0700)
Reducing non-const static data makes code more obviously thread-safe.
Although option parsing does not normally need to be thread-safe, I
don't know of a drawback to making its data const.

Signed-off-by: Ben Pfaff <blp@nicira.com>
13 files changed:
ovsdb/ovsdb-client.c
ovsdb/ovsdb-server.c
ovsdb/ovsdb-tool.c
tests/test-jsonrpc.c
tests/test-netflow.c
tests/test-ovsdb.c
tests/test-sflow.c
tests/test-util.c
utilities/ovs-benchmark.c
utilities/ovs-controller.c
utilities/ovs-dpctl.c
utilities/ovs-ofctl.c
vswitchd/ovs-vswitchd.c

index 37bd1aa..53e6bb9 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.
@@ -166,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'},
index a8daf1f..1ba7c3c 100644 (file)
@@ -980,7 +980,7 @@ parse_options(int *argcp, char **argvp[],
         LEAK_CHECKER_OPTION_ENUMS,
         DAEMON_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"remote",      required_argument, NULL, OPT_REMOTE},
         {"unixctl",     required_argument, NULL, OPT_UNIXCTL},
         {"run",         required_argument, NULL, OPT_RUN},
index fe6ab42..2ef4061 100644 (file)
@@ -66,7 +66,7 @@ main(int argc, char *argv[])
 static void
 parse_options(int argc, char *argv[])
 {
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"more", no_argument, NULL, 'm'},
         {"verbose", optional_argument, NULL, 'v'},
         {"help", no_argument, NULL, 'h'},
index 7cc708a..616ff2e 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.
@@ -56,7 +56,7 @@ parse_options(int argc, char *argv[])
         OPT_BOOTSTRAP_CA_CERT = UCHAR_MAX + 1,
         DAEMON_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"verbose", optional_argument, NULL, 'v'},
         {"help", no_argument, NULL, 'h'},
         DAEMON_LONG_OPTIONS,
index 6e5b0be..921f0fd 100644 (file)
@@ -237,7 +237,7 @@ parse_options(int argc, char *argv[])
         DAEMON_OPTION_ENUMS,
         VLOG_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"help", no_argument, NULL, 'h'},
         DAEMON_LONG_OPTIONS,
         VLOG_LONG_OPTIONS,
index 658259e..10d434e 100644 (file)
@@ -68,7 +68,7 @@ main(int argc, char *argv[])
 static void
 parse_options(int argc, char *argv[])
 {
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"timeout", required_argument, NULL, 't'},
         {"verbose", optional_argument, NULL, 'v'},
         {"help", no_argument, NULL, 'h'},
index 838fa62..edb996c 100644 (file)
@@ -559,7 +559,7 @@ parse_options(int argc, char *argv[])
         DAEMON_OPTION_ENUMS,
         VLOG_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"verbose", optional_argument, NULL, 'v'},
         {"help", no_argument, NULL, 'h'},
         DAEMON_LONG_OPTIONS,
index 3eecc7a..3422af3 100644 (file)
@@ -363,7 +363,7 @@ parse_options(int argc, char *argv[])
     enum {
         VLOG_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         VLOG_LONG_OPTIONS,
         {NULL, 0, NULL, 0},
     };
index 8bea9f0..d1bdaac 100644 (file)
@@ -118,7 +118,7 @@ parse_target(const char *s_, struct in_addr *addr,
 static void
 parse_options(int argc, char *argv[])
 {
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"local", required_argument, NULL, 'l'},
         {"remote", required_argument, NULL, 'r'},
         {"batches", required_argument, NULL, 'b'},
index 51765bd..70bc2e6 100644 (file)
@@ -255,7 +255,7 @@ parse_options(int argc, char *argv[])
         DAEMON_OPTION_ENUMS,
         OFP_VERSION_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"hub",         no_argument, NULL, 'H'},
         {"noflow",      no_argument, NULL, 'n'},
         {"normal",      no_argument, NULL, 'N'},
index 3b6e6a5..2f9574f 100644 (file)
@@ -89,7 +89,7 @@ parse_options(int argc, char *argv[])
         OPT_MAY_CREATE,
         VLOG_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"statistics", no_argument, NULL, 's'},
         {"clear", no_argument, NULL, OPT_CLEAR},
         {"may-create", no_argument, NULL, OPT_MAY_CREATE},
index 409d640..9f97bbc 100644 (file)
@@ -151,7 +151,7 @@ parse_options(int argc, char *argv[])
         OFP_VERSION_OPTION_ENUMS,
         VLOG_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"timeout", required_argument, NULL, 't'},
         {"strict", no_argument, NULL, OPT_STRICT},
         {"readd", no_argument, NULL, OPT_READD},
index 9736b79..78ebd31 100644 (file)
@@ -159,7 +159,7 @@ parse_options(int argc, char *argv[], char **unixctl_pathp)
         OPT_DISABLE_SYSTEM,
         DAEMON_OPTION_ENUMS
     };
-    static struct option long_options[] = {
+    static const struct option long_options[] = {
         {"help",        no_argument, NULL, 'h'},
         {"version",     no_argument, NULL, 'V'},
         {"mlockall",    no_argument, NULL, OPT_MLOCKALL},