diff --git a/include/libtorrent/enum_net.hpp b/include/libtorrent/enum_net.hpp index ce694d808..a2280466a 100644 --- a/include/libtorrent/enum_net.hpp +++ b/include/libtorrent/enum_net.hpp @@ -177,4 +177,3 @@ namespace libtorrent } #endif - diff --git a/include/libtorrent/http_tracker_connection.hpp b/include/libtorrent/http_tracker_connection.hpp index 680d7fc76..0873518c1 100644 --- a/include/libtorrent/http_tracker_connection.hpp +++ b/include/libtorrent/http_tracker_connection.hpp @@ -95,7 +95,7 @@ namespace libtorrent TORRENT_EXTRA_EXPORT tracker_response parse_tracker_response( char const* data, int size, error_code& ec - , int flags, sha1_hash scrape_ih); + , int flags, sha1_hash const& scrape_ih); TORRENT_EXTRA_EXPORT bool extract_peer_info(bdecode_node const& info , peer_entry& ret, error_code& ec); diff --git a/src/enum_net.cpp b/src/enum_net.cpp index d06273978..6258ed8e2 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -363,7 +363,7 @@ namespace libtorrent b1[i] &= m[i]; b2[i] &= m[i]; } - return memcmp(&b1[0], &b2[0], b1.size()) == 0; + return std::memcmp(b1.data(), b2.data(), b1.size()) == 0; } #endif return (a1.to_v4().to_ulong() & mask.to_v4().to_ulong()) @@ -379,10 +379,9 @@ namespace libtorrent bool in_local_network(std::vector const& net, address const& addr) { - for (std::vector::const_iterator i = net.begin() - , end(net.end()); i != end; ++i) + for (auto const& i : net) { - if (match_addr_mask(addr, i->interface_address, i->netmask)) + if (match_addr_mask(addr, i.interface_address, i.netmask)) return true; } return false; @@ -703,7 +702,7 @@ namespace libtorrent address get_default_gateway(io_service& ios, error_code& ec) { std::vector ret = enum_routes(ios, ec); - std::vector::iterator i = std::find_if(ret.begin(), ret.end() + auto const i = std::find_if(ret.begin(), ret.end() , [](ip_route const& r) { return r.destination == address(); }); if (i == ret.end()) return address(); return i->gateway; @@ -845,9 +844,9 @@ namespace libtorrent } close(s); */ - int mib[6] = { CTL_NET, PF_ROUTE, 0, AF_UNSPEC, NET_RT_DUMP, 0}; + int mib[6] = {CTL_NET, PF_ROUTE, 0, AF_UNSPEC, NET_RT_DUMP, 0}; - size_t needed = 0; + std::size_t needed = 0; #ifdef TORRENT_OS2 if (__libsocket_sysctl(mib, 6, 0, &needed, 0, 0) < 0) #else diff --git a/src/file_storage.cpp b/src/file_storage.cpp index fe2dbbfe2..8c679586b 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -1138,4 +1138,3 @@ namespace libtorrent } // namespace aux } - diff --git a/src/http_connection.cpp b/src/http_connection.cpp index 97f52f41e..08ed6a02f 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -260,7 +260,7 @@ void http_connection::start(std::string const& hostname, int port if (ec) { m_timer.get_io_service().post(std::bind(&http_connection::callback - , me, ec, static_cast(nullptr), 0)); + , me, ec, nullptr, 0)); return; } @@ -339,7 +339,7 @@ void http_connection::start(std::string const& hostname, int port if (ec) { m_timer.get_io_service().post(std::bind(&http_connection::callback - , me, ec, static_cast(nullptr), 0)); + , me, ec, nullptr, 0)); return; } } @@ -355,12 +355,12 @@ void http_connection::start(std::string const& hostname, int port if (m_bind_addr != address_v4::any()) { - m_sock.open(m_bind_addr.is_v4()?tcp::v4():tcp::v6(), ec); + m_sock.open(m_bind_addr.is_v4() ? tcp::v4() : tcp::v6(), ec); m_sock.bind(tcp::endpoint(m_bind_addr, 0), ec); if (ec) { m_timer.get_io_service().post(std::bind(&http_connection::callback - , me, ec, static_cast(nullptr), 0)); + , me, ec, nullptr, 0)); return; } } @@ -369,7 +369,7 @@ void http_connection::start(std::string const& hostname, int port if (ec) { m_timer.get_io_service().post(std::bind(&http_connection::callback - , me, ec, static_cast(nullptr), 0)); + , me, ec, nullptr, 0)); return; } @@ -518,9 +518,8 @@ void http_connection::on_resolve(error_code const& e } TORRENT_ASSERT(!addresses.empty()); - for (std::vector
::const_iterator i = addresses.begin() - , end(addresses.end()); i != end; ++i) - m_endpoints.push_back(tcp::endpoint(*i, m_port)); + for (auto const& addr : addresses) + m_endpoints.push_back({addr, m_port}); if (m_filter_handler) m_filter_handler(*this, m_endpoints); if (m_endpoints.empty()) @@ -793,7 +792,7 @@ void http_connection::on_read(error_code const& e if (!m_bottled && m_parser.header_finished()) { if (m_read_pos > m_parser.body_start()) - callback(e, &m_recvbuffer[0] + m_parser.body_start() + callback(e, m_recvbuffer.data() + m_parser.body_start() , m_read_pos - m_parser.body_start()); m_read_pos = 0; m_last_receive = clock_type::now(); @@ -810,14 +809,14 @@ void http_connection::on_read(error_code const& e else { TORRENT_ASSERT(!m_bottled); - callback(e, &m_recvbuffer[0], m_read_pos); + callback(e, m_recvbuffer.data(), m_read_pos); m_read_pos = 0; m_last_receive = clock_type::now(); } // if we've hit the limit, double the buffer size if (int(m_recvbuffer.size()) == m_read_pos) - m_recvbuffer.resize((std::min)(m_read_pos * 2, m_max_bottled_buffer_size)); + m_recvbuffer.resize(std::min(m_read_pos * 2, m_max_bottled_buffer_size)); if (m_read_pos == m_max_bottled_buffer_size) { @@ -841,7 +840,7 @@ void http_connection::on_read(error_code const& e } } ADD_OUTSTANDING_ASYNC("http_connection::on_read"); - m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos + m_sock.async_read_some(boost::asio::buffer(m_recvbuffer.data() + m_read_pos , amount_to_read) , std::bind(&http_connection::on_read , me, _1, _2)); @@ -871,7 +870,7 @@ void http_connection::on_assign_bandwidth(error_code const& e) if (!m_sock.is_open()) return; ADD_OUTSTANDING_ASYNC("http_connection::on_read"); - m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos + m_sock.async_read_some(boost::asio::buffer(m_recvbuffer.data() + m_read_pos , amount_to_read) , std::bind(&http_connection::on_read , shared_from_this(), _1, _2)); diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 38bef9abb..a7dc517e2 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -101,7 +101,7 @@ namespace libtorrent // if request-string already contains // some parameters, append an ampersand instead // of a question mark - size_t arguments_start = url.find('?'); + std::size_t arguments_start = url.find('?'); if (arguments_start != std::string::npos) url += "&"; else @@ -264,8 +264,7 @@ namespace libtorrent if (!tracker_req().filter) return; // remove endpoints that are filtered by the IP filter - for (std::vector::iterator i = endpoints.begin(); - i != endpoints.end();) + for (auto i = endpoints.begin(); i != endpoints.end();) { if (tracker_req().filter->access(i->address()) == ip_filter::blocked) i = endpoints.erase(i); @@ -412,8 +411,8 @@ namespace libtorrent return true; } - tracker_response parse_tracker_response(char const* data, int size, error_code& ec - , int flags, sha1_hash scrape_ih) + tracker_response parse_tracker_response(char const* data, int const size, error_code& ec + , int const flags, sha1_hash const& scrape_ih) { tracker_response resp;