Looks Good. On Tue, Mar 1, 2011 at 2:19 PM, Ben Pfaff <[email protected]> wrote: > ovs-vsctl will, in upcoming commits, want to more closely examine its > ovsdb_symbol_table structures. This could be done by providing a more > complete API, but it doesn't seem worth it to me. This commit instead goes > the other way, exposing the internals to clients. This commit also > eliminates the ovsdb_symbol_table_find_uncreated() function, which > ovs-vsctl can now implement itself. > --- > lib/ovsdb-data.c | 19 ------------------- > lib/ovsdb-data.h | 8 +++++--- > utilities/ovs-vsctl.c | 13 ++++++++----- > 3 files changed, 13 insertions(+), 27 deletions(-) > > diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c > index c141e86..ac94864 100644 > --- a/lib/ovsdb-data.c > +++ b/lib/ovsdb-data.c > @@ -1795,10 +1795,6 @@ ovsdb_datum_subtract(struct ovsdb_datum *a, const > struct ovsdb_type *a_type, > } > } > > -struct ovsdb_symbol_table { > - struct shash sh; > -}; > - > struct ovsdb_symbol_table * > ovsdb_symbol_table_create(void) > { > @@ -1852,21 +1848,6 @@ ovsdb_symbol_table_insert(struct ovsdb_symbol_table > *symtab, > } > return symbol; > } > - > -const char * > -ovsdb_symbol_table_find_uncreated(const struct ovsdb_symbol_table *symtab) > -{ > - struct shash_node *node; > - > - SHASH_FOR_EACH (node, &symtab->sh) { > - struct ovsdb_symbol *symbol = node->data; > - if (!symbol->created) { > - return node->name; > - } > - } > - > - return NULL; > -} > > /* Extracts a token from the beginning of 's' and returns a pointer just > after > * the token. Stores the token itself into '*outp', which the caller is > diff --git a/lib/ovsdb-data.h b/lib/ovsdb-data.h > index fe279bc..fe71f90 100644 > --- a/lib/ovsdb-data.h > +++ b/lib/ovsdb-data.h > @@ -19,10 +19,10 @@ > #include <stdlib.h> > #include "compiler.h" > #include "ovsdb-types.h" > +#include "shash.h" > > struct ds; > struct ovsdb_symbol_table; > -struct shash; > > /* One value of an atomic type (given by enum ovs_atomic_type). */ > union ovsdb_atom { > @@ -229,6 +229,10 @@ ovsdb_datum_conforms_to_type(const struct ovsdb_datum > *datum, > /* A table mapping from names to data items. Currently the data items are > * always UUIDs; perhaps this will be expanded in the future. */ > > +struct ovsdb_symbol_table { > + struct shash sh; /* Maps from name to struct ovsdb_symbol *. > */ > +}; > + > struct ovsdb_symbol { > struct uuid uuid; /* The UUID that the symbol represents. */ > bool created; /* Already used to create row? */ > @@ -243,8 +247,6 @@ struct ovsdb_symbol *ovsdb_symbol_table_put(struct > ovsdb_symbol_table *, > const struct uuid *, bool used); > struct ovsdb_symbol *ovsdb_symbol_table_insert(struct ovsdb_symbol_table *, > const char *name); > -const char *ovsdb_symbol_table_find_uncreated( > - const struct ovsdb_symbol_table *); > > /* Tokenization > * > diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c > index 2818a38..e5e03f7 100644 > --- a/utilities/ovs-vsctl.c > +++ b/utilities/ovs-vsctl.c > @@ -3354,8 +3354,8 @@ do_vsctl(const char *args, struct vsctl_command > *commands, size_t n_commands, > const struct ovsrec_open_vswitch *ovs; > enum ovsdb_idl_txn_status status; > struct ovsdb_symbol_table *symtab; > - const char *uncreated; > struct vsctl_command *c; > + struct shash_node *node; > int64_t next_cfg = 0; > char *error = NULL; > > @@ -3395,10 +3395,13 @@ do_vsctl(const char *args, struct vsctl_command > *commands, size_t n_commands, > } > } > > - uncreated = ovsdb_symbol_table_find_uncreated(symtab); > - if (uncreated) { > - vsctl_fatal("row id \"%s\" is referenced but never created (e.g. " > - "with \"-- --id=%s create ...\")", uncreated, uncreated); > + SHASH_FOR_EACH (node, &symtab->sh) { > + struct ovsdb_symbol *symbol = node->data; > + if (!symbol->created) { > + vsctl_fatal("row id \"%s\" is referenced but never created (e.g. > " > + "with \"-- --id=%s create ...\")", > + node->name, node->name); > + } > } > > status = ovsdb_idl_txn_commit_block(txn); > -- > 1.7.1 > > > _______________________________________________ > dev mailing list > [email protected] > http://openvswitch.org/mailman/listinfo/dev_openvswitch.org >
_______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
