summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-05-31 09:09:43 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-06-01 11:02:35 +0200
commit58d54740785eb2c7208a01afb5bd9736e5808069 (patch)
tree19d24c817201842b3781328d5f1a5fb25138a496
parentf84ebfdbc64b774b1f00f5b98494e66b8a88fb0b (diff)
Assertions improved
This patch is replaces generic xs_asserts by errno_assers and alloc_asserts as appropriate. It is based on 0MQ patch by Martin Hurton. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
-rw-r--r--src/ctx.cpp2
-rw-r--r--src/dist.cpp2
-rw-r--r--src/lb.cpp2
-rw-r--r--src/pgm_sender.cpp2
-rw-r--r--src/prefix_filter.cpp8
-rw-r--r--src/session_base.cpp4
-rw-r--r--src/signaler.cpp4
-rw-r--r--src/socket_base.cpp4
-rw-r--r--src/xrep.cpp2
-rw-r--r--src/xsub.cpp2
10 files changed, 16 insertions, 16 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 6460dd2..7909099 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -268,7 +268,7 @@ int xs::ctx_t::terminate ()
int rc = mailbox_recv (&term_mailbox, &cmd, -1);
if (rc == -1 && errno == EINTR)
return -1;
- xs_assert (rc == 0);
+ errno_assert (rc == 0);
xs_assert (cmd.type == command_t::done);
slot_sync.lock ();
xs_assert (sockets.empty ());
diff --git a/src/dist.cpp b/src/dist.cpp
index 4e94276..6106394 100644
--- a/src/dist.cpp
+++ b/src/dist.cpp
@@ -153,7 +153,7 @@ void xs::dist_t::distribute (msg_t *msg_, int flags_)
int rc = msg_->close ();
errno_assert (rc == 0);
rc = msg_->init ();
- xs_assert (rc == 0);
+ errno_assert (rc == 0);
return;
}
diff --git a/src/lb.cpp b/src/lb.cpp
index 3cfdef8..1fb9fc0 100644
--- a/src/lb.cpp
+++ b/src/lb.cpp
@@ -84,7 +84,7 @@ int xs::lb_t::send (msg_t *msg_, int flags_)
int rc = msg_->close ();
errno_assert (rc == 0);
rc = msg_->init ();
- xs_assert (rc == 0);
+ errno_assert (rc == 0);
return 0;
}
diff --git a/src/pgm_sender.cpp b/src/pgm_sender.cpp
index 528ac7a..d8d77b9 100644
--- a/src/pgm_sender.cpp
+++ b/src/pgm_sender.cpp
@@ -215,7 +215,7 @@ void xs::pgm_sender_t::out_event (fd_t fd_)
xs_assert (!tx_timer);
tx_timer = add_timer (timeout);
} else
- xs_assert (errno == EBUSY);
+ errno_assert (errno == EBUSY);
}
}
diff --git a/src/prefix_filter.cpp b/src/prefix_filter.cpp
index abf68d0..b166bca 100644
--- a/src/prefix_filter.cpp
+++ b/src/prefix_filter.cpp
@@ -111,7 +111,7 @@ static bool pfx_add (pfx_node_t *node_,
(node_->min < c ? c - node_->min : node_->min - c) + 1;
node_->next.table = (pfx_node_t**)
malloc (sizeof (pfx_node_t*) * node_->count);
- xs_assert (node_->next.table);
+ alloc_assert (node_->next.table);
for (unsigned short i = 0; i != node_->count; ++i)
node_->next.table [i] = 0;
node_->min = std::min (node_->min, c);
@@ -293,7 +293,7 @@ static void pfx_rm_all (pfx_node_t *node_, void *subscribers_,
node_->count = new_max - new_min + 1;
node_->next.table =
(pfx_node_t**) malloc (sizeof (pfx_node_t*) * node_->count);
- xs_assert (node_->next.table);
+ alloc_assert (node_->next.table);
memmove (node_->next.table, old_table + (new_min - node_->min),
sizeof (pfx_node_t*) * node_->count);
@@ -393,7 +393,7 @@ static bool pfx_rm (pfx_node_t *node_, const unsigned char *prefix_,
node_->count = node_->count - (new_min - node_->min);
node_->next.table = (pfx_node_t**)
malloc (sizeof (pfx_node_t*) * node_->count);
- xs_assert (node_->next.table);
+ alloc_assert (node_->next.table);
memmove (node_->next.table, old_table + (new_min - node_->min),
sizeof (pfx_node_t*) * node_->count);
@@ -417,7 +417,7 @@ static bool pfx_rm (pfx_node_t *node_, const unsigned char *prefix_,
pfx_node_t **old_table = node_->next.table;
node_->next.table = (pfx_node_t**)
malloc (sizeof (pfx_node_t*) * node_->count);
- xs_assert (node_->next.table);
+ alloc_assert (node_->next.table);
memmove (node_->next.table, old_table,
sizeof (pfx_node_t*) * node_->count);
diff --git a/src/session_base.cpp b/src/session_base.cpp
index da9ee8e..12d2e8d 100644
--- a/src/session_base.cpp
+++ b/src/session_base.cpp
@@ -461,7 +461,7 @@ void xs::session_base_t::start_connecting (bool wait_)
alloc_assert (pgm_sender);
int rc = pgm_sender->init (udp_encapsulation, address.c_str ());
- xs_assert (rc == 0);
+ errno_assert (rc == 0);
send_attach (this, pgm_sender);
}
@@ -473,7 +473,7 @@ void xs::session_base_t::start_connecting (bool wait_)
alloc_assert (pgm_receiver);
int rc = pgm_receiver->init (udp_encapsulation, address.c_str ());
- xs_assert (rc == 0);
+ errno_assert (rc == 0);
send_attach (this, pgm_receiver);
}
diff --git a/src/signaler.cpp b/src/signaler.cpp
index a9db3f2..cf1e0fd 100644
--- a/src/signaler.cpp
+++ b/src/signaler.cpp
@@ -332,7 +332,7 @@ int xs::signaler_wait (xs::signaler_t *self_, int timeout_)
pfd.events = POLLIN;
int rc = poll (&pfd, 1, timeout_);
if (unlikely (rc < 0)) {
- xs_assert (errno == EINTR);
+ errno_assert (errno == EINTR);
return -1;
}
else if (unlikely (rc == 0)) {
@@ -358,7 +358,7 @@ int xs::signaler_wait (xs::signaler_t *self_, int timeout_)
int rc = select (self_->r + 1, &self_->fds, NULL, NULL,
timeout_ >= 0 ? &timeout : NULL);
if (unlikely (rc < 0)) {
- xs_assert (errno == EINTR);
+ errno_assert (errno == EINTR);
return -1;
}
#endif
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index 960bd2c..9de8735 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -461,7 +461,7 @@ int xs::socket_base_t::connect (const char *addr_)
if (options.send_identity) {
msg_t id;
rc = id.init_size (options.identity_size);
- xs_assert (rc == 0);
+ errno_assert (rc == 0);
memcpy (id.data (), options.identity, options.identity_size);
id.set_flags (msg_t::identity);
bool written = ppair [0]->write (&id);
@@ -473,7 +473,7 @@ int xs::socket_base_t::connect (const char *addr_)
if (peer.options.send_identity) {
msg_t id;
rc = id.init_size (peer.options.identity_size);
- xs_assert (rc == 0);
+ errno_assert (rc == 0);
memcpy (id.data (), peer.options.identity,
peer.options.identity_size);
id.set_flags (msg_t::identity);
diff --git a/src/xrep.cpp b/src/xrep.cpp
index 30f1419..0e6acb2 100644
--- a/src/xrep.cpp
+++ b/src/xrep.cpp
@@ -319,7 +319,7 @@ bool xs::xrep_t::xhas_in ()
id.close ();
return false;
}
- xs_assert (rc == 0);
+ errno_assert (rc == 0);
// We have first part of the message prefetched now. We will store the
// prefetched identity as well.
diff --git a/src/xsub.cpp b/src/xsub.cpp
index 9255ceb..0a9ff7e 100644
--- a/src/xsub.cpp
+++ b/src/xsub.cpp
@@ -200,7 +200,7 @@ void xs::xsub_t::send_subscription (pipe_t *pipe_, bool subscribe_,
// Create the subsctription message.
msg_t msg;
int rc = msg.init_size (size_ + 4);
- xs_assert (rc == 0);
+ errno_assert (rc == 0);
unsigned char *data = (unsigned char*) msg.data ();
put_uint16 (data, subscribe_ ? SP_PUBSUB_CMD_SUBSCRIBE :
SP_PUBSUB_CMD_UNSUBSCRIBE);