daemon: Define daemon options enums the same way as other option enums.
authorBen Pfaff <blp@nicira.com>
Fri, 28 Jan 2011 20:39:15 +0000 (12:39 -0800)
committerBen Pfaff <blp@nicira.com>
Mon, 7 Feb 2011 20:50:19 +0000 (12:50 -0800)
Other modules that accept options use this style and I don't see a reason
for the daemon code to be different.  The style used by the daemon code
until now runs the risk of ending up with conflicting values accidentally,
which would be confusing.

lib/daemon.h
ovsdb/ovsdb-client.c
ovsdb/ovsdb-server.c
tests/test-jsonrpc.c
utilities/ovs-controller.c
utilities/ovs-discover.c
utilities/ovs-openflowd.c
vswitchd/ovs-brcompatd.c
vswitchd/ovs-vswitchd.c

index 1d63076..dd85b46 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <stdbool.h>
 #include <sys/types.h>
 
-enum {
-    OPT_DETACH = UCHAR_MAX + 2048,
-    OPT_NO_CHDIR,
-    OPT_OVERWRITE_PIDFILE,
-    OPT_PIDFILE,
+#define DAEMON_OPTION_ENUMS                     \
+    OPT_DETACH,                                 \
+    OPT_NO_CHDIR,                               \
+    OPT_OVERWRITE_PIDFILE,                      \
+    OPT_PIDFILE,                                \
     OPT_MONITOR
-};
 
 #define DAEMON_LONG_OPTIONS                                          \
         {"detach",            no_argument, 0, OPT_DETACH},           \
index da6a6d6..295a9be 100644 (file)
@@ -85,7 +85,8 @@ static void
 parse_options(int argc, char *argv[])
 {
     enum {
-        OPT_BOOTSTRAP_CA_CERT = UCHAR_MAX + 1
+        OPT_BOOTSTRAP_CA_CERT = UCHAR_MAX + 1,
+        DAEMON_OPTION_ENUMS,
     };
     static struct option long_options[] = {
         {"format", required_argument, 0, 'f'},
index 41f1146..1dc9b7d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010 Nicira Networks
+/* Copyright (c) 2009, 2010, 2011 Nicira Networks
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -658,7 +658,8 @@ parse_options(int argc, char *argv[], char **file_namep,
         OPT_RUN,
         OPT_BOOTSTRAP_CA_CERT,
         VLOG_OPTION_ENUMS,
-        LEAK_CHECKER_OPTION_ENUMS
+        LEAK_CHECKER_OPTION_ENUMS,
+        DAEMON_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"remote",      required_argument, 0, OPT_REMOTE},
index e8edec0..44edda8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,7 +53,8 @@ static void
 parse_options(int argc, char *argv[])
 {
     enum {
-        OPT_BOOTSTRAP_CA_CERT = UCHAR_MAX + 1
+        OPT_BOOTSTRAP_CA_CERT = UCHAR_MAX + 1,
+        DAEMON_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"verbose", optional_argument, 0, 'v'},
index c38c812..f5e5014 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -306,7 +306,8 @@ parse_options(int argc, char *argv[])
         OPT_MUTE,
         OPT_WITH_FLOWS,
         OPT_UNIXCTL,
-        VLOG_OPTION_ENUMS
+        VLOG_OPTION_ENUMS,
+        DAEMON_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"hub",         no_argument, 0, 'H'},
index a89ebc5..534dd77 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -280,7 +280,8 @@ parse_options(int argc, char *argv[])
         OPT_EXIT_WITHOUT_BIND,
         OPT_EXIT_AFTER_BIND,
         OPT_NO_DETACH,
-        VLOG_OPTION_ENUMS
+        VLOG_OPTION_ENUMS,
+        DAEMON_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"accept-vconn", required_argument, 0, OPT_ACCEPT_VCONN},
index 0cd919a..486eae2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -234,7 +234,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         OPT_UNIXCTL,
         OPT_ENABLE_DUMMY,
         VLOG_OPTION_ENUMS,
-        LEAK_CHECKER_OPTION_ENUMS
+        LEAK_CHECKER_OPTION_ENUMS,
+        DAEMON_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"datapath-id", required_argument, 0, OPT_DATAPATH_ID},
index 992b8e2..a89ea2a 100644 (file)
@@ -1413,7 +1413,8 @@ parse_options(int argc, char *argv[])
         OPT_PRUNE_TIMEOUT,
         OPT_APPCTL_COMMAND,
         VLOG_OPTION_ENUMS,
-        LEAK_CHECKER_OPTION_ENUMS
+        LEAK_CHECKER_OPTION_ENUMS,
+        DAEMON_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"help",             no_argument, 0, 'h'},
index cd30c96..4ebc8f2 100644 (file)
@@ -123,7 +123,8 @@ parse_options(int argc, char *argv[])
         VLOG_OPTION_ENUMS,
         LEAK_CHECKER_OPTION_ENUMS,
         OPT_BOOTSTRAP_CA_CERT,
-        OPT_ENABLE_DUMMY
+        OPT_ENABLE_DUMMY,
+        DAEMON_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"help",        no_argument, 0, 'h'},