forked from boostorg/mqtt5
Handle all MSVC warnings
Summary: related to T13409 Reviewers: ivica Reviewed By: ivica Subscribers: miljen, iljazovic Differential Revision: https://repo.mireo.local/D27152
This commit is contained in:
@@ -21,7 +21,7 @@ struct tls_handshake_type<asio::ssl::stream<StreamBase>> {
|
|||||||
template <typename StreamBase>
|
template <typename StreamBase>
|
||||||
void assign_tls_sni(
|
void assign_tls_sni(
|
||||||
const authority_path& ap,
|
const authority_path& ap,
|
||||||
asio::ssl::context& ctx,
|
asio::ssl::context& /* ctx */,
|
||||||
asio::ssl::stream<StreamBase>& stream
|
asio::ssl::stream<StreamBase>& stream
|
||||||
) {
|
) {
|
||||||
SSL_set_tlsext_host_name(stream.native_handle(), ap.host.c_str());
|
SSL_set_tlsext_host_name(stream.native_handle(), ap.host.c_str());
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
void run_openssl_tls_examples();
|
|
||||||
void run_tcp_examples();
|
void run_tcp_examples();
|
||||||
|
void run_openssl_tls_examples();
|
||||||
void run_websocket_tcp_examples();
|
void run_websocket_tcp_examples();
|
||||||
void run_websocket_tls_examples();
|
void run_websocket_tls_examples();
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main() {
|
||||||
|
|
||||||
run_tcp_examples();
|
run_tcp_examples();
|
||||||
run_openssl_tls_examples();
|
run_openssl_tls_examples();
|
||||||
|
@@ -18,11 +18,11 @@ void publish_qos0_tcp() {
|
|||||||
client_type c(ioc, "");
|
client_type c(ioc, "");
|
||||||
|
|
||||||
connect_props props;
|
connect_props props;
|
||||||
props[prop::maximum_packet_size] = 1024;
|
props[prop::maximum_packet_size] = int16_t(1024);
|
||||||
|
|
||||||
c.credentials("test-qos0-tcp", "", "")
|
c.credentials("test-qos0-tcp", "", "")
|
||||||
.brokers("emqtt.mireo.local", 1883)
|
.brokers("emqtt.mireo.local", 1883)
|
||||||
.will({ "test/mqtt-test", "Client disconnected!",qos_e::at_least_once })
|
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
|
||||||
.connect_properties(std::move(props))
|
.connect_properties(std::move(props))
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ namespace boost::beast::websocket {
|
|||||||
|
|
||||||
template <typename TeardownHandler>
|
template <typename TeardownHandler>
|
||||||
void async_teardown(
|
void async_teardown(
|
||||||
boost::beast::role_type role,
|
boost::beast::role_type /* role */,
|
||||||
asio::ssl::stream<asio::ip::tcp::socket>& stream,
|
asio::ssl::stream<asio::ip::tcp::socket>& stream,
|
||||||
TeardownHandler&& handler
|
TeardownHandler&& handler
|
||||||
) {
|
) {
|
||||||
@@ -35,7 +35,7 @@ struct tls_handshake_type<asio::ssl::stream<StreamBase>> {
|
|||||||
template <typename StreamBase>
|
template <typename StreamBase>
|
||||||
void assign_tls_sni(
|
void assign_tls_sni(
|
||||||
const authority_path& ap,
|
const authority_path& ap,
|
||||||
asio::ssl::context& ctx,
|
asio::ssl::context& /* ctx */,
|
||||||
asio::ssl::stream<StreamBase>& stream
|
asio::ssl::stream<StreamBase>& stream
|
||||||
) {
|
) {
|
||||||
SSL_set_tlsext_host_name(stream.native_handle(), ap.host.c_str());
|
SSL_set_tlsext_host_name(stream.native_handle(), ap.host.c_str());
|
||||||
|
@@ -125,7 +125,7 @@ class packet_id_allocator {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
packet_id_allocator() {
|
packet_id_allocator() {
|
||||||
_free_ids.emplace_back(MAX_PACKET_ID, 0);
|
_free_ids.emplace_back(MAX_PACKET_ID, uint16_t(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t allocate() {
|
uint16_t allocate() {
|
||||||
|
@@ -223,7 +223,7 @@ private:
|
|||||||
_write_queue.begin(), _write_queue.end(),
|
_write_queue.begin(), _write_queue.end(),
|
||||||
[](const auto& op) { return !op.throttled(); }
|
[](const auto& op) { return !op.throttled(); }
|
||||||
);
|
);
|
||||||
uint16_t dist = std::distance(throttled_ptr, _write_queue.end());
|
uint16_t dist = static_cast<uint16_t>(std::distance(throttled_ptr, _write_queue.end()));
|
||||||
uint16_t throttled_num = std::min(dist, _quota);
|
uint16_t throttled_num = std::min(dist, _quota);
|
||||||
_quota -= throttled_num;
|
_quota -= throttled_num;
|
||||||
throttled_ptr += throttled_num;
|
throttled_ptr += throttled_num;
|
||||||
|
@@ -212,7 +212,7 @@ public:
|
|||||||
|
|
||||||
client_service(
|
client_service(
|
||||||
const executor_type& ex,
|
const executor_type& ex,
|
||||||
const std::string& cnf,
|
const std::string& /* cnf */,
|
||||||
tls_context_type tls_context = {}
|
tls_context_type tls_context = {}
|
||||||
) :
|
) :
|
||||||
_stream_context(std::move(tls_context)),
|
_stream_context(std::move(tls_context)),
|
||||||
|
@@ -351,7 +351,7 @@ inline std::string encode_pingreq() {
|
|||||||
basic::flag<4>(0);
|
basic::flag<4>(0);
|
||||||
|
|
||||||
auto remaining_len_ =
|
auto remaining_len_ =
|
||||||
basic::byte_(0);
|
basic::byte_(uint8_t(0));
|
||||||
|
|
||||||
auto ping_req_ = packet_type_ & remaining_len_;
|
auto ping_req_ = packet_type_ & remaining_len_;
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ inline std::string encode_pingresp() {
|
|||||||
basic::flag<4>(0);
|
basic::flag<4>(0);
|
||||||
|
|
||||||
auto remaining_len_ =
|
auto remaining_len_ =
|
||||||
basic::byte_(0);
|
basic::byte_(uint8_t(0));
|
||||||
|
|
||||||
auto ping_resp_ = packet_type_ & remaining_len_;
|
auto ping_resp_ = packet_type_ & remaining_len_;
|
||||||
|
|
||||||
|
@@ -279,7 +279,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void on_connack(byte_citer first, byte_citer last) {
|
void on_connack(byte_citer first, byte_citer last) {
|
||||||
auto packet_length = std::distance(first, last);
|
auto packet_length = static_cast<uint32_t>(std::distance(first, last));
|
||||||
auto rv = decoders::decode_connack(packet_length, first);
|
auto rv = decoders::decode_connack(packet_length, first);
|
||||||
if (!rv.has_value())
|
if (!rv.has_value())
|
||||||
return complete(client::error::malformed_packet);
|
return complete(client::error::malformed_packet);
|
||||||
@@ -313,7 +313,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void on_auth(byte_citer first, byte_citer last) {
|
void on_auth(byte_citer first, byte_citer last) {
|
||||||
auto packet_length = std::distance(first, last);
|
auto packet_length = static_cast<uint32_t>(std::distance(first, last));
|
||||||
auto rv = decoders::decode_auth(packet_length, first);
|
auto rv = decoders::decode_auth(packet_length, first);
|
||||||
if (!rv.has_value())
|
if (!rv.has_value())
|
||||||
return complete(client::error::malformed_packet);
|
return complete(client::error::malformed_packet);
|
||||||
|
@@ -141,7 +141,7 @@ public:
|
|||||||
if (ec)
|
if (ec)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto pubrel = decoders::decode_pubrel(std::distance(first, last), first);
|
auto pubrel = decoders::decode_pubrel(static_cast<uint32_t>(std::distance(first, last)), first);
|
||||||
if (!pubrel.has_value()) {
|
if (!pubrel.has_value()) {
|
||||||
on_malformed_packet("Malformed PUBREL received: cannot decode");
|
on_malformed_packet("Malformed PUBREL received: cannot decode");
|
||||||
return wait_pubrel(packet_id);
|
return wait_pubrel(packet_id);
|
||||||
|
@@ -205,7 +205,9 @@ public:
|
|||||||
ec, reason_codes::empty, packet_id, puback_props {}
|
ec, reason_codes::empty, packet_id, puback_props {}
|
||||||
);
|
);
|
||||||
|
|
||||||
auto puback = decoders::decode_puback(std::distance(first, last), first);
|
auto puback = decoders::decode_puback(
|
||||||
|
static_cast<uint32_t>(std::distance(first, last)), first
|
||||||
|
);
|
||||||
if (!puback.has_value()) {
|
if (!puback.has_value()) {
|
||||||
on_malformed_packet("Malformed PUBACK: cannot decode");
|
on_malformed_packet("Malformed PUBACK: cannot decode");
|
||||||
return send_publish(std::move(publish.set_dup()));
|
return send_publish(std::move(publish.set_dup()));
|
||||||
@@ -239,7 +241,9 @@ public:
|
|||||||
ec, reason_codes::empty, packet_id, pubcomp_props {}
|
ec, reason_codes::empty, packet_id, pubcomp_props {}
|
||||||
);
|
);
|
||||||
|
|
||||||
auto pubrec = decoders::decode_pubrec(std::distance(first, last), first);
|
auto pubrec = decoders::decode_pubrec(
|
||||||
|
static_cast<uint32_t>(std::distance(first, last)), first
|
||||||
|
);
|
||||||
if (!pubrec.has_value()) {
|
if (!pubrec.has_value()) {
|
||||||
on_malformed_packet("Malformed PUBREC: cannot decode");
|
on_malformed_packet("Malformed PUBREC: cannot decode");
|
||||||
return send_publish(std::move(publish.set_dup()));
|
return send_publish(std::move(publish.set_dup()));
|
||||||
@@ -317,7 +321,9 @@ public:
|
|||||||
ec, reason_codes::empty, packet_id, pubcomp_props {}
|
ec, reason_codes::empty, packet_id, pubcomp_props {}
|
||||||
);
|
);
|
||||||
|
|
||||||
auto pubcomp = decoders::decode_pubcomp(std::distance(first, last), first);
|
auto pubcomp = decoders::decode_pubcomp(
|
||||||
|
static_cast<uint32_t>(std::distance(first, last)), first
|
||||||
|
);
|
||||||
if (!pubcomp.has_value()) {
|
if (!pubcomp.has_value()) {
|
||||||
on_malformed_packet("Malformed PUBCOMP: cannot decode");
|
on_malformed_packet("Malformed PUBCOMP: cannot decode");
|
||||||
return send_pubrel(std::move(pubrel), true);
|
return send_pubrel(std::move(pubrel), true);
|
||||||
|
@@ -88,7 +88,7 @@ private:
|
|||||||
switch (code) {
|
switch (code) {
|
||||||
case control_code_e::publish: {
|
case control_code_e::publish: {
|
||||||
auto msg = decoders::decode_publish(
|
auto msg = decoders::decode_publish(
|
||||||
control_byte, std::distance(first, last), first
|
control_byte, static_cast<uint32_t>(std::distance(first, last)), first
|
||||||
);
|
);
|
||||||
if (!msg.has_value())
|
if (!msg.has_value())
|
||||||
return on_malformed_packet(
|
return on_malformed_packet(
|
||||||
@@ -105,7 +105,7 @@ private:
|
|||||||
break;
|
break;
|
||||||
case control_code_e::auth: {
|
case control_code_e::auth: {
|
||||||
auto rv = decoders::decode_auth(
|
auto rv = decoders::decode_auth(
|
||||||
std::distance(first, last), first
|
static_cast<uint32_t>(std::distance(first, last)), first
|
||||||
);
|
);
|
||||||
if (!rv.has_value())
|
if (!rv.has_value())
|
||||||
return on_malformed_packet(
|
return on_malformed_packet(
|
||||||
|
@@ -134,7 +134,9 @@ public:
|
|||||||
if (ec)
|
if (ec)
|
||||||
return complete(ec, packet_id, {}, {});
|
return complete(ec, packet_id, {}, {});
|
||||||
|
|
||||||
auto suback = decoders::decode_suback(std::distance(first, last), first);
|
auto suback = decoders::decode_suback(
|
||||||
|
static_cast<uint32_t>(std::distance(first, last)), first
|
||||||
|
);
|
||||||
if (!suback.has_value()) {
|
if (!suback.has_value()) {
|
||||||
on_malformed_packet("Malformed SUBACK: cannot decode");
|
on_malformed_packet("Malformed SUBACK: cannot decode");
|
||||||
return send_subscribe(std::move(packet));
|
return send_subscribe(std::move(packet));
|
||||||
|
@@ -131,7 +131,7 @@ public:
|
|||||||
return complete(ec, packet_id, {}, {});
|
return complete(ec, packet_id, {}, {});
|
||||||
|
|
||||||
auto unsuback = decoders::decode_unsuback(
|
auto unsuback = decoders::decode_unsuback(
|
||||||
std::distance(first, last), first
|
static_cast<uint32_t>(std::distance(first, last)), first
|
||||||
);
|
);
|
||||||
if (!unsuback.has_value()) {
|
if (!unsuback.has_value()) {
|
||||||
on_malformed_packet("Malformed UNSUBACK: cannot decode");
|
on_malformed_packet("Malformed UNSUBACK: cannot decode");
|
||||||
|
@@ -86,6 +86,7 @@ void cancel_async_publish() {
|
|||||||
"topic", "payload", retain_e::yes, {},
|
"topic", "payload", retain_e::yes, {},
|
||||||
[&handlers_called](error_code ec, reason_code rc, puback_props) {
|
[&handlers_called](error_code ec, reason_code rc, puback_props) {
|
||||||
BOOST_CHECK_EQUAL(ec, asio::error::operation_aborted);
|
BOOST_CHECK_EQUAL(ec, asio::error::operation_aborted);
|
||||||
|
BOOST_CHECK_EQUAL(rc, reason_codes::empty);
|
||||||
handlers_called++;
|
handlers_called++;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -95,6 +96,7 @@ void cancel_async_publish() {
|
|||||||
"topic", "payload", retain_e::yes, {},
|
"topic", "payload", retain_e::yes, {},
|
||||||
[&handlers_called](error_code ec, reason_code rc, pubcomp_props) {
|
[&handlers_called](error_code ec, reason_code rc, pubcomp_props) {
|
||||||
BOOST_CHECK_EQUAL(ec, asio::error::operation_aborted);
|
BOOST_CHECK_EQUAL(ec, asio::error::operation_aborted);
|
||||||
|
BOOST_CHECK_EQUAL(rc, reason_codes::empty);
|
||||||
handlers_called++;
|
handlers_called++;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -413,7 +413,7 @@ BOOST_AUTO_TEST_CASE(throttling) {
|
|||||||
int handlers_called = 0;
|
int handlers_called = 0;
|
||||||
|
|
||||||
connack_props props;
|
connack_props props;
|
||||||
props[prop::receive_maximum] = 1;
|
props[prop::receive_maximum] = int16_t(1);
|
||||||
|
|
||||||
//packets
|
//packets
|
||||||
auto connect = encoders::encode_connect(
|
auto connect = encoders::encode_connect(
|
||||||
|
@@ -18,7 +18,7 @@ namespace boost::beast::websocket {
|
|||||||
|
|
||||||
template <typename TeardownHandler>
|
template <typename TeardownHandler>
|
||||||
void async_teardown(
|
void async_teardown(
|
||||||
boost::beast::role_type role,
|
boost::beast::role_type /* role */,
|
||||||
asio::ssl::stream<asio::ip::tcp::socket>& stream,
|
asio::ssl::stream<asio::ip::tcp::socket>& stream,
|
||||||
TeardownHandler&& handler
|
TeardownHandler&& handler
|
||||||
) {
|
) {
|
||||||
@@ -62,7 +62,7 @@ struct tls_handshake_type<asio::ssl::stream<StreamBase>> {
|
|||||||
template <typename StreamBase>
|
template <typename StreamBase>
|
||||||
void assign_tls_sni(
|
void assign_tls_sni(
|
||||||
const authority_path& ap,
|
const authority_path& ap,
|
||||||
asio::ssl::context& ctx,
|
asio::ssl::context& /* ctx */,
|
||||||
asio::ssl::stream<StreamBase>& stream
|
asio::ssl::stream<StreamBase>& stream
|
||||||
) {
|
) {
|
||||||
SSL_set_tlsext_host_name(stream.native_handle(), ap.host.c_str());
|
SSL_set_tlsext_host_name(stream.native_handle(), ap.host.c_str());
|
||||||
|
@@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(test_invalid_topic_names) {
|
|||||||
"", "+", "#",
|
"", "+", "#",
|
||||||
"invalid+", "invalid#", "invalid/#", "invalid/+"
|
"invalid+", "invalid#", "invalid/#", "invalid/+"
|
||||||
};
|
};
|
||||||
int expected_handlers_called = invalid_topics.size();
|
int expected_handlers_called = static_cast<int>(invalid_topics.size());
|
||||||
int handlers_called = 0;
|
int handlers_called = 0;
|
||||||
|
|
||||||
asio::io_context ioc;
|
asio::io_context ioc;
|
||||||
@@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(test_malformed_packet) {
|
|||||||
out_of_range_subid_props
|
out_of_range_subid_props
|
||||||
};
|
};
|
||||||
|
|
||||||
int expected_handlers_called = testing_props.size();
|
int expected_handlers_called = static_cast<int>(testing_props.size());
|
||||||
int handlers_called = 0;
|
int handlers_called = 0;
|
||||||
|
|
||||||
asio::io_context ioc;
|
asio::io_context ioc;
|
||||||
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(test_topic_alias_maximum) {
|
|||||||
ta_allowed_props, connack_props {} /* not allowed */
|
ta_allowed_props, connack_props {} /* not allowed */
|
||||||
};
|
};
|
||||||
|
|
||||||
int expected_handlers_called = test_props.size();
|
int expected_handlers_called = static_cast<int>(test_props.size());
|
||||||
int handlers_called = 0;
|
int handlers_called = 0;
|
||||||
|
|
||||||
asio::io_context ioc;
|
asio::io_context ioc;
|
||||||
|
@@ -58,9 +58,9 @@ BOOST_AUTO_TEST_CASE(test_connect) {
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_connack) {
|
BOOST_AUTO_TEST_CASE(test_connack) {
|
||||||
// testing variables
|
// testing variables
|
||||||
bool session_present = true;
|
uint8_t session_present = 1;
|
||||||
uint8_t reason_code = 0x89;
|
uint8_t reason_code = 0x89;
|
||||||
bool wildcard_sub = true;
|
uint8_t wildcard_sub = 1;
|
||||||
|
|
||||||
connack_props cap;
|
connack_props cap;
|
||||||
cap[prop::wildcard_subscription_available] = wildcard_sub;
|
cap[prop::wildcard_subscription_available] = wildcard_sub;
|
||||||
|
@@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(clear_waiting_on_pubrel) {
|
|||||||
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor());
|
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor());
|
||||||
|
|
||||||
decoders::publish_message pub_msg = std::make_tuple(
|
decoders::publish_message pub_msg = std::make_tuple(
|
||||||
"topic", 1, 0b0100, publish_props {}, "payload"
|
"topic", int16_t(1), uint8_t(0b0100), publish_props {}, "payload"
|
||||||
);
|
);
|
||||||
|
|
||||||
detail::publish_rec_op<client_service_type> { svc_ptr }.perform(pub_msg);
|
detail::publish_rec_op<client_service_type> { svc_ptr }.perform(pub_msg);
|
||||||
|
@@ -17,7 +17,7 @@ BOOST_AUTO_TEST_CASE(test_invalid_topic_filters) {
|
|||||||
"", "+topic", "#topic", "some/#/topic", "topic+",
|
"", "+topic", "#topic", "some/#/topic", "topic+",
|
||||||
"$share//topic"
|
"$share//topic"
|
||||||
};
|
};
|
||||||
const int expected_handlers_called = invalid_topics.size();
|
const int expected_handlers_called = static_cast<int>(invalid_topics.size());
|
||||||
int handlers_called = 0;
|
int handlers_called = 0;
|
||||||
|
|
||||||
asio::io_context ioc;
|
asio::io_context ioc;
|
||||||
@@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(test_wildcard_subscriptions_not_supported) {
|
|||||||
connack_props props;
|
connack_props props;
|
||||||
props[prop::wildcard_subscription_available] = uint8_t(0);
|
props[prop::wildcard_subscription_available] = uint8_t(0);
|
||||||
|
|
||||||
int expected_handlers_called = wildcard_topics.size();
|
int expected_handlers_called = static_cast<int>(wildcard_topics.size());
|
||||||
int handlers_called = 0;
|
int handlers_called = 0;
|
||||||
|
|
||||||
asio::io_context ioc;
|
asio::io_context ioc;
|
||||||
|
Reference in New Issue
Block a user