Skip to content

Commit

Permalink
msvc warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anarthal committed Nov 27, 2023
1 parent be7ec9f commit 83994c1
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
2 changes: 2 additions & 0 deletions include/boost/mysql/detail/connection_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <boost/mysql/detail/writable_field_traits.hpp>

#include <boost/asio/any_completion_handler.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/mp11/integer_sequence.hpp>

#include <array>
Expand Down Expand Up @@ -58,6 +59,7 @@ using any_void_handler = asio::any_completion_handler<void(error_code)>;
template <class... T, std::size_t... I>
std::array<field_view, sizeof...(T)> tuple_to_array_impl(const std::tuple<T...>& t, mp11::index_sequence<I...>) noexcept
{
boost::ignore_unused(t); // MSVC gets confused if sizeof...(T) == 0
return std::array<field_view, sizeof...(T)>{{to_field(std::get<I>(t))...}};
}

Expand Down
11 changes: 5 additions & 6 deletions include/boost/mysql/impl/internal/protocol/protocol.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,11 @@ void boost::mysql::detail::execute_stmt_command::serialize(span<std::uint8_t> bu
serialization_context ctx(buff.data());
BOOST_ASSERT(buff.size() >= get_size());

std::uint32_t statement_id = this->statement_id;
std::uint8_t flags = 0;
std::uint32_t iteration_count = 1;
std::uint8_t new_params_bind_flag = 1;

::boost::mysql::detail::serialize(ctx, command_id, statement_id, flags, iteration_count);
::boost::mysql::detail::serialize(ctx, command_id, this->statement_id, flags, iteration_count);

// Number of parameters
auto num_params = params.size();
Expand Down Expand Up @@ -1043,7 +1042,7 @@ boost::mysql::detail::handhake_server_response boost::mysql::detail::deserialize
{
// We have received an auth switch request. Deserialize it
auth_switch auth_sw{};
auto err = deserialize_auth_switch(ctx.to_span(), auth_sw);
err = deserialize_auth_switch(ctx.to_span(), auth_sw);
if (err)
return err;
return auth_sw;
Expand All @@ -1053,9 +1052,9 @@ boost::mysql::detail::handhake_server_response boost::mysql::detail::deserialize
// We have received an auth more data request. Deserialize it.
// Note that string_eof never fails deserialization (by definition)
string_eof auth_more_data;
auto err = deserialize(ctx, auth_more_data);
BOOST_ASSERT(err == deserialize_errc::ok);
boost::ignore_unused(err);
auto ec = deserialize(ctx, auth_more_data);
BOOST_ASSERT(ec == deserialize_errc::ok);
boost::ignore_unused(ec);

// If the special value fast_auth_complete_challenge
// is received as auth data, it means that the auth is complete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class message_reader
// with the number of bytes read
void resume(std::size_t bytes_read)
{
frame_header header;
frame_header header{};
buffer_.move_to_pending(bytes_read);

BOOST_ASIO_CORO_REENTER(state_.coro)
Expand Down
2 changes: 1 addition & 1 deletion include/boost/mysql/impl/resultset.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void boost::mysql::resultset::assign(resultset_view v)
rws_ = v.rows();
affected_rows_ = v.affected_rows();
last_insert_id_ = v.last_insert_id();
warnings_ = v.warning_count();
warnings_ = static_cast<std::uint16_t>(v.warning_count());
info_.assign(v.info().begin(), v.info().end());
is_out_params_ = v.is_out_params();
}
Expand Down
4 changes: 3 additions & 1 deletion test/common/include/test_common/validate_string_contains.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ namespace test {

inline void validate_string_contains(std::string value, const std::vector<std::string>& to_check)
{
std::transform(value.begin(), value.end(), value.begin(), &tolower);
std::transform(value.begin(), value.end(), value.begin(), [](char c) {
return static_cast<char>(tolower(c));
});
for (const auto& elm : to_check)
{
BOOST_TEST(
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test/auth/auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ BOOST_FIXTURE_TEST_CASE(non_empty_password_cleartext_auth_ssl_false, fixture)

BOOST_FIXTURE_TEST_CASE(non_empty_password_cleartext_auth_ssl_true, fixture)
{
constexpr std::uint8_t expected[] = {'h', 'o', 'l', 'a', '\0'};
constexpr std::uint8_t expected_local[] = {'h', 'o', 'l', 'a', '\0'};
auto err = compute_auth_response("caching_sha2_password", "hola", cleartext_challenge, true, resp);
BOOST_TEST_REQUIRE(err == error_code());
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(resp.data, expected);
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(resp.data, expected_local);
BOOST_TEST(resp.plugin_name == "caching_sha2_password");
}

Expand Down
16 changes: 8 additions & 8 deletions test/unit/test/detail/datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ BOOST_AUTO_TEST_CASE(ymd_to_days_days_to_ymd)
// Starting from 1970, going up
int num_days = 0;

for (int year = 1970; year <= 2204; ++year)
for (std::uint16_t year = 1970u; year <= 2204u; ++year)
{
for (unsigned month = 1; month <= 12; ++month)
for (std::uint8_t month = 1u; month <= 12u; ++month)
{
unsigned last_month_day = month == 2 && is_leap_year(year) ? 29u : last_day_of_month(month);
for (unsigned day = 1; day <= last_month_day; ++day)
std::uint8_t last_month_day = month == 2u && is_leap_year(year) ? 29u : last_day_of_month(month);
for (std::uint8_t day = 1u; day <= last_month_day; ++day)
{
ymd_years_test(st, year, month, day, num_days++);
}
Expand All @@ -196,12 +196,12 @@ BOOST_AUTO_TEST_CASE(ymd_to_days_days_to_ymd)
// Starting from 1970, going down
num_days = -1;

for (int year = 1969; year >= 1804; --year)
for (std::uint16_t year = 1969u; year >= 1804u; --year)
{
for (unsigned month = 12; month >= 1; --month)
for (std::uint8_t month = 12u; month >= 1u; --month)
{
unsigned last_month_day = month == 2 && is_leap_year(year) ? 29u : last_day_of_month(month);
for (unsigned day = last_month_day; day >= 1; --day)
std::uint8_t last_month_day = month == 2u && is_leap_year(year) ? 29u : last_day_of_month(month);
for (std::uint8_t day = last_month_day; day >= 1u; --day)
{
ymd_years_test(st, year, month, day, num_days--);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ BOOST_AUTO_TEST_CASE(tuples)
fields
);
throw_on_error(err);
BOOST_TEST((storage_1[0] == row1_tuple{10, "abc"}));
BOOST_TEST((storage_1[0] == row1_tuple{10u, "abc"}));

// EOF r1
add_ok(st, create_ok_r1(true));
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test/execution_processor/static_results_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,10 @@ BOOST_AUTO_TEST_CASE(tuples)

// Verify
std::vector<row1_tuple> expected_r1{
row1_tuple{10, "abc"}
row1_tuple{10u, "abc"}
};
std::vector<row3_tuple> expected_r3{
row3_tuple{4.2f, 90.0, 9}
row3_tuple{4.2f, 90.0, 9u}
};
BOOST_TEST(st.is_complete());
check_meta_r1(st.get_meta(0));
Expand Down

0 comments on commit 83994c1

Please sign in to comment.