forked from boostorg/mqtt5
Handle all warnings on MSVC Win32
Summary: related to T13409 Reviewers: ivica Reviewed By: ivica Subscribers: miljen, iljazovic Differential Revision: https://repo.mireo.local/D27165
This commit is contained in:
@@ -18,7 +18,7 @@ void publish_qos0_tcp() {
|
|||||||
client_type c(ioc, "");
|
client_type c(ioc, "");
|
||||||
|
|
||||||
connect_props props;
|
connect_props props;
|
||||||
props[prop::maximum_packet_size] = int16_t(1024);
|
props[prop::maximum_packet_size] = 1024;
|
||||||
|
|
||||||
c.credentials("test-qos0-tcp", "", "")
|
c.credentials("test-qos0-tcp", "", "")
|
||||||
.brokers("emqtt.mireo.local", 1883)
|
.brokers("emqtt.mireo.local", 1883)
|
||||||
|
@@ -77,7 +77,7 @@ public:
|
|||||||
EncodeFun&& encode, Args&&... args
|
EncodeFun&& encode, Args&&... args
|
||||||
) {
|
) {
|
||||||
return control_packet {
|
return control_packet {
|
||||||
alloc, 0, encode(std::forward<Args>(args)...)
|
alloc, uint16_t(0), encode(std::forward<Args>(args)...)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ class assemble_op {
|
|||||||
|
|
||||||
struct on_read {};
|
struct on_read {};
|
||||||
|
|
||||||
static constexpr size_t max_recv_size = 65'536;
|
static constexpr uint32_t max_recv_size = 65'536;
|
||||||
|
|
||||||
client_service& _svc;
|
client_service& _svc;
|
||||||
handler_type _handler;
|
handler_type _handler;
|
||||||
@@ -156,11 +156,13 @@ public:
|
|||||||
return complete(client::error::malformed_packet, 0, {}, {});
|
return complete(client::error::malformed_packet, 0, {}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto recv_size = _svc.connect_prop(prop::maximum_packet_size).value_or(max_recv_size);
|
auto recv_size = static_cast<size_t>(
|
||||||
|
_svc.connect_prop(prop::maximum_packet_size).value_or(max_recv_size)
|
||||||
|
);
|
||||||
if (*varlen > recv_size - std::distance(_data_span.first(), first))
|
if (*varlen > recv_size - std::distance(_data_span.first(), first))
|
||||||
return complete(client::error::malformed_packet, 0, {}, {});
|
return complete(client::error::malformed_packet, 0, {}, {});
|
||||||
|
|
||||||
if (std::distance(first, _data_span.last()) < *varlen)
|
if (static_cast<uint32_t>(std::distance(first, _data_span.last())) < *varlen)
|
||||||
return perform(wait_for, asio::transfer_at_least(1));
|
return perform(wait_for, asio::transfer_at_least(1));
|
||||||
|
|
||||||
_data_span.remove_prefix(
|
_data_span.remove_prefix(
|
||||||
|
@@ -16,6 +16,8 @@ namespace async_mqtt5::encoders {
|
|||||||
|
|
||||||
namespace basic {
|
namespace basic {
|
||||||
|
|
||||||
|
using varint_t = int*;
|
||||||
|
|
||||||
inline void to_variable_bytes(std::string& s, int32_t val) {
|
inline void to_variable_bytes(std::string& s, int32_t val) {
|
||||||
if (val > 0xfffffff) return;
|
if (val > 0xfffffff) return;
|
||||||
while (val > 127) {
|
while (val > 127) {
|
||||||
@@ -132,7 +134,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static size_t val_length(U&& val) {
|
static size_t val_length(U&& val) {
|
||||||
if constexpr (std::is_same_v<Repr, intptr_t>)
|
if constexpr (std::is_same_v<Repr, varint_t>)
|
||||||
return variable_length(int32_t(val));
|
return variable_length(int32_t(val));
|
||||||
else
|
else
|
||||||
return sizeof(Repr);
|
return sizeof(Repr);
|
||||||
@@ -141,7 +143,7 @@ private:
|
|||||||
template <typename U>
|
template <typename U>
|
||||||
static std::string& encode_val(std::string& s, U&& val) {
|
static std::string& encode_val(std::string& s, U&& val) {
|
||||||
using namespace boost::endian;
|
using namespace boost::endian;
|
||||||
if constexpr (std::is_same_v<Repr, intptr_t>) {
|
if constexpr (std::is_same_v<Repr, varint_t>) {
|
||||||
to_variable_bytes(s, int32_t(val));
|
to_variable_bytes(s, int32_t(val));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -182,7 +184,7 @@ public:
|
|||||||
constexpr auto byte_ = int_def<uint8_t> {};
|
constexpr auto byte_ = int_def<uint8_t> {};
|
||||||
constexpr auto int16_ = int_def<uint16_t> {};
|
constexpr auto int16_ = int_def<uint16_t> {};
|
||||||
constexpr auto int32_ = int_def<uint32_t> {};
|
constexpr auto int32_ = int_def<uint32_t> {};
|
||||||
constexpr auto varlen_ = int_def<intptr_t>{};
|
constexpr auto varlen_ = int_def<varint_t> {};
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -368,7 +370,7 @@ using encoder_types = std::tuple<
|
|||||||
prop_encoder_type<pp::content_type_t, basic::utf8_def>,
|
prop_encoder_type<pp::content_type_t, basic::utf8_def>,
|
||||||
prop_encoder_type<pp::response_topic_t, basic::utf8_def>,
|
prop_encoder_type<pp::response_topic_t, basic::utf8_def>,
|
||||||
prop_encoder_type<pp::correlation_data_t, basic::utf8_def>,
|
prop_encoder_type<pp::correlation_data_t, basic::utf8_def>,
|
||||||
prop_encoder_type<pp::subscription_identifier_t, basic::int_def<intptr_t>>, // varint
|
prop_encoder_type<pp::subscription_identifier_t, basic::int_def<basic::varint_t>>, // varint
|
||||||
prop_encoder_type<pp::session_expiry_interval_t, basic::int_def<int32_t>>,
|
prop_encoder_type<pp::session_expiry_interval_t, basic::int_def<int32_t>>,
|
||||||
prop_encoder_type<pp::assigned_client_identifier_t, basic::utf8_def>,
|
prop_encoder_type<pp::assigned_client_identifier_t, basic::utf8_def>,
|
||||||
prop_encoder_type<pp::server_keep_alive_t, basic::int_def<int16_t>>,
|
prop_encoder_type<pp::server_keep_alive_t, basic::int_def<int16_t>>,
|
||||||
|
@@ -196,7 +196,7 @@ public:
|
|||||||
encoders::encode_connect,
|
encoders::encode_connect,
|
||||||
_ctx.creds.client_id,
|
_ctx.creds.client_id,
|
||||||
_ctx.creds.username, _ctx.creds.password,
|
_ctx.creds.username, _ctx.creds.password,
|
||||||
10u, false, _ctx.co_props, _ctx.will_msg
|
uint16_t(10), false, _ctx.co_props, _ctx.will_msg
|
||||||
);
|
);
|
||||||
|
|
||||||
auto wire_data = packet.wire_data();
|
auto wire_data = packet.wire_data();
|
||||||
|
@@ -71,9 +71,10 @@ public:
|
|||||||
static_cast<uint8_t>(_context.reason_code), _context.props
|
static_cast<uint8_t>(_context.reason_code), _context.props
|
||||||
);
|
);
|
||||||
|
|
||||||
auto max_packet_size = _svc_ptr->connack_prop(
|
auto max_packet_size = static_cast<size_t>(
|
||||||
prop::maximum_packet_size
|
_svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||||
).value_or(default_max_send_size);
|
.value_or(default_max_send_size)
|
||||||
|
);
|
||||||
if (disconnect.size() > max_packet_size)
|
if (disconnect.size() > max_packet_size)
|
||||||
// drop properties
|
// drop properties
|
||||||
return send_disconnect(control_packet<allocator_type>::of(
|
return send_disconnect(control_packet<allocator_type>::of(
|
||||||
|
@@ -60,7 +60,7 @@ public:
|
|||||||
|
|
||||||
_owner._current_host++;
|
_owner._current_host++;
|
||||||
|
|
||||||
if (_owner._current_host + 1 > _owner._servers.size()) {
|
if (_owner._current_host + 1 > static_cast<int>(_owner._servers.size())) {
|
||||||
_owner._current_host = -1;
|
_owner._current_host = -1;
|
||||||
return complete_post(asio::error::try_again, {}, {});
|
return complete_post(asio::error::try_again, {}, {});
|
||||||
}
|
}
|
||||||
|
@@ -120,8 +120,10 @@ public:
|
|||||||
qos_type, retain, dup_e::no, props
|
qos_type, retain, dup_e::no, props
|
||||||
);
|
);
|
||||||
|
|
||||||
auto max_packet_size = _svc_ptr->connack_prop(prop::maximum_packet_size)
|
auto max_packet_size = static_cast<size_t>(
|
||||||
.value_or(default_max_send_size);
|
_svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||||
|
.value_or(default_max_send_size)
|
||||||
|
);
|
||||||
if (publish.size() > max_packet_size)
|
if (publish.size() > max_packet_size)
|
||||||
return complete_post(client::error::packet_too_large, packet_id);
|
return complete_post(client::error::packet_too_large, packet_id);
|
||||||
|
|
||||||
|
@@ -80,8 +80,10 @@ public:
|
|||||||
topics, props
|
topics, props
|
||||||
);
|
);
|
||||||
|
|
||||||
auto max_packet_size = _svc_ptr->connack_prop(prop::maximum_packet_size)
|
auto max_packet_size = static_cast<size_t>(
|
||||||
.value_or(default_max_send_size);
|
_svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||||
|
.value_or(default_max_send_size)
|
||||||
|
);
|
||||||
if (subscribe.size() > max_packet_size)
|
if (subscribe.size() > max_packet_size)
|
||||||
return complete_post(
|
return complete_post(
|
||||||
client::error::packet_too_large, packet_id, topics.size()
|
client::error::packet_too_large, packet_id, topics.size()
|
||||||
|
@@ -75,9 +75,10 @@ public:
|
|||||||
topics, props
|
topics, props
|
||||||
);
|
);
|
||||||
|
|
||||||
auto max_packet_size = _svc_ptr->connack_prop(
|
auto max_packet_size = static_cast<size_t>(
|
||||||
prop::maximum_packet_size
|
_svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||||
).value_or(default_max_send_size);
|
.value_or(default_max_send_size)
|
||||||
|
);
|
||||||
if (unsubscribe.size() > max_packet_size)
|
if (unsubscribe.size() > max_packet_size)
|
||||||
return complete_post(
|
return complete_post(
|
||||||
client::error::packet_too_large, packet_id, topics.size()
|
client::error::packet_too_large, packet_id, topics.size()
|
||||||
|
Reference in New Issue
Block a user