[ovs-dev] [indexes 2/6] ovsdb: Move ovsdb_table_put_row() into test program.

Justin Pettit jpettit at nicira.com
Sat Jun 4 05:05:11 UTC 2011


Looks good.

--Justin


On Jun 2, 2011, at 4:19 PM, Ben Pfaff wrote:

> 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.
> ---
> ovsdb/table.c      |   14 --------------
> ovsdb/table.h      |    1 -
> tests/test-ovsdb.c |   14 ++++++++++++--
> 3 files changed, 12 insertions(+), 17 deletions(-)
> 
> diff --git a/ovsdb/table.c b/ovsdb/table.c
> index 2ea73bf..44a205e 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 95da740..8e93343 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 5b8f451..5594b40 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);
> -- 
> 1.7.4.4
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev




More information about the dev mailing list