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, "");
|
||||
|
||||
connect_props props;
|
||||
props[prop::maximum_packet_size] = int16_t(1024);
|
||||
props[prop::maximum_packet_size] = 1024;
|
||||
|
||||
c.credentials("test-qos0-tcp", "", "")
|
||||
.brokers("emqtt.mireo.local", 1883)
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
EncodeFun&& encode, Args&&... args
|
||||
) {
|
||||
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 {};
|
||||
|
||||
static constexpr size_t max_recv_size = 65'536;
|
||||
static constexpr uint32_t max_recv_size = 65'536;
|
||||
|
||||
client_service& _svc;
|
||||
handler_type _handler;
|
||||
@ -156,11 +156,13 @@ public:
|
||||
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))
|
||||
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));
|
||||
|
||||
_data_span.remove_prefix(
|
||||
|
@ -16,6 +16,8 @@ namespace async_mqtt5::encoders {
|
||||
|
||||
namespace basic {
|
||||
|
||||
using varint_t = int*;
|
||||
|
||||
inline void to_variable_bytes(std::string& s, int32_t val) {
|
||||
if (val > 0xfffffff) return;
|
||||
while (val > 127) {
|
||||
@ -132,7 +134,7 @@ public:
|
||||
private:
|
||||
template <typename U>
|
||||
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));
|
||||
else
|
||||
return sizeof(Repr);
|
||||
@ -141,7 +143,7 @@ private:
|
||||
template <typename U>
|
||||
static std::string& encode_val(std::string& s, U&& val) {
|
||||
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));
|
||||
return s;
|
||||
}
|
||||
@ -179,10 +181,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
constexpr auto byte_ = int_def<uint8_t>{};
|
||||
constexpr auto int16_ = int_def<uint16_t>{};
|
||||
constexpr auto int32_ = int_def<uint32_t>{};
|
||||
constexpr auto varlen_ = int_def<intptr_t>{};
|
||||
constexpr auto byte_ = int_def<uint8_t> {};
|
||||
constexpr auto int16_ = int_def<uint16_t> {};
|
||||
constexpr auto int32_ = int_def<uint32_t> {};
|
||||
constexpr auto varlen_ = int_def<varint_t> {};
|
||||
|
||||
|
||||
template <typename T>
|
||||
@ -273,9 +275,9 @@ public:
|
||||
|
||||
using utf8_def = array_def<true>;
|
||||
|
||||
constexpr auto utf8_ = utf8_def{};
|
||||
constexpr auto binary_ = array_def<true>{}; // for now
|
||||
constexpr auto verbatim_ = array_def<false>{};
|
||||
constexpr auto utf8_ = utf8_def {};
|
||||
constexpr auto binary_ = array_def<true> {}; // for now
|
||||
constexpr auto verbatim_ = array_def<false> {};
|
||||
|
||||
|
||||
template <typename T, typename U>
|
||||
@ -368,7 +370,7 @@ using encoder_types = std::tuple<
|
||||
prop_encoder_type<pp::content_type_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::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::assigned_client_identifier_t, basic::utf8_def>,
|
||||
prop_encoder_type<pp::server_keep_alive_t, basic::int_def<int16_t>>,
|
||||
@ -488,7 +490,7 @@ class props_val : public basic::encoder {
|
||||
static auto to_prop_vals(const pp::properties<Ps...>& props) {
|
||||
return std::make_tuple(
|
||||
to_prop_val<Ps>(
|
||||
props[std::integral_constant<pp::property_type, Ps>{}]
|
||||
props[std::integral_constant<pp::property_type, Ps> {}]
|
||||
)...
|
||||
);
|
||||
}
|
||||
@ -554,8 +556,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
constexpr auto props_ = props_def<false>{};
|
||||
constexpr auto props_may_omit_ = props_def<true>{};
|
||||
constexpr auto props_ = props_def<false> {};
|
||||
constexpr auto props_may_omit_ = props_def<true> {};
|
||||
|
||||
} // end namespace prop
|
||||
|
||||
|
@ -196,7 +196,7 @@ public:
|
||||
encoders::encode_connect,
|
||||
_ctx.creds.client_id,
|
||||
_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();
|
||||
@ -204,7 +204,7 @@ public:
|
||||
detail::async_write(
|
||||
_stream, asio::buffer(wire_data),
|
||||
asio::consign(
|
||||
asio::prepend(std::move(*this), on_send_connect{}),
|
||||
asio::prepend(std::move(*this), on_send_connect {}),
|
||||
std::move(packet)
|
||||
)
|
||||
);
|
||||
|
@ -71,9 +71,10 @@ public:
|
||||
static_cast<uint8_t>(_context.reason_code), _context.props
|
||||
);
|
||||
|
||||
auto max_packet_size = _svc_ptr->connack_prop(
|
||||
prop::maximum_packet_size
|
||||
).value_or(default_max_send_size);
|
||||
auto max_packet_size = static_cast<size_t>(
|
||||
_svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||
.value_or(default_max_send_size)
|
||||
);
|
||||
if (disconnect.size() > max_packet_size)
|
||||
// drop properties
|
||||
return send_disconnect(control_packet<allocator_type>::of(
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
|
||||
_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;
|
||||
return complete_post(asio::error::try_again, {}, {});
|
||||
}
|
||||
|
@ -120,8 +120,10 @@ public:
|
||||
qos_type, retain, dup_e::no, props
|
||||
);
|
||||
|
||||
auto max_packet_size = _svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||
.value_or(default_max_send_size);
|
||||
auto max_packet_size = static_cast<size_t>(
|
||||
_svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||
.value_or(default_max_send_size)
|
||||
);
|
||||
if (publish.size() > max_packet_size)
|
||||
return complete_post(client::error::packet_too_large, packet_id);
|
||||
|
||||
|
@ -80,8 +80,10 @@ public:
|
||||
topics, props
|
||||
);
|
||||
|
||||
auto max_packet_size = _svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||
.value_or(default_max_send_size);
|
||||
auto max_packet_size = static_cast<size_t>(
|
||||
_svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||
.value_or(default_max_send_size)
|
||||
);
|
||||
if (subscribe.size() > max_packet_size)
|
||||
return complete_post(
|
||||
client::error::packet_too_large, packet_id, topics.size()
|
||||
|
@ -75,9 +75,10 @@ public:
|
||||
topics, props
|
||||
);
|
||||
|
||||
auto max_packet_size = _svc_ptr->connack_prop(
|
||||
prop::maximum_packet_size
|
||||
).value_or(default_max_send_size);
|
||||
auto max_packet_size = static_cast<size_t>(
|
||||
_svc_ptr->connack_prop(prop::maximum_packet_size)
|
||||
.value_or(default_max_send_size)
|
||||
);
|
||||
if (unsubscribe.size() > max_packet_size)
|
||||
return complete_post(
|
||||
client::error::packet_too_large, packet_id, topics.size()
|
||||
|
Reference in New Issue
Block a user