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:
Korina Šimičević
2024-01-02 16:01:56 +01:00
parent 794c72cb44
commit bf81ab5ee7
10 changed files with 41 additions and 31 deletions

View File

@ -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)

View File

@ -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)...)
};
}

View File

@ -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(

View File

@ -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;
}
@ -182,7 +184,7 @@ 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 varlen_ = int_def<varint_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::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>>,

View File

@ -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();

View File

@ -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(

View File

@ -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, {}, {});
}

View File

@ -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);

View File

@ -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()

View File

@ -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()