I noticed that there were lots of calls to ovsdb_datum_sort_unique() from "set" functions in generated IDL code. This moves that call into common code, reducing redundancy.
There are more calls to the same function that are a little harder to remove. Signed-off-by: Ben Pfaff <b...@ovn.org> --- lib/ovsdb-idl.c | 17 ++++++++++++----- ovsdb/ovsdb-idlc.in | 2 -- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index ffee4b6..a1fcd19 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -3159,9 +3159,10 @@ discard_datum: * itself and the structs derived from it (e.g. the "struct ovsrec_*", for * ovs-vswitchd). * - * 'datum' must have the correct type for its column. The IDL does not check - * that it meets schema constraints, but ovsdb-server will do so at commit time - * so it had better be correct. + * 'datum' must have the correct type for its column, but it needs not be + * sorted or unique because this function will take care of that. The IDL does + * not check that it meets schema constraints, but ovsdb-server will do so at + * commit time so it had better be correct. * * A transaction must be in progress. Replication of 'column' must not have * been disabled (by calling ovsdb_idl_omit()). @@ -3177,11 +3178,17 @@ ovsdb_idl_txn_write(const struct ovsdb_idl_row *row, const struct ovsdb_idl_column *column, struct ovsdb_datum *datum) { + ovsdb_datum_sort_unique(datum, + column->type.key.type, column->type.value.type); ovsdb_idl_txn_write__(row, column, datum, true); } -/* Similar to ovsdb_idl_txn_write(), except that the caller retains ownership - * of 'datum' and what it points to. */ +/* Similar to ovsdb_idl_txn_write(), except: + * + * - The caller retains ownership of 'datum' and what it points to. + * + * - The caller must ensure that 'datum' is sorted and unique (e.g. via + * ovsdb_datum_sort_unique().) */ void ovsdb_idl_txn_write_clone(const struct ovsdb_idl_row *row, const struct ovsdb_idl_column *column, diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 17b4453..680a205 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -763,8 +763,6 @@ void valueType = type.value.toAtomicType() else: valueType = "OVSDB_TYPE_VOID" - print " ovsdb_datum_sort_unique(&datum, %s, %s);" % ( - type.key.toAtomicType(), valueType) txn_write_func = "ovsdb_idl_txn_write" print " %(f)s(&row->header_, &%(s)s_col_%(c)s, &datum);" \ % {'f': txn_write_func, -- 2.1.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev