diff --git a/libtransmission/announcer-udp.cc b/libtransmission/announcer-udp.cc index 6f4b45b82..38f1ca3df 100644 --- a/libtransmission/announcer-udp.cc +++ b/libtransmission/announcer-udp.cc @@ -13,6 +13,12 @@ #include #include +#ifdef _WIN32 +#include +#undef gai_strerror +#define gai_strerror gai_strerrorA +#endif + #include #include @@ -432,7 +438,7 @@ private: fmt::arg("address", host.sv()), fmt::arg("port", port.host()), fmt::arg("error", gai_strerror(rc)), - fmt::arg("error_code", rc))); + fmt::arg("error_code", static_cast(rc)))); return {}; } diff --git a/libtransmission/handshake.cc b/libtransmission/handshake.cc index 24ab2fc7e..a61a40b35 100644 --- a/libtransmission/handshake.cc +++ b/libtransmission/handshake.cc @@ -903,8 +903,8 @@ static ReadState readPayloadStream(tr_handshake* handshake, tr_peerIo* peer_io) } /* parse the handshake ... */ - handshake_parse_err_t const i = parseHandshake(handshake, peer_io); - tr_logAddTraceHand(handshake, fmt::format("parseHandshake returned {}", i)); + auto const i = parseHandshake(handshake, peer_io); + tr_logAddTraceHand(handshake, fmt::format("parseHandshake returned {}", static_cast(i))); if (i != HANDSHAKE_OK) { @@ -989,7 +989,7 @@ static ReadState canRead(tr_peerIo* peer_io, void* vhandshake, size_t* piece) default: #ifdef TR_ENABLE_ASSERTS - TR_ASSERT_MSG(false, fmt::format(FMT_STRING("unhandled handshake state {:d}"), handshake->state)); + TR_ASSERT_MSG(false, fmt::format(FMT_STRING("unhandled handshake state {:d}"), static_cast(handshake->state))); #else ret = READ_ERR; break; diff --git a/libtransmission/net.cc b/libtransmission/net.cc index a42524911..7c7122ec8 100644 --- a/libtransmission/net.cc +++ b/libtransmission/net.cc @@ -384,7 +384,7 @@ void tr_netClosePeerSocket(tr_session* session, tr_peer_socket socket) #endif default: - TR_ASSERT_MSG(false, fmt::format(FMT_STRING("unsupported peer socket type {:d}"), socket.type)); + TR_ASSERT_MSG(false, fmt::format(FMT_STRING("unsupported peer socket type {:d}"), static_cast(socket.type))); } } diff --git a/libtransmission/peer-io.cc b/libtransmission/peer-io.cc index ab6b9ad47..3441a87cc 100644 --- a/libtransmission/peer-io.cc +++ b/libtransmission/peer-io.cc @@ -518,7 +518,7 @@ std::shared_ptr tr_peerIo::create( #endif default: - TR_ASSERT_MSG(false, fmt::format("unsupported peer socket type {:d}", socket.type)); + TR_ASSERT_MSG(false, fmt::format("unsupported peer socket type {:d}", static_cast(socket.type))); } return io; @@ -699,7 +699,7 @@ static void io_close_socket(tr_peerIo* io) #endif default: - tr_logAddDebugIo(io, fmt::format("unsupported peer socket type {}", io->socket.type)); + tr_logAddDebugIo(io, fmt::format("unsupported peer socket type {}", static_cast(io->socket.type))); } io->event_write.reset(); @@ -1010,7 +1010,9 @@ size_t tr_peerIo::flush(tr_direction dir, size_t limit, tr_error** error) TR_ASSERT(tr_isDirection(dir)); auto const bytes_used = dir == TR_DOWN ? tr_peerIoTryRead(this, limit, error) : tr_peerIoTryWrite(this, limit, error); - tr_logAddTraceIo(this, fmt::format("flushing peer-io, direction:{}, limit:{}, byte_used:{}", dir, limit, bytes_used)); + tr_logAddTraceIo( + this, + fmt::format("flushing peer-io, direction:{}, limit:{}, byte_used:{}", static_cast(dir), limit, bytes_used)); return bytes_used; } diff --git a/libtransmission/torrent.cc b/libtransmission/torrent.cc index 49c2baa56..1a37f37f3 100644 --- a/libtransmission/torrent.cc +++ b/libtransmission/torrent.cc @@ -2331,7 +2331,7 @@ void tr_torrentSetQueuePosition(tr_torrent* tor, size_t queue_position) size_t current = 0; auto const old_pos = tor->queuePosition; - tor->queuePosition = -1; + tor->queuePosition = static_cast(-1); for (auto* const walk : tor->session->torrents()) { diff --git a/tests/libtransmission/announcer-udp-test.cc b/tests/libtransmission/announcer-udp-test.cc index acc567dbd..77d69f2d5 100644 --- a/tests/libtransmission/announcer-udp-test.cc +++ b/tests/libtransmission/announcer-udp-test.cc @@ -27,6 +27,8 @@ class AnnouncerUdpTest : public ::testing::Test private: void SetUp() override { + tr_net_init(); + ::testing::Test::SetUp(); tr_timeUpdate(time(nullptr)); } @@ -230,8 +232,8 @@ protected: EXPECT_EQ(expected.up, actual.uploaded); // EXPECT_EQ(foo, actual.event); ; // 0: none; 1: completed; 2: started; 3: stopped // FIXME // EXPECT_EQ(foo, actual.ip_address); // FIXME - EXPECT_EQ(expected.key, actual.key); - EXPECT_EQ(expected.numwant, actual.num_want); + EXPECT_EQ(expected.key, static_cast(actual.key)); + EXPECT_EQ(expected.numwant, static_cast(actual.num_want)); EXPECT_EQ(expected.port.host(), actual.port); } @@ -389,7 +391,7 @@ TEST_F(AnnouncerUdpTest, canDestructCleanlyEvenWhenBusy) // Inspect that request for validity. auto sent = waitForAnnouncerToSendMessage(mediator); auto const connect_transaction_id = parseConnectionRequest(sent); - EXPECT_NE(0, connect_transaction_id); + EXPECT_NE(0U, connect_transaction_id); // now just end the test before responding to the request. // the announcer and mediator will go out-of-scope & be destroyed. diff --git a/tests/libtransmission/dht-test.cc b/tests/libtransmission/dht-test.cc index 1f3b01696..b91970d04 100644 --- a/tests/libtransmission/dht-test.cc +++ b/tests/libtransmission/dht-test.cc @@ -235,8 +235,8 @@ protected: std::vector pinged_; std::vector searched_; std::array id_ = {}; - int dht_socket_ = TR_BAD_SOCKET; - int dht_socket6_ = TR_BAD_SOCKET; + tr_socket_t dht_socket_ = TR_BAD_SOCKET; + tr_socket_t dht_socket6_ = TR_BAD_SOCKET; }; // Creates real timers, but with shortened intervals so that tests can run faster diff --git a/tests/libtransmission/net-test.cc b/tests/libtransmission/net-test.cc index 00c8448e6..e66ca85fc 100644 --- a/tests/libtransmission/net-test.cc +++ b/tests/libtransmission/net-test.cc @@ -61,7 +61,7 @@ TEST_F(NetTest, compact4) auto compact4 = std::array{}; auto out = std::data(compact4); out = addr.toCompact4(out, port); - EXPECT_EQ(std::size(Compact4), out - std::data(compact4)); + EXPECT_EQ(std::size(Compact4), static_cast(out - std::data(compact4))); EXPECT_EQ(Compact4, compact4); /// sockaddr --> compact @@ -115,7 +115,7 @@ TEST_F(NetTest, compact6) auto compact6 = std::array{}; auto out = std::data(compact6); out = addr.toCompact6(out, port); - EXPECT_EQ(std::size(Compact6), out - std::data(compact6)); + EXPECT_EQ(std::size(Compact6), static_cast(out - std::data(compact6))); EXPECT_EQ(Compact6, compact6); /// sockaddr --> compact diff --git a/tests/libtransmission/settings-test.cc b/tests/libtransmission/settings-test.cc index 0ac8ab9cd..b514cd7b6 100644 --- a/tests/libtransmission/settings-test.cc +++ b/tests/libtransmission/settings-test.cc @@ -327,7 +327,7 @@ TEST_F(SettingsTest, canSaveSizeT) settings.save(&dict); auto val = int64_t{}; EXPECT_TRUE(tr_variantDictFindInt(&dict, Key, &val)); - EXPECT_EQ(expected_value, val); + EXPECT_EQ(expected_value, static_cast(val)); tr_variantClear(&dict); }