[ovs-dev] [indexes 1/6] ovsdb: Make ovsdb_column_set_from_json() take table schema instead of table.

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


Looks good.

--Justin


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

> This function took a struct ovsdb_table but only used the 'schema' member.
> An upcoming patch needs to parse a column set when only the schema is
> available, so to prepare for that this patch changes
> ovsdb_column_set_from_json() to only take the schema that it really needs.
> ---
> ovsdb/column.c     |    8 ++++----
> ovsdb/column.h     |    9 +++++----
> ovsdb/execution.c  |    8 +++++---
> tests/test-ovsdb.c |    3 ++-
> 4 files changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/ovsdb/column.c b/ovsdb/column.c
> index a22e1a2..be346e4 100644
> --- a/ovsdb/column.c
> +++ b/ovsdb/column.c
> @@ -1,4 +1,4 @@
> -/* Copyright (c) 2009, 2010 Nicira Networks
> +/* Copyright (c) 2009, 2010, 2011 Nicira Networks
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
> @@ -136,14 +136,14 @@ ovsdb_column_set_clone(struct ovsdb_column_set *new,
> 
> struct ovsdb_error *
> ovsdb_column_set_from_json(const struct json *json,
> -                           const struct ovsdb_table *table,
> +                           const struct ovsdb_table_schema *schema,
>                            struct ovsdb_column_set *set)
> {
>     ovsdb_column_set_init(set);
>     if (!json) {
>         struct shash_node *node;
> 
> -        SHASH_FOR_EACH (node, &table->schema->columns) {
> +        SHASH_FOR_EACH (node, &schema->columns) {
>             const struct ovsdb_column *column = node->data;
>             ovsdb_column_set_add(set, column);
>         }
> @@ -167,7 +167,7 @@ ovsdb_column_set_from_json(const struct json *json,
>             }
> 
>             s = json->u.array.elems[i]->u.string;
> -            column = shash_find_data(&table->schema->columns, s);
> +            column = shash_find_data(&schema->columns, s);
>             if (!column) {
>                 error = ovsdb_syntax_error(json, NULL, "%s is not a valid "
>                                            "column name", s);
> diff --git a/ovsdb/column.h b/ovsdb/column.h
> index b6f324c..d90c12a 100644
> --- a/ovsdb/column.h
> +++ b/ovsdb/column.h
> @@ -1,4 +1,4 @@
> -/* Copyright (c) 2009, 2010 Nicira Networks
> +/* Copyright (c) 2009, 2010, 2011 Nicira Networks
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
> @@ -21,6 +21,7 @@
> #include "ovsdb-types.h"
> 
> struct ovsdb_table;
> +struct ovsdb_table_schema;
> 
> /* A column or a column schema (currently there is no distinction). */
> struct ovsdb_column {
> @@ -68,9 +69,9 @@ void ovsdb_column_set_init(struct ovsdb_column_set *);
> void ovsdb_column_set_destroy(struct ovsdb_column_set *);
> void ovsdb_column_set_clone(struct ovsdb_column_set *,
>                             const struct ovsdb_column_set *);
> -struct ovsdb_error *ovsdb_column_set_from_json(const struct json *,
> -                                               const struct ovsdb_table *,
> -                                               struct ovsdb_column_set *);
> +struct ovsdb_error *ovsdb_column_set_from_json(
> +    const struct json *, const struct ovsdb_table_schema *,
> +    struct ovsdb_column_set *);
> struct json *ovsdb_column_set_to_json(const struct ovsdb_column_set *);
> 
> void ovsdb_column_set_add(struct ovsdb_column_set *,
> diff --git a/ovsdb/execution.c b/ovsdb/execution.c
> index cb1bec3..416016f 100644
> --- a/ovsdb/execution.c
> +++ b/ovsdb/execution.c
> @@ -364,10 +364,11 @@ ovsdb_execute_select(struct ovsdb_execution *x, struct ovsdb_parser *parser,
>                                           &condition);
>     }
>     if (!error) {
> -        error = ovsdb_column_set_from_json(columns_json, table, &columns);
> +        error = ovsdb_column_set_from_json(columns_json, table->schema,
> +                                           &columns);
>     }
>     if (!error) {
> -        error = ovsdb_column_set_from_json(sort_json, table, &sort);
> +        error = ovsdb_column_set_from_json(sort_json, table->schema, &sort);
>     }
>     if (!error) {
>         struct ovsdb_row_set rows = OVSDB_ROW_SET_INITIALIZER;
> @@ -606,7 +607,8 @@ ovsdb_execute_wait(struct ovsdb_execution *x, struct ovsdb_parser *parser,
>                                           &condition);
>     }
>     if (!error) {
> -        error = ovsdb_column_set_from_json(columns_json, table, &columns);
> +        error = ovsdb_column_set_from_json(columns_json, table->schema,
> +                                           &columns);
>     }
>     if (!error) {
>         if (timeout) {
> diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
> index 8fe1727..5b8f451 100644
> --- a/tests/test-ovsdb.c
> +++ b/tests/test-ovsdb.c
> @@ -1109,7 +1109,8 @@ do_query_distinct(int argc OVS_UNUSED, char *argv[])
> 
>     /* Parse column set. */
>     json = parse_json(argv[4]);
> -    check_ovsdb_error(ovsdb_column_set_from_json(json, table, &columns));
> +    check_ovsdb_error(ovsdb_column_set_from_json(json, table->schema,
> +                                                 &columns));
>     json_destroy(json);
> 
>     /* Parse rows, add to table. */
> -- 
> 1.7.4.4
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev




More information about the dev mailing list