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:
Korina Šimičević
2024-01-02 11:40:53 +01:00
parent 7c0b9042d1
commit 794c72cb44
21 changed files with 43 additions and 33 deletions

View File

@ -21,7 +21,7 @@ struct tls_handshake_type<asio::ssl::stream<StreamBase>> {
template <typename StreamBase>
void assign_tls_sni(
const authority_path& ap,
asio::ssl::context& ctx,
asio::ssl::context& /* ctx */,
asio::ssl::stream<StreamBase>& stream
) {
SSL_set_tlsext_host_name(stream.native_handle(), ap.host.c_str());

View File

@ -1,10 +1,10 @@
void run_openssl_tls_examples();
void run_tcp_examples();
void run_openssl_tls_examples();
void run_websocket_tcp_examples();
void run_websocket_tls_examples();
int main(int argc, char* argv[]) {
int main() {
run_tcp_examples();
run_openssl_tls_examples();

View File

@ -18,11 +18,11 @@ void publish_qos0_tcp() {
client_type c(ioc, "");
connect_props props;
props[prop::maximum_packet_size] = 1024;
props[prop::maximum_packet_size] = int16_t(1024);
c.credentials("test-qos0-tcp", "", "")
.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))
.run();

View File

@ -15,7 +15,7 @@ namespace boost::beast::websocket {
template <typename TeardownHandler>
void async_teardown(
boost::beast::role_type role,
boost::beast::role_type /* role */,
asio::ssl::stream<asio::ip::tcp::socket>& stream,
TeardownHandler&& handler
) {
@ -35,7 +35,7 @@ struct tls_handshake_type<asio::ssl::stream<StreamBase>> {
template <typename StreamBase>
void assign_tls_sni(
const authority_path& ap,
asio::ssl::context& ctx,
asio::ssl::context& /* ctx */,
asio::ssl::stream<StreamBase>& stream
) {
SSL_set_tlsext_host_name(stream.native_handle(), ap.host.c_str());

View File

@ -125,7 +125,7 @@ class packet_id_allocator {
public:
packet_id_allocator() {
_free_ids.emplace_back(MAX_PACKET_ID, 0);
_free_ids.emplace_back(MAX_PACKET_ID, uint16_t(0));
}
uint16_t allocate() {

View File

@ -223,7 +223,7 @@ private:
_write_queue.begin(), _write_queue.end(),
[](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);
_quota -= throttled_num;
throttled_ptr += throttled_num;

View File

@ -212,7 +212,7 @@ public:
client_service(
const executor_type& ex,
const std::string& cnf,
const std::string& /* cnf */,
tls_context_type tls_context = {}
) :
_stream_context(std::move(tls_context)),

View File

@ -351,7 +351,7 @@ inline std::string encode_pingreq() {
basic::flag<4>(0);
auto remaining_len_ =
basic::byte_(0);
basic::byte_(uint8_t(0));
auto ping_req_ = packet_type_ & remaining_len_;
@ -364,7 +364,7 @@ inline std::string encode_pingresp() {
basic::flag<4>(0);
auto remaining_len_ =
basic::byte_(0);
basic::byte_(uint8_t(0));
auto ping_resp_ = packet_type_ & remaining_len_;

View File

@ -279,7 +279,7 @@ public:
}
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);
if (!rv.has_value())
return complete(client::error::malformed_packet);
@ -313,7 +313,7 @@ public:
}
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);
if (!rv.has_value())
return complete(client::error::malformed_packet);

View File

@ -141,7 +141,7 @@ public:
if (ec)
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()) {
on_malformed_packet("Malformed PUBREL received: cannot decode");
return wait_pubrel(packet_id);

View File

@ -205,7 +205,9 @@ public:
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()) {
on_malformed_packet("Malformed PUBACK: cannot decode");
return send_publish(std::move(publish.set_dup()));
@ -239,7 +241,9 @@ public:
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()) {
on_malformed_packet("Malformed PUBREC: cannot decode");
return send_publish(std::move(publish.set_dup()));
@ -317,7 +321,9 @@ public:
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()) {
on_malformed_packet("Malformed PUBCOMP: cannot decode");
return send_pubrel(std::move(pubrel), true);

View File

@ -88,7 +88,7 @@ private:
switch (code) {
case control_code_e::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())
return on_malformed_packet(
@ -105,7 +105,7 @@ private:
break;
case control_code_e::auth: {
auto rv = decoders::decode_auth(
std::distance(first, last), first
static_cast<uint32_t>(std::distance(first, last)), first
);
if (!rv.has_value())
return on_malformed_packet(

View File

@ -134,7 +134,9 @@ public:
if (ec)
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()) {
on_malformed_packet("Malformed SUBACK: cannot decode");
return send_subscribe(std::move(packet));

View File

@ -131,7 +131,7 @@ public:
return complete(ec, packet_id, {}, {});
auto unsuback = decoders::decode_unsuback(
std::distance(first, last), first
static_cast<uint32_t>(std::distance(first, last)), first
);
if (!unsuback.has_value()) {
on_malformed_packet("Malformed UNSUBACK: cannot decode");

View File

@ -86,6 +86,7 @@ void cancel_async_publish() {
"topic", "payload", retain_e::yes, {},
[&handlers_called](error_code ec, reason_code rc, puback_props) {
BOOST_CHECK_EQUAL(ec, asio::error::operation_aborted);
BOOST_CHECK_EQUAL(rc, reason_codes::empty);
handlers_called++;
}
);
@ -95,6 +96,7 @@ void cancel_async_publish() {
"topic", "payload", retain_e::yes, {},
[&handlers_called](error_code ec, reason_code rc, pubcomp_props) {
BOOST_CHECK_EQUAL(ec, asio::error::operation_aborted);
BOOST_CHECK_EQUAL(rc, reason_codes::empty);
handlers_called++;
}
);

View File

@ -413,7 +413,7 @@ BOOST_AUTO_TEST_CASE(throttling) {
int handlers_called = 0;
connack_props props;
props[prop::receive_maximum] = 1;
props[prop::receive_maximum] = int16_t(1);
//packets
auto connect = encoders::encode_connect(

View File

@ -18,7 +18,7 @@ namespace boost::beast::websocket {
template <typename TeardownHandler>
void async_teardown(
boost::beast::role_type role,
boost::beast::role_type /* role */,
asio::ssl::stream<asio::ip::tcp::socket>& stream,
TeardownHandler&& handler
) {
@ -62,7 +62,7 @@ struct tls_handshake_type<asio::ssl::stream<StreamBase>> {
template <typename StreamBase>
void assign_tls_sni(
const authority_path& ap,
asio::ssl::context& ctx,
asio::ssl::context& /* ctx */,
asio::ssl::stream<StreamBase>& stream
) {
SSL_set_tlsext_host_name(stream.native_handle(), ap.host.c_str());

View File

@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(test_invalid_topic_names) {
"", "+", "#",
"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;
asio::io_context ioc;
@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(test_malformed_packet) {
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;
asio::io_context ioc;
@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(test_topic_alias_maximum) {
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;
asio::io_context ioc;

View File

@ -58,9 +58,9 @@ BOOST_AUTO_TEST_CASE(test_connect) {
BOOST_AUTO_TEST_CASE(test_connack) {
// testing variables
bool session_present = true;
uint8_t session_present = 1;
uint8_t reason_code = 0x89;
bool wildcard_sub = true;
uint8_t wildcard_sub = 1;
connack_props cap;
cap[prop::wildcard_subscription_available] = wildcard_sub;

View File

@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(clear_waiting_on_pubrel) {
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor());
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);

View File

@ -17,7 +17,7 @@ BOOST_AUTO_TEST_CASE(test_invalid_topic_filters) {
"", "+topic", "#topic", "some/#/topic", "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;
asio::io_context ioc;
@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(test_wildcard_subscriptions_not_supported) {
connack_props props;
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;
asio::io_context ioc;