X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ovsdb%2Fovsdb-server.c;h=32e2eb02f8a8ea9a608923d93fbc56ecf935276d;hb=c824c8a39854199a4221256281b1322cfae33469;hp=6c68e506b197cfb19473e5d736b50ea8e882c12b;hpb=f973f2af2fd4452c8e182caf6a4346cf2a2a394e;p=openvswitch diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 6c68e506..32e2eb02 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -350,8 +350,8 @@ read_map_string_column(const struct ovsdb_row *row, const char *column_name, union ovsdb_atom *atom_key = NULL, *atom_value = NULL; size_t i; - datum = get_datum((struct ovsdb_row *) row, column_name, OVSDB_TYPE_STRING, - OVSDB_TYPE_STRING, UINT_MAX); + datum = get_datum(CONST_CAST(struct ovsdb_row *, row), column_name, + OVSDB_TYPE_STRING, OVSDB_TYPE_STRING, UINT_MAX); if (!datum) { return NULL; @@ -374,8 +374,8 @@ read_column(const struct ovsdb_row *row, const char *column_name, { const struct ovsdb_datum *datum; - datum = get_datum((struct ovsdb_row *) row, column_name, type, OVSDB_TYPE_VOID, - 1); + datum = get_datum(CONST_CAST(struct ovsdb_row *, row), column_name, type, + OVSDB_TYPE_VOID, 1); return datum && datum->n ? datum->keys : NULL; } @@ -404,12 +404,24 @@ read_string_column(const struct ovsdb_row *row, const char *column_name, static void write_bool_column(struct ovsdb_row *row, const char *column_name, bool value) { - struct ovsdb_datum *datum = get_datum(row, column_name, OVSDB_TYPE_BOOLEAN, - OVSDB_TYPE_VOID, 1); + const struct ovsdb_column *column; + struct ovsdb_datum *datum; + column = ovsdb_table_schema_get_column(row->table->schema, column_name); + datum = get_datum(row, column_name, OVSDB_TYPE_BOOLEAN, + OVSDB_TYPE_VOID, 1); if (!datum) { return; } + + if (datum->n != 1) { + ovsdb_datum_destroy(datum, &column->type); + + datum->n = 1; + datum->keys = xmalloc(sizeof *datum->keys); + datum->values = NULL; + } + datum->keys[0].boolean = value; }