From 8274ae959ac0b158c3e3206b3810af608fb93785 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 28 Jan 2011 12:39:15 -0800 Subject: [PATCH] daemon: Define daemon options enums the same way as other option enums. 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 | 13 ++++++------- ovsdb/ovsdb-client.c | 3 ++- ovsdb/ovsdb-server.c | 5 +++-- tests/test-jsonrpc.c | 5 +++-- utilities/ovs-controller.c | 5 +++-- utilities/ovs-discover.c | 5 +++-- utilities/ovs-openflowd.c | 5 +++-- vswitchd/ovs-brcompatd.c | 3 ++- vswitchd/ovs-vswitchd.c | 3 ++- 9 files changed, 27 insertions(+), 20 deletions(-) diff --git a/lib/daemon.h b/lib/daemon.h index 1d630768..dd85b463 100644 --- a/lib/daemon.h +++ b/lib/daemon.h @@ -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. @@ -21,13 +21,12 @@ #include #include -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}, \ diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index da6a6d6d..295a9be5 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -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'}, diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 41f1146c..1dc9b7de 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -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}, diff --git a/tests/test-jsonrpc.c b/tests/test-jsonrpc.c index e8edec06..44edda84 100644 --- a/tests/test-jsonrpc.c +++ b/tests/test-jsonrpc.c @@ -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'}, diff --git a/utilities/ovs-controller.c b/utilities/ovs-controller.c index c38c8123..f5e50143 100644 --- a/utilities/ovs-controller.c +++ b/utilities/ovs-controller.c @@ -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'}, diff --git a/utilities/ovs-discover.c b/utilities/ovs-discover.c index a89ebc58..534dd774 100644 --- a/utilities/ovs-discover.c +++ b/utilities/ovs-discover.c @@ -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}, diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index 0cd919a6..486eae28 100644 --- a/utilities/ovs-openflowd.c +++ b/utilities/ovs-openflowd.c @@ -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}, diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c index 992b8e21..a89ea2af 100644 --- a/vswitchd/ovs-brcompatd.c +++ b/vswitchd/ovs-brcompatd.c @@ -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'}, diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c index cd30c96d..4ebc8f2c 100644 --- a/vswitchd/ovs-vswitchd.c +++ b/vswitchd/ovs-vswitchd.c @@ -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'}, -- 2.30.2