diff options
author | Ben Pfaff <blp@nicira.com> | 2012-11-06 13:14:55 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2013-01-16 16:03:37 -0800 |
commit | cb22974d773942d66da42b700b8bca0db27a0920 (patch) | |
tree | 6412724be1bfc46d7235c4e2105c279bbe20d320 /ovsdb | |
parent | 4749f73d12c844b318af7f45cf45e1acac9f7c08 (diff) | |
download | openvswitch-cb22974d773942d66da42b700b8bca0db27a0920.tar.gz |
Replace most uses of assert by ovs_assert.
This is a straight search-and-replace, except that I also removed #include
<assert.h> from each file where there were no assert calls left.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'ovsdb')
-rw-r--r-- | ovsdb/execution.c | 3 | ||||
-rw-r--r-- | ovsdb/file.c | 9 | ||||
-rw-r--r-- | ovsdb/jsonrpc-server.c | 3 | ||||
-rw-r--r-- | ovsdb/log.c | 5 | ||||
-rwxr-xr-x | ovsdb/ovsdb-idlc.in | 24 | ||||
-rw-r--r-- | ovsdb/row.c | 3 | ||||
-rw-r--r-- | ovsdb/server.c | 6 | ||||
-rw-r--r-- | ovsdb/table.c | 9 | ||||
-rw-r--r-- | ovsdb/transaction.c | 12 | ||||
-rw-r--r-- | ovsdb/trigger.c | 3 |
10 files changed, 33 insertions, 44 deletions
diff --git a/ovsdb/execution.c b/ovsdb/execution.c index 300c247a3..027e9e18b 100644 --- a/ovsdb/execution.c +++ b/ovsdb/execution.c @@ -15,7 +15,6 @@ #include <config.h> -#include <assert.h> #include <limits.h> #include "column.h" @@ -154,7 +153,7 @@ ovsdb_execute(struct ovsdb *db, const struct ovsdb_session *session, op_name); } } else { - assert(ovsdb_parser_has_error(&parser)); + ovs_assert(ovsdb_parser_has_error(&parser)); } /* A parse error overrides any other error. diff --git a/ovsdb/file.c b/ovsdb/file.c index 43fcb9564..fd646f01c 100644 --- a/ovsdb/file.c +++ b/ovsdb/file.c @@ -17,7 +17,6 @@ #include "file.h" -#include <assert.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> @@ -129,7 +128,7 @@ ovsdb_file_open_log(const char *file_name, enum ovsdb_log_open_mode open_mode, struct ovsdb_error *error; struct json *json = NULL; - assert(logp || schemap); + ovs_assert(logp || schemap); error = ovsdb_log_open(file_name, open_mode, -1, &log); if (error) { @@ -194,7 +193,7 @@ ovsdb_file_open__(const char *file_name, struct ovsdb *db = NULL; /* In read-only mode there is no ovsdb_file so 'filep' must be null. */ - assert(!(read_only && filep)); + ovs_assert(!(read_only && filep)); open_mode = read_only ? OVSDB_LOG_READ_ONLY : OVSDB_LOG_READ_WRITE; error = ovsdb_file_open_log(file_name, open_mode, &log, @@ -504,7 +503,7 @@ ovsdb_file_save_copy(const char *file_name, int locking, struct ovsdb_error * ovsdb_file_read_schema(const char *file_name, struct ovsdb_schema **schemap) { - assert(schemap != NULL); + ovs_assert(schemap != NULL); return ovsdb_file_open_log(file_name, OVSDB_LOG_READ_ONLY, NULL, schemap); } @@ -562,7 +561,7 @@ ovsdb_file_create(struct ovsdb *db, struct ovsdb_log *log, static struct ovsdb_file * ovsdb_file_cast(struct ovsdb_replica *replica) { - assert(replica->class == &ovsdb_file_class); + ovs_assert(replica->class == &ovsdb_file_class); return CONTAINER_OF(replica, struct ovsdb_file, replica); } diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index 8e1c030c3..1d0b0e316 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -17,7 +17,6 @@ #include "jsonrpc-server.h" -#include <assert.h> #include <errno.h> #include "bitmap.h" @@ -1292,7 +1291,7 @@ ovsdb_jsonrpc_monitor_remove_all(struct ovsdb_jsonrpc_session *s) static struct ovsdb_jsonrpc_monitor * ovsdb_jsonrpc_monitor_cast(struct ovsdb_replica *replica) { - assert(replica->class == &ovsdb_jsonrpc_replica_class); + ovs_assert(replica->class == &ovsdb_jsonrpc_replica_class); return CONTAINER_OF(replica, struct ovsdb_jsonrpc_monitor, replica); } diff --git a/ovsdb/log.c b/ovsdb/log.c index b79535ac8..440e8d074 100644 --- a/ovsdb/log.c +++ b/ovsdb/log.c @@ -17,7 +17,6 @@ #include "log.h" -#include <assert.h> #include <errno.h> #include <fcntl.h> #include <stdlib.h> @@ -75,7 +74,7 @@ ovsdb_log_open(const char *name, enum ovsdb_log_open_mode open_mode, *filep = NULL; - assert(locking == -1 || locking == false || locking == true); + ovs_assert(locking == -1 || locking == false || locking == true); if (locking < 0) { locking = open_mode != OVSDB_LOG_READ_ONLY; } @@ -318,7 +317,7 @@ error: void ovsdb_log_unread(struct ovsdb_log *file) { - assert(file->mode == OVSDB_LOG_READ); + ovs_assert(file->mode == OVSDB_LOG_READ); file->offset = file->prev_offset; } diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 478109af6..dc0839eda 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -185,10 +185,10 @@ def printCIDLSource(schemaFile): #include <config.h> #include %s -#include <assert.h> #include <limits.h> #include "ovsdb-data.h" #include "ovsdb-error.h" +#include "util.h" #ifdef __CHECKER__ /* Sparse dislikes sizeof(bool) ("warning: expression using sizeof bool"). */ @@ -236,7 +236,7 @@ static void if type.is_smap(): print " size_t i;" print - print " assert(inited);" + print " ovs_assert(inited);" print " smap_init(&row->%s);" % columnName print " for (i = 0; i < datum->n; i++) {" print " smap_add(&row->%s," % columnName @@ -245,7 +245,7 @@ static void print " }" elif (type.n_min == 1 and type.n_max == 1) or type.is_optional_pointer(): print - print " assert(inited);" + print " ovs_assert(inited);" print " if (datum->n >= 1) {" if not type.key.ref_table: print " %s = datum->keys[0].%s;" % (keyVar, type.key.type.to_string()) @@ -270,7 +270,7 @@ static void nMax = "datum->n" print " size_t i;" print - print " assert(inited);" + print " ovs_assert(inited);" print " %s = NULL;" % keyVar if valueVar: print " %s = NULL;" % valueVar @@ -333,7 +333,7 @@ static void { struct %(s)s *row = %(s)s_cast(row_); - assert(inited);''' % {'s': structName, 'c': columnName} + ovs_assert(inited);''' % {'s': structName, 'c': columnName} if type.is_smap(): print " smap_destroy(&row->%s);" % columnName @@ -415,7 +415,7 @@ struct %(s)s * void %(s)s_verify_%(c)s(const struct %(s)s *row) { - assert(inited); + ovs_assert(inited); ovsdb_idl_txn_verify(&row->header_, &%(s)s_columns[%(S)s_COL_%(C)s]); }''' % {'s': structName, 'S': structName.upper(), @@ -426,7 +426,7 @@ void for columnName, column in sorted(table.columns.iteritems()): if column.type.value: valueParam = ',\n\tenum ovsdb_atomic_type value_type OVS_UNUSED' - valueType = '\n assert(value_type == %s);' % column.type.value.toAtomicType() + valueType = '\n ovs_assert(value_type == %s);' % column.type.value.toAtomicType() valueComment = "\n * 'value_type' must be %s." % column.type.value.toAtomicType() else: valueParam = '' @@ -452,7 +452,7 @@ const struct ovsdb_datum * %(s)s_get_%(c)s(const struct %(s)s *row, \tenum ovsdb_atomic_type key_type OVS_UNUSED%(v)s) { - assert(key_type == %(kt)s);%(vt)s + ovs_assert(key_type == %(kt)s);%(vt)s return ovsdb_idl_read(&row->header_, &%(s)s_col_%(c)s); }""" % {'s': structName, 'c': columnName, 'kt': column.type.key.toAtomicType(), @@ -469,7 +469,7 @@ void { struct ovsdb_datum datum; - assert(inited); + ovs_assert(inited); if (smap) { struct smap_node *node; size_t i; @@ -518,7 +518,7 @@ void print " struct ovsdb_datum datum;" if type.n_min == 1 and type.n_max == 1: print - print " assert(inited);" + print " ovs_assert(inited);" print " datum.n = 1;" print " datum.keys = xmalloc(sizeof *datum.keys);" print " " + type.key.copyCValue("datum.keys[0].%s" % type.key.type.to_string(), keyVar) @@ -529,7 +529,7 @@ void print " datum.values = NULL;" elif type.is_optional_pointer(): print - print " assert(inited);" + print " ovs_assert(inited);" print " if (%s) {" % keyVar print " datum.n = 1;" print " datum.keys = xmalloc(sizeof *datum.keys);" @@ -542,7 +542,7 @@ void else: print " size_t i;" print - print " assert(inited);" + print " ovs_assert(inited);" print " datum.n = %s;" % nVar print " datum.keys = xmalloc(%s * sizeof *datum.keys);" % nVar if type.value: diff --git a/ovsdb/row.c b/ovsdb/row.c index 450c32745..9b9f96a2a 100644 --- a/ovsdb/row.c +++ b/ovsdb/row.c @@ -17,7 +17,6 @@ #include "row.h" -#include <assert.h> #include <stddef.h> #include "dynamic-string.h" @@ -376,7 +375,7 @@ ovsdb_row_hash_contains_all(const struct ovsdb_row_hash *a, { struct ovsdb_row_hash_node *node; - assert(ovsdb_column_set_equals(&a->columns, &b->columns)); + ovs_assert(ovsdb_column_set_equals(&a->columns, &b->columns)); HMAP_FOR_EACH (node, hmap_node, &b->rows) { if (!ovsdb_row_hash_contains__(a, node->row, node->hmap_node.hash)) { return false; diff --git a/ovsdb/server.c b/ovsdb/server.c index ac2aa29df..bf4ef3c9c 100644 --- a/ovsdb/server.c +++ b/ovsdb/server.c @@ -17,8 +17,6 @@ #include "server.h" -#include <assert.h> - #include "hash.h" #include "ovsdb.h" @@ -35,7 +33,7 @@ ovsdb_session_init(struct ovsdb_session *session, struct ovsdb_server *server) void ovsdb_session_destroy(struct ovsdb_session *session) { - assert(hmap_is_empty(&session->waiters)); + ovs_assert(hmap_is_empty(&session->waiters)); hmap_destroy(&session->waiters); } @@ -101,7 +99,7 @@ ovsdb_lock_waiter_remove(struct ovsdb_lock_waiter *waiter) void ovsdb_lock_waiter_destroy(struct ovsdb_lock_waiter *waiter) { - assert(!waiter->lock); + ovs_assert(!waiter->lock); hmap_remove(&waiter->session->waiters, &waiter->session_node); free(waiter->lock_name); free(waiter); diff --git a/ovsdb/table.c b/ovsdb/table.c index 19f4d3173..0d4f52275 100644 --- a/ovsdb/table.c +++ b/ovsdb/table.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010, 2011 Nicira, Inc. +/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ #include "table.h" -#include <assert.h> #include <limits.h> #include "json.h" @@ -30,7 +29,7 @@ static void add_column(struct ovsdb_table_schema *ts, struct ovsdb_column *column) { - assert(!shash_find(&ts->columns, column->name)); + ovs_assert(!shash_find(&ts->columns, column->name)); column->index = shash_count(&ts->columns); shash_add(&ts->columns, column->name, column); } @@ -51,11 +50,11 @@ ovsdb_table_schema_create(const char *name, bool mutable, uuid = ovsdb_column_create("_uuid", false, true, &ovsdb_type_uuid); add_column(ts, uuid); - assert(uuid->index == OVSDB_COL_UUID); + ovs_assert(uuid->index == OVSDB_COL_UUID); version = ovsdb_column_create("_version", false, false, &ovsdb_type_uuid); add_column(ts, version); - assert(version->index == OVSDB_COL_VERSION); + ovs_assert(version->index == OVSDB_COL_VERSION); ts->n_indexes = 0; ts->indexes = NULL; diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c index cc890ad8d..646163a99 100644 --- a/ovsdb/transaction.c +++ b/ovsdb/transaction.c @@ -17,8 +17,6 @@ #include "transaction.h" -#include <assert.h> - #include "bitmap.h" #include "dynamic-string.h" #include "hash.h" @@ -111,7 +109,7 @@ ovsdb_txn_create(struct ovsdb *db) 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); } @@ -807,7 +805,7 @@ ovsdb_txn_commit(struct ovsdb_txn *txn, bool durable) 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; @@ -898,7 +896,7 @@ ovsdb_txn_row_modify(struct ovsdb_txn *txn, const 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; @@ -940,7 +938,7 @@ ovsdb_txn_row_delete(struct ovsdb_txn *txn, const struct ovsdb_row *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 { @@ -987,7 +985,7 @@ ovsdb_txn_table_destroy(struct ovsdb_txn_table *txn_table) { 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]); diff --git a/ovsdb/trigger.c b/ovsdb/trigger.c index a93b84404..74a1b0fdc 100644 --- a/ovsdb/trigger.c +++ b/ovsdb/trigger.c @@ -17,7 +17,6 @@ #include "trigger.h" -#include <assert.h> #include <limits.h> #include "json.h" @@ -124,7 +123,7 @@ ovsdb_trigger_try(struct ovsdb_trigger *t, long long int now) static void ovsdb_trigger_complete(struct ovsdb_trigger *t) { - assert(t->result != NULL); + ovs_assert(t->result != NULL); list_remove(&t->node); list_push_back(&t->session->completions, &t->node); } |