In C++, 'protected' is a keyword. This patch renames 'protected' to 'protected_' in a couple files so that C++ compiler will not get confused.
Signed-off-by: Yi-Hung Wei <yihung....@gmail.com> --- ofproto/ofproto-dpif.c | 10 +++++----- ofproto/ofproto.h | 2 +- ovsdb/ovsdb-idlc.1 | 6 ++++-- ovsdb/ovsdb-idlc.in | 18 ++++++++++++++++-- vswitchd/bridge.c | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index b99f04fad300..cdfd09ee2ee7 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -103,7 +103,7 @@ struct ofbundle { struct bond *bond; /* Nonnull iff more than one port. */ bool use_priority_tags; /* Use 802.1p tag for frames in VLAN 0? */ - bool protected; /* Protected port mode */ + bool protected_; /* Protected port mode */ /* Status. */ bool floodable; /* True if no port has OFPUTIL_PC_NO_FLOOD set. */ @@ -456,7 +456,7 @@ type_run(const char *type) bundle->vlan, bundle->trunks, bundle->cvlans, bundle->use_priority_tags, bundle->bond, bundle->lacp, - bundle->floodable, bundle->protected); + bundle->floodable, bundle->protected_); } HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) { @@ -3049,7 +3049,7 @@ bundle_set(struct ofproto *ofproto_, void *aux, bundle->bond = NULL; bundle->floodable = true; - bundle->protected = false; + bundle->protected_ = false; mbridge_register_bundle(ofproto->mbridge, bundle); } @@ -3207,8 +3207,8 @@ bundle_set(struct ofproto *ofproto_, void *aux, } /* Set proteced port mode */ - if (s->protected != bundle->protected) { - bundle->protected = s->protected; + if (s->protected_ != bundle->protected_) { + bundle->protected_ = s->protected_; need_flush = true; } diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h index 1e48e1952aa2..c45b12041e85 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -414,7 +414,7 @@ struct ofproto_bundle_settings { struct lacp_settings *lacp; /* Nonnull to enable LACP. */ struct lacp_slave_settings *lacp_slaves; /* Array of n_slaves elements. */ - bool protected; /* Protected port mode */ + bool protected_; /* Protected port mode */ }; int ofproto_bundle_register(struct ofproto *, void *aux, diff --git a/ovsdb/ovsdb-idlc.1 b/ovsdb/ovsdb-idlc.1 index b44757b820b8..393badfbd4da 100644 --- a/ovsdb/ovsdb-idlc.1 +++ b/ovsdb/ovsdb-idlc.1 @@ -50,11 +50,13 @@ modified is re-serialized as JSON on standard output. . .IP "\fBc\-idl\-header\fI idl\fR" Reads \fIidl\fR and prints on standard output a C header file that -defines a structure for each table defined by the schema. +defines a structure for each table defined by the schema. If a column +name in \fIidl\fR is a C++ keyword, it will be appended with an underscore. . .IP "\fBc\-idl\-source\fI idl\fR" Reads \fIidl\fR and prints on standard output a C source file that -implements C bindings for the database defined by the schema. +implements C bindings for the database defined by the schema. If a column +name in \fIidl\fR is a C++ keyword, it will be appended with an underscore. . .SS "Options" .so lib/common.man diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index c3973e4f5982..1ca1b977e049 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -122,8 +122,20 @@ def cMembers(prefix, tableName, columnName, column, const, refTable=True): def sorted_columns(table): return sorted(table.columns.items()) +# If a column name in the schema is a C++ keyword, append an underscore +# to the column name. +def replace_cplusplus_keyword(schema): + keywords = {'class', 'default', 'delete', 'mutable', 'new', 'private', + 'protected', 'public'} + + for tableName, table in schema.tables.items(): + for columnName in table.columns: + if columnName in keywords: + table.columns[columnName + '_'] = table.columns.pop(columnName) + def printCIDLHeader(schemaFile): schema = parseSchema(schemaFile) + replace_cplusplus_keyword(schema) prefix = schema.idlPrefix print('''\ /* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */ @@ -328,6 +340,7 @@ def printEnum(type, members): def printCIDLSource(schemaFile): schema = parseSchema(schemaFile) + replace_cplusplus_keyword(schema) prefix = schema.idlPrefix print('''\ /* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */ @@ -1273,7 +1286,7 @@ void for x in column.type.cInitType("%s_col_%s" % (tableName, columnName), prereqs)) print("""\ [%(P)s%(T)s_COL_%(C)s] = { - .name = "%(c)s", + .name = "%(column_name_in_schema)s", .type = { %(type)s }, @@ -1286,7 +1299,8 @@ void 'C': columnName.upper(), 's': structName, 'mutable': mutable, - 'type': type_init}) + 'type': type_init, + 'column_name_in_schema': column.name}) print("};") # Table classes. diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 630c6fa535e2..66c6a1776c2b 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -1046,7 +1046,7 @@ port_configure(struct port *port) } /* Protected port mode */ - s.protected = cfg->protected; + s.protected_ = cfg->protected_; /* Register. */ ofproto_bundle_register(port->bridge->ofproto, port, &s); -- 2.7.4 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev