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

Fix some code style issues
This commit is contained in:
Luca Boccassi 2018-05-17 15:43:20 +01:00 committed by GitHub
commit 6a5051fac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 9 deletions

View File

@ -72,7 +72,7 @@ struct blob_t
blob_t () : data_ (0), size_ (0), owned_ (true) {}
// 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)),
size_ (size),
owned_ (true)

View File

@ -57,6 +57,8 @@ void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_)
rc = pipe_->write (&probe_msg_);
// zmq_assert (rc) is not applicable here, since it is not a bug.
(void) rc;
pipe_->flush ();
rc = probe_msg_.close ();

View File

@ -108,17 +108,21 @@ void zmq::shared_message_memory_allocator::deallocate ()
if (buf && !c->sub (1)) {
std::free (buf);
}
release ();
clear ();
}
unsigned char *zmq::shared_message_memory_allocator::release ()
{
unsigned char *b = buf;
clear ();
return b;
}
void zmq::shared_message_memory_allocator::clear ()
{
buf = NULL;
bufsize = 0;
msg_content = NULL;
return b;
}
void zmq::shared_message_memory_allocator::inc_ref ()

View File

@ -120,6 +120,8 @@ class shared_message_memory_allocator
void advance_content () { msg_content++; }
private:
void clear ();
unsigned char *buf;
std::size_t bufsize;
const std::size_t max_size;

View File

@ -36,7 +36,7 @@ zmq::mailbox_t::mailbox_t ()
// 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
// new command is posted.
const bool ok = cpipe.read (NULL);
const bool ok = cpipe.check_read ();
zmq_assert (!ok);
active = false;
}

View File

@ -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
// polling on the associated file descriptor it will get woken up when
// new command is posted.
const bool ok = cpipe.read (NULL);
const bool ok = cpipe.check_read ();
zmq_assert (!ok);
}

View File

@ -52,7 +52,7 @@ int zmq::rep_t::xsend (msg_t *msg_)
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.
int rc = router_t::xsend (msg_);

View File

@ -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_);
if (rc != 0)
@ -299,7 +299,8 @@ int zmq::req_session_t::push_msg (msg_t *msg_)
if (msg_->size () == sizeof (uint32_t)) {
state = request_id;
return session_base_t::push_msg (msg_);
} else if (msg_->size () == 0) {
}
if (msg_->size () == 0) {
state = body;
return session_base_t::push_msg (msg_);
}