From: Ben Pfaff Date: Wed, 1 Jun 2011 23:17:00 +0000 (-0700) Subject: ovsdb: Move ovsdb_table_put_row() into test program. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29d7226e8b17ce1891aaba8f3009715b24fa664f;p=openvswitch ovsdb: Move ovsdb_table_put_row() into test program. This function is not useful inside ovsdb itself but only in the "test-ovsdb" test program. To avoid the temptation to use it incorrectly inside ovsdb, this commit moves it into the test program. --- diff --git a/ovsdb/table.c b/ovsdb/table.c index 2ea73bf8..44a205e9 100644 --- a/ovsdb/table.c +++ b/ovsdb/table.c @@ -251,17 +251,3 @@ ovsdb_table_get_row(const struct ovsdb_table *table, const struct uuid *uuid) return NULL; } - -/* This is probably not the function you want. Use ovsdb_txn_row_modify() - * instead. */ -bool -ovsdb_table_put_row(struct ovsdb_table *table, struct ovsdb_row *row) -{ - const struct uuid *uuid = ovsdb_row_get_uuid(row); - if (!ovsdb_table_get_row(table, uuid)) { - hmap_insert(&table->rows, &row->hmap_node, uuid_hash(uuid)); - return true; - } else { - return false; - } -} diff --git a/ovsdb/table.h b/ovsdb/table.h index 95da7403..8e933438 100644 --- a/ovsdb/table.h +++ b/ovsdb/table.h @@ -62,6 +62,5 @@ void ovsdb_table_destroy(struct ovsdb_table *); const struct ovsdb_row *ovsdb_table_get_row(const struct ovsdb_table *, const struct uuid *); -bool ovsdb_table_put_row(struct ovsdb_table *, struct ovsdb_row *); #endif /* ovsdb/table.h */ diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index 5b8f4519..5594b40f 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -975,6 +975,16 @@ do_execute_mutations(int argc OVS_UNUSED, char *argv[]) ovsdb_table_destroy(table); /* Also destroys 'ts'. */ } +/* Inserts a row, without bothering to update metadata such as refcounts. */ +static void +put_row(struct ovsdb_table *table, struct ovsdb_row *row) +{ + const struct uuid *uuid = ovsdb_row_get_uuid(row); + if (!ovsdb_table_get_row(table, uuid)) { + hmap_insert(&table->rows, &row->hmap_node, uuid_hash(uuid)); + } +} + struct do_query_cbdata { struct uuid *row_uuids; int *counts; @@ -1031,7 +1041,7 @@ do_query(int argc OVS_UNUSED, char *argv[]) UUID_ARGS(ovsdb_row_get_uuid(row))); } cbdata.row_uuids[i] = *ovsdb_row_get_uuid(row); - ovsdb_table_put_row(table, row); + put_row(table, row); } json_destroy(json); @@ -1152,7 +1162,7 @@ do_query_distinct(int argc OVS_UNUSED, char *argv[]) ovs_fatal(0, "duplicate UUID "UUID_FMT" in table", UUID_ARGS(ovsdb_row_get_uuid(row))); } - ovsdb_table_put_row(table, row); + put_row(table, row); } json_destroy(json);