: (X) <= UINT_MAX / (Y) ? (unsigned int) (X) * (unsigned int) (Y) \
: UINT_MAX)
-/* Like the standard assert macro, except writes the failure message to the
- * log. */
+/* Like the standard assert macro, except:
+ *
+ * - Writes the failure message to the log.
+ *
+ * - Always evaluates the condition, even with NDEBUG. */
#ifndef NDEBUG
#define ovs_assert(CONDITION) \
(OVS_LIKELY(CONDITION) \
struct cmap_impl *impl = cmap_get_impl(cmap);
uint32_t h1 = rehash(impl, hash);
uint32_t h2 = other_hash(h1);
- bool ok;
- ok = cmap_replace__(impl, old_node, new_node, hash, h1)
- || cmap_replace__(impl, old_node, new_node, hash, h2);
- ovs_assert(ok);
+ ovs_assert(cmap_replace__(impl, old_node, new_node, hash, h1) ||
+ cmap_replace__(impl, old_node, new_node, hash, h2));
if (!new_node) {
impl->n--;
return 0;
}
- const char *rc;
char v6_addr_str[IPV6_SCAN_LEN] = {0};
- rc = inet_ntop(AF_INET6, &v6_addr_rep.ipv6_aligned, v6_addr_str,
- IPV6_SCAN_LEN - 1);
- ovs_assert(rc != NULL);
+ ovs_assert(inet_ntop(AF_INET6, &v6_addr_rep.ipv6_aligned, v6_addr_str,
+ IPV6_SCAN_LEN - 1));
size_t replace_addr_size = strlen(v6_addr_str);
void
hmapx_add_assert(struct hmapx *map, void *data)
{
- bool added OVS_UNUSED = hmapx_add(map, data);
- ovs_assert(added);
+ ovs_assert(hmapx_add(map, data));
}
/* Removes all of the nodes from 'map'. */
void
hmapx_find_and_delete_assert(struct hmapx *map, const void *data)
{
- bool deleted OVS_UNUSED = hmapx_find_and_delete(map, data);
- ovs_assert(deleted);
+ ovs_assert(hmapx_find_and_delete(map, data));
}
/* Searches for 'data' in 'map'. Returns its node, if found, otherwise a null
static void
odp_set_tunnel_action(const struct nlattr *a, struct flow_tnl *tun_key)
{
- enum odp_key_fitness fitness;
-
- fitness = odp_tun_key_from_attr(a, tun_key);
- ovs_assert(fitness != ODP_FIT_ERROR);
+ ovs_assert(odp_tun_key_from_attr(a, tun_key) != ODP_FIT_ERROR);
}
static void
/* Otherwise, if there more LSEs in base than are common between
* base and flow then pop the topmost one. */
ovs_be16 dl_type;
- bool popped;
-
/* If all the LSEs are to be popped and this is not the outermost
* LSE then use ETH_TYPE_MPLS as the ethertype parameter of the
* POP_MPLS action instead of flow->dl_type.
dl_type = flow->dl_type;
}
nl_msg_put_be16(odp_actions, OVS_ACTION_ATTR_POP_MPLS, dl_type);
- popped = flow_pop_mpls(base, base_n, flow->dl_type, NULL);
- ovs_assert(popped);
+ ovs_assert(flow_pop_mpls(base, base_n, flow->dl_type, NULL));
base_n--;
}
}
ofphdrs_decode_assert(struct ofphdrs *hdrs,
const struct ofp_header *oh, size_t length)
{
- enum ofperr error = ofphdrs_decode(hdrs, oh, length);
- ovs_assert(!error);
+ ovs_assert(!ofphdrs_decode(hdrs, oh, length));
}
static bool
enum ofpraw
ofpraw_decode_assert(const struct ofp_header *oh)
{
- enum ofperr error;
enum ofpraw raw;
-
- error = ofpraw_decode(&raw, oh);
- ovs_assert(!error);
+ ovs_assert(!ofpraw_decode(&raw, oh));
return raw;
}
enum ofpraw
ofpraw_pull_assert(struct ofpbuf *msg)
{
- enum ofperr error;
enum ofpraw raw;
-
- error = ofpraw_pull(&raw, msg);
- ovs_assert(!error);
+ ovs_assert(!ofpraw_pull(&raw, msg));
return raw;
}
{
enum ofpraw request_raw;
enum ofpraw reply_raw;
- enum ofperr error;
- error = ofpraw_decode_partial(&request_raw, request,
- ntohs(request->length));
- ovs_assert(!error);
+ ovs_assert(!ofpraw_decode_partial(&request_raw, request,
+ ntohs(request->length)));
reply_raw = ofpraw_stats_request_to_reply(request_raw, request->version);
ovs_assert(reply_raw);
void
ofpraw_put_stats_reply(const struct ofp_header *request, struct ofpbuf *buf)
{
- enum ofperr error;
enum ofpraw raw;
- error = ofpraw_decode_partial(&raw, request, ntohs(request->length));
- ovs_assert(!error);
+ ovs_assert(!ofpraw_decode_partial(&raw, request, ntohs(request->length)));
raw = ofpraw_stats_request_to_reply(raw, request->version);
ovs_assert(raw);
const struct raw_instance *instance = raw_instance_get(info, version);
enum ofpraw reply_raw;
struct ofphdrs hdrs;
- enum ofperr error;
hdrs = instance->hdrs;
switch ((enum ofp_version)hdrs.version) {
OVS_NOT_REACHED();
}
- error = ofpraw_from_ofphdrs(&reply_raw, &hdrs);
- ovs_assert(!error);
+ ovs_assert(!ofpraw_from_ofphdrs(&reply_raw, &hdrs));
return reply_raw;
}
ofpmp_decode_raw(struct ovs_list *replies)
{
struct ofpbuf *msg = ofpbuf_from_list(ovs_list_back(replies));
- enum ofperr error;
enum ofpraw raw;
-
- error = ofpraw_decode_partial(&raw, msg->data, msg->size);
- ovs_assert(!error);
+ ovs_assert(!ofpraw_decode_partial(&raw, msg->data, msg->size));
return raw;
}
struct ovs_list *replies)
{
struct ofpbuf *reply;
- enum ofperr error;
ofp_port_t port;
uint32_t queue;
- error = ofputil_decode_queue_get_config_request(request, &port, &queue);
- ovs_assert(!error);
+ ovs_assert(!ofputil_decode_queue_get_config_request(request, &port,
+ &queue));
enum ofpraw raw = ofpraw_decode_assert(request);
switch ((int) raw) {
struct ofputil_role_status *rs)
{
struct ofpbuf b = ofpbuf_const_initializer(oh, ntohs(oh->length));
- enum ofpraw raw = ofpraw_pull_assert(&b);
- ovs_assert(raw == OFPRAW_OFPT14_ROLE_STATUS);
+ ovs_assert(ofpraw_pull_assert(&b) == OFPRAW_OFPT14_ROLE_STATUS);
const struct ofp14_role_status *r = b.msg;
if (r->role != htonl(OFPCR12_ROLE_NOCHANGE) &&
struct ofpbuf b = ofpbuf_const_initializer(outer, ntohs(outer->length));
/* Skip past outer message. */
- enum ofpraw outer_raw = ofpraw_pull_assert(&b);
- ovs_assert(outer_raw == OFPRAW_OFPT14_REQUESTFORWARD);
+ ovs_assert(ofpraw_pull_assert(&b) == OFPRAW_OFPT14_REQUESTFORWARD);
/* Validate inner message. */
if (b.size < sizeof(struct ofp_header)) {
}
}
if (n != a->n) {
- struct ovsdb_error *error;
a->n = n;
- error = ovsdb_datum_sort(a, type->key.type);
- ovs_assert(!error);
+ ovs_assert(!ovsdb_datum_sort(a, type->key.type));
}
}
void
shash_add_assert(struct shash *sh, const char *name, const void *data)
{
- bool added OVS_UNUSED = shash_add_once(sh, name, data);
- ovs_assert(added);
+ ovs_assert(shash_add_once(sh, name, data));
}
/* Searches for 'name' in 'sh'. If it does not already exist, adds it along
void
sset_add_assert(struct sset *set, const char *name)
{
- bool added OVS_UNUSED = sset_add(set, name);
- ovs_assert(added);
+ ovs_assert(sset_add(set, name));
}
/* Adds a copy of each of the 'n' names in 'names' to 'set'. */
void
sset_find_and_delete_assert(struct sset *set, const char *name)
{
- bool deleted OVS_UNUSED = sset_find_and_delete(set, name);
- ovs_assert(deleted);
+ ovs_assert(sset_find_and_delete(set, name));
}
/* Removes a string from 'set' and returns a copy of it. The caller must free
int snaplen;
/* Get the details of the mirror represented by the rightmost 1-bit. */
- bool has_mirror = mirror_get(xbridge->mbridge, raw_ctz(mirrors),
- &vlans, &dup_mirrors,
- &out, &snaplen, &out_vlan);
- ovs_assert(has_mirror);
+ ovs_assert(mirror_get(xbridge->mbridge, raw_ctz(mirrors),
+ &vlans, &dup_mirrors,
+ &out, &snaplen, &out_vlan));
/* If this mirror selects on the basis of VLAN, and it does not select
remove_db(struct server_config *config, struct shash_node *node)
{
struct db *db;
- bool ok;
db = node->data;
- ok = ovsdb_jsonrpc_server_remove_db(config->jsonrpc, db->db);
- ovs_assert(ok);
+ ovs_assert(ovsdb_jsonrpc_server_remove_db(config->jsonrpc, db->db));
close_db(db);
shash_delete(config->all_dbs, node);
{
free(sync_from);
sync_from = xstrdup(sync_from_);
- char *err = set_blacklist_tables(exclude_tables, false);
/* Caller should have verified that the 'exclude_tables' is
* parseable. An error here is unexpected. */
- ovs_assert(!err);
+ ovs_assert(!set_blacklist_tables(exclude_tables, false));
replication_dbs_destroy();