2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-05 00:35:33 +00:00

Avoid designated initializers and static decls of arrays of unknown size.

MSVC can't handle either one.

Signed-off-by: Linda Sun <lsun@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Linda Sun
2013-07-19 10:04:47 -07:00
committed by Ben Pfaff
parent 59987a623a
commit 3815d6c2cd
8 changed files with 53 additions and 23 deletions

View File

@@ -144,8 +144,9 @@ static void
format_odp_sample_action(struct ds *ds, const struct nlattr *attr)
{
static const struct nl_policy ovs_sample_policy[] = {
[OVS_SAMPLE_ATTR_PROBABILITY] = { .type = NL_A_U32 },
[OVS_SAMPLE_ATTR_ACTIONS] = { .type = NL_A_NESTED }
{ NL_A_NO_ATTR, 0, 0, false }, /* OVS_SAMPLE_ATTR_UNSPEC */
{ NL_A_U32, 0, 0, false }, /* OVS_SAMPLE_ATTR_PROBABILITY */
{ NL_A_NESTED, 0, 0, false }, /* OVS_SAMPLE_ATTR_ACTIONS */
};
struct nlattr *a[ARRAY_SIZE(ovs_sample_policy)];
double percentage;
@@ -259,9 +260,9 @@ static void
format_odp_userspace_action(struct ds *ds, const struct nlattr *attr)
{
static const struct nl_policy ovs_userspace_policy[] = {
[OVS_USERSPACE_ATTR_PID] = { .type = NL_A_U32 },
[OVS_USERSPACE_ATTR_USERDATA] = { .type = NL_A_UNSPEC,
.optional = true },
{ NL_A_NO_ATTR, 0, 0, false }, /* OVS_USERSPACE_ATTR_UNSPEC */
{ NL_A_U32, 0, 0, false }, /* OVS_USERSPACE_ATTR_PID */
{ NL_A_UNSPEC, 0, 0, true }, /* OVS_USERSPACE_ATTR_USERDATA */
};
struct nlattr *a[ARRAY_SIZE(ovs_userspace_policy)];
const struct nlattr *userdata_attr;

View File

@@ -160,11 +160,9 @@ struct xlate_ctx {
* it did not arrive on a "real" port. 'ofpp_none_bundle' exists for
* when an input bundle is needed for validation (e.g., mirroring or
* OFPP_NORMAL processing). It is not connected to an 'ofproto' or have
* any 'port' structs, so care must be taken when dealing with it. */
static struct xbundle ofpp_none_bundle = {
.name = "OFPP_NONE",
.vlan_mode = PORT_VLAN_TRUNK
};
* any 'port' structs, so care must be taken when dealing with it.
* The bundle's name and vlan mode are initialized in lookup_input_bundle() */
static struct xbundle ofpp_none_bundle;
static struct hmap xbridges = HMAP_INITIALIZER(&xbridges);
static struct hmap xbundles = HMAP_INITIALIZER(&xbundles);
@@ -530,6 +528,8 @@ lookup_input_bundle(const struct xbridge *xbridge, ofp_port_t in_port,
/* Special-case OFPP_NONE, which a controller may use as the ingress
* port for traffic that it is sourcing. */
if (in_port == OFPP_NONE) {
ofpp_none_bundle.name = "OFPP_NONE";
ofpp_none_bundle.vlan_mode = PORT_VLAN_TRUNK;
return &ofpp_none_bundle;
}

View File

@@ -69,7 +69,7 @@ static bool timestamp;
/* Format for table output. */
static struct table_style table_style = TABLE_STYLE_DEFAULT;
static const struct ovsdb_client_command all_commands[];
static const struct ovsdb_client_command *get_all_commands(void);
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[]);
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
ovs_fatal(0, "missing command name; use --help for help");
}
for (command = all_commands; ; command++) {
for (command = get_all_commands(); ; command++) {
if (!command->name) {
VLOG_FATAL("unknown command '%s'; use --help for help",
argv[optind]);
@@ -997,3 +997,8 @@ static const struct ovsdb_client_command all_commands[] = {
{ NULL, 0, 0, 0, NULL },
};
static const struct ovsdb_client_command *get_all_commands(void)
{
return all_commands;
}

View File

@@ -45,7 +45,7 @@ VLOG_DEFINE_THIS_MODULE(ovsdb_tool);
/* -m, --more: Verbosity level for "show-log" command output. */
static int show_log_verbosity;
static const struct command all_commands[];
static const struct command *get_all_commands(void);
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[]);
@@ -59,7 +59,7 @@ main(int argc, char *argv[])
set_program_name(argv[0]);
parse_options(argc, argv);
signal(SIGPIPE, SIG_IGN);
run_command(argc - optind, argv + optind, all_commands);
run_command(argc - optind, argv + optind, get_all_commands());
return 0;
}
@@ -564,3 +564,8 @@ static const struct command all_commands[] = {
{ "help", 0, INT_MAX, do_help },
{ NULL, 0, 0, NULL },
};
static const struct command *get_all_commands(void)
{
return all_commands;
}

View File

@@ -49,7 +49,7 @@ static double max_rate;
static double timeout;
static const struct command all_commands[];
static const struct command *get_all_commands(void);
static void parse_options(int argc, char *argv[]);
static void usage(void);
@@ -72,7 +72,7 @@ main(int argc, char *argv[])
set_program_name(argv[0]);
vlog_set_levels(NULL, VLF_ANY_FACILITY, VLL_EMER);
parse_options(argc, argv);
run_command(argc - optind, argv + optind, all_commands);
run_command(argc - optind, argv + optind, get_all_commands());
return 0;
}
@@ -617,3 +617,8 @@ static const struct command all_commands[] = {
{ "help", 0, 0, cmd_help },
{ NULL, 0, 0, NULL },
};
static const struct command *get_all_commands(void)
{
return all_commands;
}

View File

@@ -66,7 +66,7 @@ static bool may_create;
* the option itself. */
static int verbosity;
static const struct command all_commands[];
static const struct command *get_all_commands(void);
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[]);
@@ -77,7 +77,7 @@ main(int argc, char *argv[])
set_program_name(argv[0]);
parse_options(argc, argv);
signal(SIGPIPE, SIG_IGN);
run_command(argc - optind, argv + optind, all_commands);
run_command(argc - optind, argv + optind, get_all_commands());
return 0;
}
@@ -1146,3 +1146,8 @@ static const struct command all_commands[] = {
{ NULL, 0, 0, NULL },
};
static const struct command *get_all_commands(void)
{
return all_commands;
}

View File

@@ -98,7 +98,7 @@ struct sort_criterion {
static struct sort_criterion *criteria;
static size_t n_criteria, allocated_criteria;
static const struct command all_commands[];
static const struct command *get_all_commands(void);
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[]);
@@ -113,7 +113,7 @@ main(int argc, char *argv[])
set_program_name(argv[0]);
parse_options(argc, argv);
signal(SIGPIPE, SIG_IGN);
run_command(argc - optind, argv + optind, all_commands);
run_command(argc - optind, argv + optind, get_all_commands());
return 0;
}
@@ -2956,3 +2956,8 @@ static const struct command all_commands[] = {
{ NULL, 0, 0, NULL },
};
static const struct command *get_all_commands(void)
{
return all_commands;
}

View File

@@ -128,7 +128,7 @@ static bool retry;
static struct table_style table_style = TABLE_STYLE_DEFAULT;
/* All supported commands. */
static const struct vsctl_command_syntax all_commands[];
static const struct vsctl_command_syntax *get_all_commands(void);
/* The IDL we're using and the current transaction, if any.
* This is for use by vsctl_exit() only, to allow it to clean up.
@@ -302,7 +302,7 @@ parse_options(int argc, char *argv[], struct shash *local_options)
options = xmemdup(global_long_options, sizeof global_long_options);
allocated_options = ARRAY_SIZE(global_long_options);
n_options = n_global_long_options;
for (p = all_commands; p->name; p++) {
for (p = get_all_commands(); p->name; p++) {
if (p->options[0]) {
char *save_ptr = NULL;
char *name;
@@ -568,7 +568,7 @@ find_command(const char *name)
if (shash_is_empty(&commands)) {
const struct vsctl_command_syntax *p;
for (p = all_commands; p->name; p++) {
for (p = get_all_commands(); p->name; p++) {
shash_add_assert(&commands, p->name, p);
}
}
@@ -4228,3 +4228,7 @@ static const struct vsctl_command_syntax all_commands[] = {
{NULL, 0, 0, NULL, NULL, NULL, NULL, RO},
};
static const struct vsctl_command_syntax *get_all_commands(void)
{
return all_commands;
}