mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-30 13:47:13 +01:00
Problem: C-style casts
Solution: replace by reinterpret_casts or avoid entirely
This commit is contained in:
@@ -65,7 +65,7 @@ void zmq::mechanism_t::set_user_id (const void *data_, size_t size_)
|
|||||||
_user_id.set (static_cast<const unsigned char *> (data_), size_);
|
_user_id.set (static_cast<const unsigned char *> (data_), size_);
|
||||||
zap_properties.ZMQ_MAP_INSERT_OR_EMPLACE (
|
zap_properties.ZMQ_MAP_INSERT_OR_EMPLACE (
|
||||||
std::string (ZMQ_MSG_PROPERTY_USER_ID),
|
std::string (ZMQ_MSG_PROPERTY_USER_ID),
|
||||||
std::string ((char *) data_, size_));
|
std::string (reinterpret_cast<const char *> (data_), size_));
|
||||||
}
|
}
|
||||||
|
|
||||||
const zmq::blob_t &zmq::mechanism_t::get_user_id () const
|
const zmq::blob_t &zmq::mechanism_t::get_user_id () const
|
||||||
@@ -238,7 +238,8 @@ int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
|
|||||||
if (bytes_left < name_length)
|
if (bytes_left < name_length)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const std::string name = std::string ((char *) ptr_, name_length);
|
const std::string name =
|
||||||
|
std::string (reinterpret_cast<const char *> (ptr_), name_length);
|
||||||
ptr_ += name_length;
|
ptr_ += name_length;
|
||||||
bytes_left -= name_length;
|
bytes_left -= name_length;
|
||||||
if (bytes_left < value_len_size)
|
if (bytes_left < value_len_size)
|
||||||
@@ -269,7 +270,8 @@ int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
|
|||||||
}
|
}
|
||||||
(zap_flag_ ? zap_properties : zmtp_properties)
|
(zap_flag_ ? zap_properties : zmtp_properties)
|
||||||
.ZMQ_MAP_INSERT_OR_EMPLACE (
|
.ZMQ_MAP_INSERT_OR_EMPLACE (
|
||||||
name, std::string ((char *) value, value_length));
|
name,
|
||||||
|
std::string (reinterpret_cast<const char *> (value), value_length));
|
||||||
}
|
}
|
||||||
if (bytes_left > 0) {
|
if (bytes_left > 0) {
|
||||||
errno = EPROTO;
|
errno = EPROTO;
|
||||||
|
|||||||
@@ -263,7 +263,8 @@ int zmq::options_t::set_curve_key (uint8_t *destination_,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case CURVE_KEYSIZE_Z85 + 1:
|
case CURVE_KEYSIZE_Z85 + 1:
|
||||||
if (zmq_z85_decode (destination_, (char *) optval_)) {
|
if (zmq_z85_decode (destination_,
|
||||||
|
reinterpret_cast<const char *> (optval_))) {
|
||||||
mechanism = ZMQ_CURVE;
|
mechanism = ZMQ_CURVE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -271,7 +272,8 @@ int zmq::options_t::set_curve_key (uint8_t *destination_,
|
|||||||
|
|
||||||
case CURVE_KEYSIZE_Z85:
|
case CURVE_KEYSIZE_Z85:
|
||||||
char z85_key[CURVE_KEYSIZE_Z85 + 1];
|
char z85_key[CURVE_KEYSIZE_Z85 + 1];
|
||||||
memcpy (z85_key, (char *) optval_, optvallen_);
|
memcpy (z85_key, reinterpret_cast<const char *> (optval_),
|
||||||
|
optvallen_);
|
||||||
z85_key[CURVE_KEYSIZE_Z85] = 0;
|
z85_key[CURVE_KEYSIZE_Z85] = 0;
|
||||||
if (zmq_z85_decode (destination_, z85_key)) {
|
if (zmq_z85_decode (destination_, z85_key)) {
|
||||||
mechanism = ZMQ_CURVE;
|
mechanism = ZMQ_CURVE;
|
||||||
@@ -719,15 +721,14 @@ int zmq::options_t::setsockopt (int option_,
|
|||||||
|
|
||||||
case ZMQ_METADATA:
|
case ZMQ_METADATA:
|
||||||
if (optvallen_ > 0 && !is_int) {
|
if (optvallen_ > 0 && !is_int) {
|
||||||
std::string s ((char *) optval_);
|
const std::string s (reinterpret_cast<const char *> (optval_));
|
||||||
size_t pos = 0;
|
const size_t pos = s.find (":");
|
||||||
std::string key, val, delimiter = ":";
|
|
||||||
pos = s.find (delimiter);
|
|
||||||
if (pos != std::string::npos && pos != 0
|
if (pos != std::string::npos && pos != 0
|
||||||
&& pos != s.length () - 1) {
|
&& pos != s.length () - 1) {
|
||||||
key = s.substr (0, pos);
|
std::string key = s.substr (0, pos);
|
||||||
if (key.compare (0, 2, "X-") == 0 && key.length () < 256) {
|
if (key.compare (0, 2, "X-") == 0
|
||||||
val = s.substr (pos + 1, s.length ());
|
&& key.length () <= UCHAR_MAX) {
|
||||||
|
std::string val = s.substr (pos + 1, s.length ());
|
||||||
app_metadata.insert (
|
app_metadata.insert (
|
||||||
std::pair<std::string, std::string> (key, val));
|
std::pair<std::string, std::string> (key, val));
|
||||||
return 0;
|
return 0;
|
||||||
@@ -736,7 +737,6 @@ int zmq::options_t::setsockopt (int option_,
|
|||||||
}
|
}
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
|
||||||
|
|
||||||
case ZMQ_MULTICAST_LOOP:
|
case ZMQ_MULTICAST_LOOP:
|
||||||
return do_setsockopt_int_as_bool_relaxed (optval_, optvallen_,
|
return do_setsockopt_int_as_bool_relaxed (optval_, optvallen_,
|
||||||
|
|||||||
Reference in New Issue
Block a user