Skip to content

Commit

Permalink
Make most "struct option" instances "const".
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
blp committed May 3, 2013
1 parent d64e176 commit 07fc4ed
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions ovsdb/ovsdb-client.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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'},
Expand Down
2 changes: 1 addition & 1 deletion ovsdb/ovsdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion ovsdb/ovsdb-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down
4 changes: 2 additions & 2 deletions tests/test-jsonrpc.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/test-netflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/test-ovsdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down
2 changes: 1 addition & 1 deletion tests/test-sflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/test-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-dpctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-ofctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion vswitchd/ovs-vswitchd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 07fc4ed

Please sign in to comment.