mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 02:42:58 +01:00
Problem: magic number "2" in socket_base.cpp
Solution: calculate from field sizes
This commit is contained in:
parent
d75ec5e055
commit
a4c817e736
@ -1731,14 +1731,14 @@ void zmq::socket_base_t::monitor_event (int event_,
|
||||
|
||||
if (_monitor_socket) {
|
||||
// Send event in first frame
|
||||
const uint16_t event = static_cast<uint16_t> (event_);
|
||||
const uint32_t value = static_cast<uint32_t> (value_);
|
||||
zmq_msg_t msg;
|
||||
zmq_msg_init_size (&msg, 6);
|
||||
zmq_msg_init_size (&msg, sizeof (event) + sizeof (value));
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
// Avoid dereferencing uint32_t on unaligned address
|
||||
uint16_t event = static_cast<uint16_t> (event_);
|
||||
uint32_t value = static_cast<uint32_t> (value_);
|
||||
memcpy (data + 0, &event, sizeof (event));
|
||||
memcpy (data + 2, &value, sizeof (value));
|
||||
memcpy (data + sizeof (event), &value, sizeof (value));
|
||||
zmq_sendmsg (_monitor_socket, &msg, ZMQ_SNDMORE);
|
||||
|
||||
// Send address in second frame
|
||||
|
Loading…
Reference in New Issue
Block a user