]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ovsdb-idl: Sort and unique-ify datum in ovsdb_idl_txn_write().
authorBen Pfaff <blp@ovn.org>
Wed, 31 Aug 2016 18:42:53 +0000 (11:42 -0700)
committerBen Pfaff <blp@ovn.org>
Wed, 19 Oct 2016 18:39:14 +0000 (11:39 -0700)
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 <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
lib/ovsdb-idl.c
ovsdb/ovsdb-idlc.in

index ffee4b6cff89129cc77f2264425e9c20d82b160a..a1fcd1913176207370fbe9ec9067afa76b1f96fc 100644 (file)
@@ -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,
index 17b44534982a4ce9a4dd4941f7ae8b591f53d584..680a205d69c121cfa1933e9f5c78a1bf16a657bf 100755 (executable)
@@ -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,