X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fovsdb-data.c;h=0afd03a29864cb449538c31cd3ef51c601646d04;hb=305b76debf72120672a8ba81d3356b6dccb1da9a;hp=58c2a10a076fc98936ea398c6b28b3ed42d07089;hpb=e0edde6fee279cdbbf3c179f5f50adaf0c7c7f1e;p=sliver-openvswitch.git diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index 58c2a10a0..0afd03a29 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -17,7 +17,6 @@ #include "ovsdb-data.h" -#include #include #include #include @@ -29,6 +28,7 @@ #include "ovsdb-parser.h" #include "json.h" #include "shash.h" +#include "smap.h" #include "sort.h" #include "unicode.h" @@ -107,7 +107,7 @@ ovsdb_atom_default(enum ovsdb_atomic_type type) inited = true; } - assert(ovsdb_atomic_type_is_valid(type)); + ovs_assert(ovsdb_atomic_type_is_valid(type)); return &default_atoms[type]; } @@ -289,7 +289,7 @@ static void ovsdb_symbol_referenced(struct ovsdb_symbol *symbol, const struct ovsdb_base_type *base) { - assert(base->type == OVSDB_TYPE_UUID); + ovs_assert(base->type == OVSDB_TYPE_UUID); if (base->u.uuid.refTableName) { switch (base->u.uuid.refType) { @@ -878,14 +878,15 @@ ovsdb_datum_default(const struct ovsdb_type *type) int kt = type->key.type; int vt = type->value.type; - assert(ovsdb_type_is_valid(type)); + ovs_assert(ovsdb_type_is_valid(type)); d = &default_data[kt][vt]; if (!d->n) { d->n = 1; - d->keys = (union ovsdb_atom *) ovsdb_atom_default(kt); + d->keys = CONST_CAST(union ovsdb_atom *, ovsdb_atom_default(kt)); if (vt != OVSDB_TYPE_VOID) { - d->values = (union ovsdb_atom *) ovsdb_atom_default(vt); + d->values = CONST_CAST(union ovsdb_atom *, + ovsdb_atom_default(vt)); } } return d; @@ -1524,27 +1525,26 @@ ovsdb_datum_to_bare(const struct ovsdb_datum *datum, } /* Initializes 'datum' as a string-to-string map whose contents are taken from - * 'sh'. Destroys 'sh'. */ + * 'smap'. Destroys 'smap'. */ void -ovsdb_datum_from_shash(struct ovsdb_datum *datum, struct shash *sh) +ovsdb_datum_from_smap(struct ovsdb_datum *datum, struct smap *smap) { - struct shash_node *node, *next; + struct smap_node *node, *next; size_t i; - datum->n = shash_count(sh); + datum->n = smap_count(smap); datum->keys = xmalloc(datum->n * sizeof *datum->keys); datum->values = xmalloc(datum->n * sizeof *datum->values); i = 0; - SHASH_FOR_EACH_SAFE (node, next, sh) { - datum->keys[i].string = node->name; - datum->values[i].string = node->data; - shash_steal(sh, node); + SMAP_FOR_EACH_SAFE (node, next, smap) { + smap_steal(smap, node, + &datum->keys[i].string, &datum->values[i].string); i++; } - assert(i == datum->n); + ovs_assert(i == datum->n); - shash_destroy(sh); + smap_destroy(smap); ovsdb_datum_sort_unique(datum, OVSDB_TYPE_STRING, OVSDB_TYPE_STRING); } @@ -1801,7 +1801,7 @@ ovsdb_datum_union(struct ovsdb_datum *a, const struct ovsdb_datum *b, struct ovsdb_error *error; a->n = n; error = ovsdb_datum_sort(a, type->key.type); - assert(!error); + ovs_assert(!error); } } @@ -1813,9 +1813,9 @@ ovsdb_datum_subtract(struct ovsdb_datum *a, const struct ovsdb_type *a_type, bool changed = false; size_t i; - assert(a_type->key.type == b_type->key.type); - assert(a_type->value.type == b_type->value.type - || b_type->value.type == OVSDB_TYPE_VOID); + ovs_assert(a_type->key.type == b_type->key.type); + ovs_assert(a_type->value.type == b_type->value.type + || b_type->value.type == OVSDB_TYPE_VOID); /* XXX The big-O of this could easily be improved. */ for (i = 0; i < a->n; ) { @@ -1862,7 +1862,7 @@ ovsdb_symbol_table_put(struct ovsdb_symbol_table *symtab, const char *name, { struct ovsdb_symbol *symbol; - assert(!ovsdb_symbol_table_get(symtab, name)); + ovs_assert(!ovsdb_symbol_table_get(symtab, name)); symbol = xmalloc(sizeof *symbol); symbol->uuid = *uuid; symbol->created = created;