diff --git a/include/libtorrent/aux_/block_cache_reference.hpp b/include/libtorrent/aux_/block_cache_reference.hpp index ebf79571b..058532970 100644 --- a/include/libtorrent/aux_/block_cache_reference.hpp +++ b/include/libtorrent/aux_/block_cache_reference.hpp @@ -42,13 +42,12 @@ namespace libtorrent { namespace aux { { // if the cookie is set to this value, it doesn't refer to anything in the // cache (and the buffer is mutable) - static std::uint32_t const none = 0xffffffffu; + constexpr static std::int32_t none = 0x7fffffff; storage_index_t storage{0}; - std::uint32_t cookie = none; + std::int32_t cookie = none; }; }} #endif - diff --git a/include/libtorrent/aux_/dev_random.hpp b/include/libtorrent/aux_/dev_random.hpp index 91b787aba..39dca4ef2 100644 --- a/include/libtorrent/aux_/dev_random.hpp +++ b/include/libtorrent/aux_/dev_random.hpp @@ -58,8 +58,8 @@ namespace libtorrent { namespace aux { void read(span buffer) { - std::size_t const ret = ::read(m_fd, buffer.data(), buffer.size()); - if (ret != buffer.size()) + std::int64_t const ret = ::read(m_fd, buffer.data(), buffer.size()); + if (ret != int(buffer.size())) { #ifndef BOOST_NO_EXCEPTIONS throw system_error(errors::no_entropy); diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 2d9546a99..bcaf0ec98 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -474,7 +474,7 @@ namespace libtorrent // used for asserts and only applies for fence jobs flush_expect_clear = 8 }; - void flush_cache(storage_interface* storage, std::uint32_t flags, jobqueue_t& completed_jobs, std::unique_lock& l); + void flush_cache(storage_interface* storage, int flags, jobqueue_t& completed_jobs, std::unique_lock& l); void flush_expired_write_blocks(jobqueue_t& completed_jobs, std::unique_lock& l); void flush_piece(cached_piece_entry* pe, int flags, jobqueue_t& completed_jobs, std::unique_lock& l); diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index 2399f0391..ee7e1e415 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -257,7 +257,7 @@ private: time_point m_last_self_refresh; // secret random numbers used to create write tokens - int m_secret[2]; + std::uint32_t m_secret[2]; udp_socket_interface* m_sock; counters& m_counters; diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index f4242a566..8c02020ff 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -280,7 +280,7 @@ namespace libtorrent { TORRENT_CFG(); settings_pack pack; - pack.set_int(settings_pack::alert_mask, alert_mask); + pack.set_int(settings_pack::alert_mask, int(alert_mask)); pack.set_str(settings_pack::peer_fingerprint, print.to_string()); if ((flags & start_default_features) == 0) { @@ -306,7 +306,7 @@ namespace libtorrent TORRENT_ASSERT(listen_port_range.first <= listen_port_range.second); settings_pack pack; - pack.set_int(settings_pack::alert_mask, alert_mask); + pack.set_int(settings_pack::alert_mask, int(alert_mask)); pack.set_int(settings_pack::max_retry_port_bind, listen_port_range.second - listen_port_range.first); pack.set_str(settings_pack::peer_fingerprint, print.to_string()); char if_string[100]; diff --git a/include/libtorrent/stack_allocator.hpp b/include/libtorrent/stack_allocator.hpp index d31bc951a..fe586fecf 100644 --- a/include/libtorrent/stack_allocator.hpp +++ b/include/libtorrent/stack_allocator.hpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/span.hpp" #include "libtorrent/string_view.hpp" +#include "libtorrent/aux_/vector.hpp" #include // for vsnprintf #include @@ -71,7 +72,7 @@ namespace libtorrent { namespace aux int const ret = int(m_storage.size()); m_storage.resize(ret + str.size() + 1); std::memcpy(&m_storage[ret], str.data(), str.size()); - m_storage[ret + str.length()] = '\0'; + m_storage[ret + int(str.length())] = '\0'; return allocation_slot(ret); } @@ -154,7 +155,7 @@ namespace libtorrent { namespace aux private: - std::vector m_storage; + vector m_storage; }; } } diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index d5fcdd7d2..0bccdbd42 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -844,7 +844,7 @@ namespace libtorrent } } - void disk_io_thread::flush_cache(storage_interface* storage, std::uint32_t const flags + void disk_io_thread::flush_cache(storage_interface* storage, int const flags , jobqueue_t& completed_jobs, std::unique_lock& l) { if (storage) diff --git a/src/kademlia/msg.cpp b/src/kademlia/msg.cpp index ed476ec67..405f1154d 100644 --- a/src/kademlia/msg.cpp +++ b/src/kademlia/msg.cpp @@ -41,14 +41,14 @@ bool verify_message_impl(bdecode_node const& message, span des { TORRENT_ASSERT(desc.size() == ret.size()); - int const size = int(ret.size()); + std::size_t const size = ret.size(); // get a non-root bdecode_node that still // points to the root. message should not be copied bdecode_node msg = message.non_owning(); // clear the return buffer - for (int i = 0; i < size; ++i) + for (std::size_t i = 0; i < size; ++i) ret[i].clear(); // when parsing child nodes, this is the stack @@ -63,7 +63,7 @@ bool verify_message_impl(bdecode_node const& message, span des } ++stack_ptr; stack[stack_ptr] = msg; - for (int i = 0; i < size; ++i) + for (std::size_t i = 0; i < size; ++i) { key_desc_t const& k = desc[i]; diff --git a/src/packet_buffer.cpp b/src/packet_buffer.cpp index 80e0d5aba..d9ec502bc 100644 --- a/src/packet_buffer.cpp +++ b/src/packet_buffer.cpp @@ -144,7 +144,7 @@ namespace libtorrent { return nullptr; } - const int mask = int(m_capacity - 1); + std::size_t const mask = m_capacity - 1; return m_storage[idx & mask]; } @@ -184,7 +184,7 @@ namespace libtorrent { if (compare_less_wrap(idx, m_first, 0xffff)) return nullptr; - const int mask = int(m_capacity - 1); + std::size_t const mask = m_capacity - 1; void* old_value = m_storage[idx & mask]; m_storage[idx & mask] = nullptr; diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index eb8580654..2179839bf 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -319,7 +319,7 @@ namespace // Since the CRC function that is used is not a one way function // the salt is required to avoid attacks where bad data is sent // that is forged to match the CRC of the good data. - int m_salt; + std::uint32_t const m_salt; // explicitly disallow assignment, to silence msvc warning smart_ban_plugin& operator=(smart_ban_plugin const&);