2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

db-ctl-base: Drop redundant 'table' field from struct ctl_row_id.

The 'table' field is redundant because the required 'column' field
implies the table that the column is a part of.

This simplifies the users and makes it harder to get these things wrong.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
This commit is contained in:
Ben Pfaff
2017-04-27 13:54:53 -07:00
parent 5d476f28b7
commit a0b02897cf
8 changed files with 82 additions and 66 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -798,26 +798,48 @@ ovsdb_idl_check_consistency(const struct ovsdb_idl *idl)
ovs_assert(ok);
}
static unsigned char *
ovsdb_idl_get_mode(struct ovsdb_idl *idl,
const struct ovsdb_idl_column *column)
const struct ovsdb_idl_class *
ovsdb_idl_get_class(const struct ovsdb_idl *idl)
{
size_t i;
ovs_assert(!idl->change_seqno);
for (i = 0; i < idl->class->n_tables; i++) {
const struct ovsdb_idl_table *table = &idl->tables[i];
const struct ovsdb_idl_table_class *tc = table->class;
return idl->class;
}
/* Given 'column' in some table in 'class', returns the table's class. */
const struct ovsdb_idl_table_class *
ovsdb_idl_table_class_from_column(const struct ovsdb_idl_class *class,
const struct ovsdb_idl_column *column)
{
for (size_t i = 0; i < class->n_tables; i++) {
const struct ovsdb_idl_table_class *tc = &class->tables[i];
if (column >= tc->columns && column < &tc->columns[tc->n_columns]) {
return &table->modes[column - tc->columns];
return tc;
}
}
OVS_NOT_REACHED();
}
/* Given 'column' in some table in 'idl', returns the table. */
static struct ovsdb_idl_table *
ovsdb_idl_table_from_column(struct ovsdb_idl *idl,
const struct ovsdb_idl_column *column)
{
const struct ovsdb_idl_table_class *tc =
ovsdb_idl_table_class_from_column(idl->class, column);
return &idl->tables[tc - idl->class->tables];
}
static unsigned char *
ovsdb_idl_get_mode(struct ovsdb_idl *idl,
const struct ovsdb_idl_column *column)
{
ovs_assert(!idl->change_seqno);
const struct ovsdb_idl_table *table = ovsdb_idl_table_from_column(idl,
column);
return &table->modes[column - table->class->columns];
}
static void
add_ref_table(struct ovsdb_idl *idl, const struct ovsdb_base_type *base)
{