[ovs-dev] [kernel-reload 1/8] daemon: Define daemon options enums the same way as other option enums.

Justin Pettit jpettit at nicira.com
Mon Feb 7 07:02:31 UTC 2011


Looks good.

--Justin


On Feb 2, 2011, at 2:31 PM, Ben Pfaff wrote:

> 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 1d63076..dd85b46 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 <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},           \
> diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
> index da6a6d6..295a9be 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 b4f2e42..c07932d 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.
> @@ -476,7 +476,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 e8edec0..44edda8 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 c38c812..f5e5014 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 a89ebc5..534dd77 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 0cd919a..486eae2 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 992b8e2..a89ea2a 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 cd30c96..4ebc8f2 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'},
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list