From f89c27183ba5528f9c806b4eda0a1b4081f3025d Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 17 Jul 2018 11:33:22 +0200 Subject: [PATCH 1/2] remove unused function --- include/libtorrent/peer_connection.hpp | 1 - src/peer_connection.cpp | 25 ------------------------- 2 files changed, 26 deletions(-) diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 38aa7553f..23c6e5efc 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -802,7 +802,6 @@ namespace libtorrent peer_connection& operator=(peer_connection const&); void do_update_interest(); - int preferred_caching() const; void fill_send_buffer(); void on_disk_read_complete(disk_io_job const* j, peer_request r , time_point issue_time); diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 1427c47da..3b8912bed 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -5105,31 +5105,6 @@ namespace libtorrent send_block_requests(); } - int peer_connection::preferred_caching() const - { - TORRENT_ASSERT(is_single_thread()); - int line_size = 0; - if (m_settings.get_bool(settings_pack::guided_read_cache)) - { - boost::shared_ptr t = m_torrent.lock(); - int upload_rate = m_statistics.upload_payload_rate(); - if (upload_rate == 0) upload_rate = 1; - - int num_uploads = m_ses.num_uploads(); - if (num_uploads == 0) num_uploads = 1; - - // assume half of the cache is write cache if we're downloading - // this torrent as well - int cache_size = m_settings.get_int(settings_pack::cache_size) / num_uploads; - if (!t->is_upload_only()) cache_size /= 2; - // cache_size is the amount of cache we have per peer. The - // cache line should not be greater than this - - line_size = cache_size; - } - return line_size; - } - void peer_connection::fill_send_buffer() { TORRENT_ASSERT(is_single_thread()); From 5d3ac8ff5c6cf5501267d0cb95211ea9fe9db72f Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 17 Jul 2018 12:06:20 +0200 Subject: [PATCH 2/2] fix some warnings --- src/bt_peer_connection.cpp | 1 - src/pe_crypto.cpp | 2 ++ src/string_util.cpp | 7 ++++--- src/torrent_info.cpp | 8 +++----- src/xml_parse.cpp | 1 - 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 57a9ce3b8..c29add0aa 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -836,7 +836,6 @@ namespace libtorrent ptr += 20; memcpy(ptr, &m_our_peer_id[0], 20); - ptr += 20; #ifndef TORRENT_DISABLE_LOGGING { diff --git a/src/pe_crypto.cpp b/src/pe_crypto.cpp index 4d3d461c9..45f920e63 100644 --- a/src/pe_crypto.cpp +++ b/src/pe_crypto.cpp @@ -204,7 +204,9 @@ namespace libtorrent { *i = boost::asio::mutable_buffer(boost::asio::buffer_cast(*i), to_process); iovec.erase(++i, iovec.end()); +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS to_process = 0; +#endif break; } to_process -= boost::asio::buffer_size(*i); diff --git a/src/string_util.cpp b/src/string_util.cpp index d2a238890..3bae80b29 100644 --- a/src/string_util.cpp +++ b/src/string_util.cpp @@ -147,9 +147,10 @@ namespace libtorrent char* allocate_string_copy(char const* str) { if (str == 0) return 0; - char* tmp = static_cast(std::malloc(std::strlen(str) + 1)); - if (tmp == 0) return 0; - std::strcpy(tmp, str); + int const len = std::strlen(str) + 1; + char* tmp = static_cast(std::malloc(len)); + if (tmp == NULL) return 0; + std::memcpy(tmp, str, len); return tmp; } diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 941a25a7b..1d997b622 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -163,6 +163,7 @@ namespace libtorrent UTF8 sequence[5]; UTF8* start = sequence; res = ConvertUTF32toUTF8(const_cast(&cp), cp + 1, &start, start + 5, lenientConversion); + TORRENT_UNUSED(res); TORRENT_ASSERT(res == conversionOK); for (int i = 0; i < std::min(5, int(start - sequence)); ++i) @@ -722,8 +723,7 @@ namespace libtorrent } #ifndef TORRENT_NO_DEPRECATE - torrent_info::torrent_info(lazy_entry const& torrent_file, error_code& ec - , int flags) + torrent_info::torrent_info(lazy_entry const& torrent_file, error_code& ec, int) : m_piece_hashes(0) , m_creation_date(0) , m_info_section_size(0) @@ -732,7 +732,6 @@ namespace libtorrent , m_private(false) , m_i2p(false) { - TORRENT_UNUSED(flags); std::pair buf = torrent_file.data_section(); bdecode_node e; if (bdecode(buf.first, buf.first + buf.second, e, ec) != 0) @@ -740,7 +739,7 @@ namespace libtorrent parse_torrent_file(e, ec, 0); } - torrent_info::torrent_info(lazy_entry const& torrent_file, int flags) + torrent_info::torrent_info(lazy_entry const& torrent_file, int) : m_piece_hashes(0) , m_creation_date(0) , m_info_section_size(0) @@ -749,7 +748,6 @@ namespace libtorrent , m_private(false) , m_i2p(false) { - TORRENT_UNUSED(flags); std::pair buf = torrent_file.data_section(); bdecode_node e; error_code ec; diff --git a/src/xml_parse.cpp b/src/xml_parse.cpp index a045fec5e..81555761f 100644 --- a/src/xml_parse.cpp +++ b/src/xml_parse.cpp @@ -128,7 +128,6 @@ namespace libtorrent token = xml_comment; const int name_len = tag_name_end - start - 2; callback(token, start, name_len, NULL, 0); - tag_end = p - 2; continue; } else