From 1f06a6684c38419e15ca988b22da3cb64809811d Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Wed, 28 Mar 2018 12:32:59 -0400 Subject: [PATCH] avoid calling address to test protocol, more consts and minor lint oriented code changes --- include/libtorrent/aux_/storage_utils.hpp | 3 ++- src/storage_utils.cpp | 7 +++---- src/udp_tracker_connection.cpp | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/libtorrent/aux_/storage_utils.hpp b/include/libtorrent/aux_/storage_utils.hpp index bb6c1279d..c6d5d2a1e 100644 --- a/include/libtorrent/aux_/storage_utils.hpp +++ b/include/libtorrent/aux_/storage_utils.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_STORAGE_UTILS_HPP_INCLUDE #include +#include #include "libtorrent/config.hpp" #include "libtorrent/span.hpp" @@ -86,7 +87,7 @@ namespace aux { // opt to only delete the partfile TORRENT_EXTRA_EXPORT void delete_files(file_storage const& fs, std::string const& save_path - , std::string const& part_file_name, remove_flags_t const options, storage_error& ec); + , std::string const& part_file_name, remove_flags_t options, storage_error& ec); TORRENT_EXTRA_EXPORT bool verify_resume_data(add_torrent_params const& rd diff --git a/src/storage_utils.cpp b/src/storage_utils.cpp index 4bdfb7177..6cb4a5acb 100644 --- a/src/storage_utils.cpp +++ b/src/storage_utils.cpp @@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/add_torrent_params.hpp" #include -#include namespace libtorrent { namespace aux { @@ -173,9 +172,9 @@ namespace libtorrent { namespace aux { // make a copy of the iovec array that _just_ covers the next // file_bytes_left bytes, i.e. just this one operation - int tmp_bufs_used = copy_bufs(current_buf, file_bytes_left, tmp_buf); + int const tmp_bufs_used = copy_bufs(current_buf, file_bytes_left, tmp_buf); - int bytes_transferred = op(file_index, file_offset + int const bytes_transferred = op(file_index, file_offset , tmp_buf.first(tmp_bufs_used), ec); if (ec) return -1; @@ -265,7 +264,7 @@ namespace libtorrent { namespace aux { // later aux::vector copied_files(std::size_t(f.num_files()), false); - file_index_t i; + file_index_t i{}; error_code e; for (i = file_index_t(0); i < f.end_file(); ++i) { diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index 016f4fa9e..f35c64038 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -649,12 +649,12 @@ namespace libtorrent { } #if TORRENT_USE_IPV6 - if (m_target.address().is_v6()) + if (m_target.protocol() == udp::v6()) { resp.peers6.reserve(std::size_t(num_peers)); for (int i = 0; i < num_peers; ++i) { - ipv6_peer_entry e; + ipv6_peer_entry e{}; std::memcpy(e.ip.data(), buf.data(), 16); buf = buf.subspan(16); e.port = aux::read_uint16(buf); @@ -667,7 +667,7 @@ namespace libtorrent { resp.peers4.reserve(std::size_t(num_peers)); for (int i = 0; i < num_peers; ++i) { - ipv4_peer_entry e; + ipv4_peer_entry e{}; std::memcpy(e.ip.data(), buf.data(), 4); buf = buf.subspan(4); e.port = aux::read_uint16(buf);