From a1ec42a39c4a58ad7d67699900514b8d62f8d792 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 16 Jun 2010 14:08:49 -0700 Subject: [PATCH] ovsdb-idlc: Check and restore ovsdb_datum invariants when setting data. ovsdb_datum has an important invariant (documented in the large comment on the declaration of struct ovsdb_datum) that a lot of code relies upon: keys must be unique and in sorted order. Most code that creates or modifies ovsdb_datum structures maintains this invariant. However, the "set" functions generated by ovsdb-idlc.in do not check or restore it. This commit adds that checking. This might fix an actual bug or two--none have been reported--but mostly it is just to add some additional checking to avoid future subtle bugs. --- ovsdb/ovsdb-idlc.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 9a235e27e..e8ec76e15 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -456,6 +456,12 @@ void if type.value: print " " + type.value.copyCValue("datum.values[i].%s" % type.value.type, "%s[i]" % valueVar) print " }" + if type.value: + valueType = type.value.toAtomicType() + else: + valueType = "OVSDB_TYPE_VOID" + print " ovsdb_datum_sort_unique(&datum, %s, %s);" % ( + type.key.toAtomicType(), valueType) print " ovsdb_idl_txn_write(&row->header_, &%(s)s_columns[%(S)s_COL_%(C)s], &datum);" \ % {'s': structName, 'S': structName.upper(), -- 2.43.0