-/* Copyright (c) 2009, 2010, 2011 Nicira Networks
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "transaction.h"
-#include <assert.h>
-
#include "bitmap.h"
#include "dynamic-string.h"
#include "hash.h"
static void
ovsdb_txn_free(struct ovsdb_txn *txn)
{
- assert(list_is_empty(&txn->txn_tables));
+ ovs_assert(list_is_empty(&txn->txn_tables));
ds_destroy(&txn->comment);
free(txn);
}
} else {
return ovsdb_error("referential integrity violation",
"cannot delete %s row "UUID_FMT" because "
- "of %zu remaining reference(s)",
+ "of %"PRIuSIZE" remaining reference(s)",
r->table->schema->name, UUID_ARGS(&r->uuid),
r->n_refs);
}
add_weak_ref(struct ovsdb_txn *txn,
const struct ovsdb_row *src_, const struct ovsdb_row *dst_)
{
- struct ovsdb_row *src = (struct ovsdb_row *) src_;
- struct ovsdb_row *dst = (struct ovsdb_row *) dst_;
+ struct ovsdb_row *src = CONST_CAST(struct ovsdb_row *, src_);
+ struct ovsdb_row *dst = CONST_CAST(struct ovsdb_row *, dst_);
struct ovsdb_weak_ref *weak;
if (src == dst) {
if (n_rows > max_rows) {
return ovsdb_error("constraint violation",
"transaction causes \"%s\" table to contain "
- "%zu rows, greater than the schema-defined "
+ "%"PRIuSIZE" rows, greater than the schema-defined "
"limit of %u row(s)",
t->table->schema->name, n_rows, max_rows);
}
if (error) {
/* We don't support two-phase commit so only the first replica is
* allowed to report an error. */
- assert(&replica->node == txn->db->replicas.next);
+ ovs_assert(&replica->node == txn->db->replicas.next);
ovsdb_txn_abort(txn);
return error;
const struct ovsdb_row *old_, struct ovsdb_row *new)
{
const struct ovsdb_row *row = old_ ? old_ : new;
- struct ovsdb_row *old = (struct ovsdb_row *) old_;
+ struct ovsdb_row *old = CONST_CAST(struct ovsdb_row *, old_);
size_t n_columns = shash_count(&table->schema->columns);
struct ovsdb_txn_table *txn_table;
struct ovsdb_txn_row *txn_row;
struct ovsdb_row *
ovsdb_txn_row_modify(struct ovsdb_txn *txn, const struct ovsdb_row *ro_row_)
{
- struct ovsdb_row *ro_row = (struct ovsdb_row *) ro_row_;
+ struct ovsdb_row *ro_row = CONST_CAST(struct ovsdb_row *, ro_row_);
if (ro_row->txn_row) {
- assert(ro_row == ro_row->txn_row->new);
+ ovs_assert(ro_row == ro_row->txn_row->new);
return ro_row;
} else {
struct ovsdb_table *table = ro_row->table;
void
ovsdb_txn_row_delete(struct ovsdb_txn *txn, const struct ovsdb_row *row_)
{
- struct ovsdb_row *row = (struct ovsdb_row *) row_;
+ struct ovsdb_row *row = CONST_CAST(struct ovsdb_row *, row_);
struct ovsdb_table *table = row->table;
struct ovsdb_txn_row *txn_row = row->txn_row;
if (!txn_row) {
ovsdb_txn_row_create(txn, table, row, NULL);
} else {
- assert(txn_row->new == row);
+ ovs_assert(txn_row->new == row);
if (txn_row->old) {
txn_row->new = NULL;
} else {
{
size_t i;
- assert(hmap_is_empty(&txn_table->txn_rows));
+ ovs_assert(hmap_is_empty(&txn_table->txn_rows));
for (i = 0; i < txn_table->table->schema->n_indexes; i++) {
hmap_destroy(&txn_table->txn_indexes[i]);
}
+ free(txn_table->txn_indexes);
txn_table->table->txn_table = NULL;
hmap_destroy(&txn_table->txn_rows);