From 8da635d1f58f7b4f375019604bfca7c7b7c3b051 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Tue, 1 May 2018 08:41:39 -0400 Subject: [PATCH] minor code cleanup, more use of const --- include/libtorrent/kademlia/find_data.hpp | 2 -- src/block_cache.cpp | 2 +- src/bt_peer_connection.cpp | 12 ++++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/libtorrent/kademlia/find_data.hpp b/include/libtorrent/kademlia/find_data.hpp index 3428f11f5..108568764 100644 --- a/include/libtorrent/kademlia/find_data.hpp +++ b/include/libtorrent/kademlia/find_data.hpp @@ -35,8 +35,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include -#include #include #include diff --git a/src/block_cache.cpp b/src/block_cache.cpp index 3c7fd0f83..b467c0e8f 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -283,7 +283,7 @@ static_assert(int(job_action_name.size()) == static_cast(job_action_t::num_ , int(pe->outstanding_flush), int(pe->piece), int(pe->num_dirty) , int(pe->num_blocks), int(pe->blocks_in_piece), int(pe->hashing_done) , int(pe->marked_for_eviction), int(pe->need_readback), pe->hash_passes - , int(pe->read_jobs.size()), int(pe->jobs.size())); + , pe->read_jobs.size(), pe->jobs.size()); bool first = true; for (auto const& log : pe->piece_log) { diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index bcebf87d6..7307fd562 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -2405,7 +2405,7 @@ namespace { TORRENT_ASSERT(m_statistics.last_protocol_downloaded() - cur_protocol_dl >= 0); std::int64_t const stats_diff = m_statistics.last_payload_downloaded() - cur_payload_dl + m_statistics.last_protocol_downloaded() - cur_protocol_dl; - TORRENT_ASSERT(stats_diff == int(sub_transferred)); + TORRENT_ASSERT(stats_diff == sub_transferred); #endif if (m_disconnecting) return; @@ -2665,7 +2665,7 @@ namespace { rc4_decrypt({m_sync_vc.get(), 8}); } - TORRENT_ASSERT(m_sync_vc.get()); + TORRENT_ASSERT(m_sync_vc); int const syncoffset = search({m_sync_vc.get(), 8}, recv_buffer); // No sync @@ -2791,7 +2791,7 @@ namespace { m_rc4_encrypted = true; } - int len_pad = aux::read_int16(recv_buffer); + int const len_pad = aux::read_int16(recv_buffer); if (len_pad < 0 || len_pad > 512) { disconnect(errors::invalid_pad_size, operation_t::encryption, 2); @@ -2835,7 +2835,7 @@ namespace { if (!is_outgoing()) { recv_buffer = recv_buffer.subspan(aux::numeric_cast(pad_size)); - int len_ia = aux::read_int16(recv_buffer); + int const len_ia = aux::read_int16(recv_buffer); if (len_ia < 0) { @@ -2958,7 +2958,7 @@ namespace { static const char protocol_string[] = "\x13" "BitTorrent protocol"; if (packet_size != 19 || - memcmp(recv_buffer.begin(), protocol_string, 20) != 0) + std::memcmp(recv_buffer.begin(), protocol_string, 20) != 0) { #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) #ifndef TORRENT_DISABLE_LOGGING @@ -3280,7 +3280,7 @@ namespace { TORRENT_ASSERT(bytes_transferred <= 1); const char* ptr = recv_buffer.begin(); - int packet_size = detail::read_int32(ptr); + int const packet_size = detail::read_int32(ptr); // don't accept packets larger than 1 MB if (packet_size > 1024 * 1024 || packet_size < 0)