X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ovsdb%2Fcolumn.c;h=73dc9c24c16015d97dc8d0b5945e45ca2335fc88;hb=2f47998baea215b996af0be4d1653032005e3ac4;hp=fc21cdc981deb4876bf772d7c2daa280a4d52402;hpb=a8425c53c5785856cabe80295f0cea0135febdb6;p=openvswitch diff --git a/ovsdb/column.c b/ovsdb/column.c index fc21cdc9..73dc9c24 100644 --- a/ovsdb/column.c +++ b/ovsdb/column.c @@ -31,16 +31,16 @@ ovsdb_column_create(const char *name, const char *comment, bool mutable, bool persistent, const struct ovsdb_type *type) { - struct ovsdb_column *ts; + struct ovsdb_column *column; - ts = xzalloc(sizeof *ts); - ts->name = xstrdup(name); - ts->comment = comment ? xstrdup(comment) : NULL; - ts->mutable = mutable; - ts->persistent = persistent; - ts->type = *type; + column = xzalloc(sizeof *column); + column->name = xstrdup(name); + column->comment = comment ? xstrdup(comment) : NULL; + column->mutable = mutable; + column->persistent = persistent; + column->type = *type; - return ts; + return column; } void @@ -143,6 +143,7 @@ ovsdb_column_set_from_json(const struct json *json, return NULL; } else { + struct ovsdb_error *error = NULL; size_t i; if (json->type != JSON_ARRAY) { @@ -152,26 +153,34 @@ ovsdb_column_set_from_json(const struct json *json, /* XXX this is O(n**2) */ for (i = 0; i < json->u.array.n; i++) { struct ovsdb_column *column; + const char *s; if (json->u.array.elems[i]->type != JSON_STRING) { goto error; } - column = shash_find_data(&table->schema->columns, - json->u.array.elems[i]->u.string); - if (ovsdb_column_set_contains(set, column->index)) { + s = json->u.array.elems[i]->u.string; + column = shash_find_data(&table->schema->columns, s); + if (!column) { + error = ovsdb_syntax_error(json, NULL, "%s is not a valid " + "column name", s); + goto error; + } else if (ovsdb_column_set_contains(set, column->index)) { goto error; } ovsdb_column_set_add(set, column); } - return NULL; - } -error: - ovsdb_column_set_destroy(set); - return ovsdb_syntax_error(json, NULL, - "array of distinct column names expected"); + error: + ovsdb_column_set_destroy(set); + ovsdb_column_set_init(set); + if (!error) { + error = ovsdb_syntax_error(json, NULL, "array of distinct column " + "names expected"); + } + return error; + } } struct json *