Unverified Commit 6a5051fa authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #3114 from sigiesec/fix-some-style-issues

Fix some code style issues
parents cbd52feb e19823d8
...@@ -72,7 +72,7 @@ struct blob_t ...@@ -72,7 +72,7 @@ struct blob_t
blob_t () : data_ (0), size_ (0), owned_ (true) {} blob_t () : data_ (0), size_ (0), owned_ (true) {}
// Creates a blob_t of a given size, with uninitialized content. // Creates a blob_t of a given size, with uninitialized content.
blob_t (const size_t size) : explicit blob_t (const size_t size) :
data_ ((unsigned char *) malloc (size)), data_ ((unsigned char *) malloc (size)),
size_ (size), size_ (size),
owned_ (true) owned_ (true)
......
...@@ -57,6 +57,8 @@ void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) ...@@ -57,6 +57,8 @@ void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_)
rc = pipe_->write (&probe_msg_); rc = pipe_->write (&probe_msg_);
// zmq_assert (rc) is not applicable here, since it is not a bug. // zmq_assert (rc) is not applicable here, since it is not a bug.
(void) rc;
pipe_->flush (); pipe_->flush ();
rc = probe_msg_.close (); rc = probe_msg_.close ();
......
...@@ -108,17 +108,21 @@ void zmq::shared_message_memory_allocator::deallocate () ...@@ -108,17 +108,21 @@ void zmq::shared_message_memory_allocator::deallocate ()
if (buf && !c->sub (1)) { if (buf && !c->sub (1)) {
std::free (buf); std::free (buf);
} }
release (); clear ();
} }
unsigned char *zmq::shared_message_memory_allocator::release () unsigned char *zmq::shared_message_memory_allocator::release ()
{ {
unsigned char *b = buf; unsigned char *b = buf;
clear ();
return b;
}
void zmq::shared_message_memory_allocator::clear ()
{
buf = NULL; buf = NULL;
bufsize = 0; bufsize = 0;
msg_content = NULL; msg_content = NULL;
return b;
} }
void zmq::shared_message_memory_allocator::inc_ref () void zmq::shared_message_memory_allocator::inc_ref ()
......
...@@ -120,6 +120,8 @@ class shared_message_memory_allocator ...@@ -120,6 +120,8 @@ class shared_message_memory_allocator
void advance_content () { msg_content++; } void advance_content () { msg_content++; }
private: private:
void clear ();
unsigned char *buf; unsigned char *buf;
std::size_t bufsize; std::size_t bufsize;
const std::size_t max_size; const std::size_t max_size;
......
...@@ -36,7 +36,7 @@ zmq::mailbox_t::mailbox_t () ...@@ -36,7 +36,7 @@ zmq::mailbox_t::mailbox_t ()
// Get the pipe into passive state. That way, if the users starts by // Get the pipe into passive state. That way, if the users starts by
// polling on the associated file descriptor it will get woken up when // polling on the associated file descriptor it will get woken up when
// new command is posted. // new command is posted.
const bool ok = cpipe.read (NULL); const bool ok = cpipe.check_read ();
zmq_assert (!ok); zmq_assert (!ok);
active = false; active = false;
} }
......
...@@ -37,7 +37,7 @@ zmq::mailbox_safe_t::mailbox_safe_t (mutex_t *sync_) : sync (sync_) ...@@ -37,7 +37,7 @@ zmq::mailbox_safe_t::mailbox_safe_t (mutex_t *sync_) : sync (sync_)
// Get the pipe into passive state. That way, if the users starts by // Get the pipe into passive state. That way, if the users starts by
// polling on the associated file descriptor it will get woken up when // polling on the associated file descriptor it will get woken up when
// new command is posted. // new command is posted.
const bool ok = cpipe.read (NULL); const bool ok = cpipe.check_read ();
zmq_assert (!ok); zmq_assert (!ok);
} }
......
...@@ -52,7 +52,7 @@ int zmq::rep_t::xsend (msg_t *msg_) ...@@ -52,7 +52,7 @@ int zmq::rep_t::xsend (msg_t *msg_)
return -1; return -1;
} }
bool more = msg_->flags () & msg_t::more ? true : false; bool more = (msg_->flags () & msg_t::more) != 0;
// Push message to the reply pipe. // Push message to the reply pipe.
int rc = router_t::xsend (msg_); int rc = router_t::xsend (msg_);
......
...@@ -126,7 +126,7 @@ int zmq::req_t::xsend (msg_t *msg_) ...@@ -126,7 +126,7 @@ int zmq::req_t::xsend (msg_t *msg_)
} }
} }
bool more = msg_->flags () & msg_t::more ? true : false; bool more = (msg_->flags () & msg_t::more) != 0;
int rc = dealer_t::xsend (msg_); int rc = dealer_t::xsend (msg_);
if (rc != 0) if (rc != 0)
...@@ -299,7 +299,8 @@ int zmq::req_session_t::push_msg (msg_t *msg_) ...@@ -299,7 +299,8 @@ int zmq::req_session_t::push_msg (msg_t *msg_)
if (msg_->size () == sizeof (uint32_t)) { if (msg_->size () == sizeof (uint32_t)) {
state = request_id; state = request_id;
return session_base_t::push_msg (msg_); return session_base_t::push_msg (msg_);
} else if (msg_->size () == 0) { }
if (msg_->size () == 0) {
state = body; state = body;
return session_base_t::push_msg (msg_); return session_base_t::push_msg (msg_);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment