Problem: Several problems found by Coverity Static Analyzer

Solution: The Coverity Static Code Analyzer was used on libzmq code and found
many issues with uninitialized member variables, some redefinition of variables
hidding previous instances of same variable name and a couple of functions
where return values were not checked, even though all other occurrences were
checked (e.g. init_size() return).
This commit is contained in:
Osiris
2016-02-21 15:49:47 -06:00
parent c5d8353429
commit b3d5fa63a0
44 changed files with 99 additions and 60 deletions

View File

@@ -87,6 +87,8 @@ zmq::stream_engine_t::stream_engine_t (fd_t fd_, const options_t &options_,
has_timeout_timer (false),
has_heartbeat_timer (false),
heartbeat_timeout (0),
as_server(false),
handle(NULL),
socket (NULL)
{
int rc = tx_msg.init ();
@@ -1018,8 +1020,9 @@ int zmq::stream_engine_t::produce_ping_message(msg_t * msg_)
zmq_assert (mechanism != NULL);
// 16-bit TTL + \4PING == 7
msg_->init_size(7);
msg_->set_flags(msg_t::command);
rc = msg_->init_size(7);
errno_assert(rc == 0);
msg_->set_flags(msg_t::command);
// Copy in the command message
memcpy(msg_->data(), "\4PING", 5);
@@ -1040,8 +1043,9 @@ int zmq::stream_engine_t::produce_pong_message(msg_t * msg_)
int rc = 0;
zmq_assert (mechanism != NULL);
msg_->init_size(5);
msg_->set_flags(msg_t::command);
rc = msg_->init_size(5);
errno_assert(rc == 0);
msg_->set_flags(msg_t::command);
memcpy(msg_->data(), "\4PONG", 5);