Skip to content

Commit

Permalink
Merge pull request zeromq#3114 from sigiesec/fix-some-style-issues
Browse files Browse the repository at this point in the history
Fix some code style issues
  • Loading branch information
bluca authored May 17, 2018
2 parents cbd52fe + e19823d commit 6a5051f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/blob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/dealer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down
10 changes: 7 additions & 3 deletions src/decoder_allocators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
2 changes: 2 additions & 0 deletions src/decoder_allocators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/mailbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mailbox_safe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/rep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down
5 changes: 3 additions & 2 deletions src/req.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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_);
}
Expand Down

0 comments on commit 6a5051f

Please sign in to comment.