From fedee2b5fa6d5b5f7ce1895e53b637aff5305c6e Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Mon, 12 Feb 2018 17:13:50 -0500 Subject: [PATCH] more headers code cleanup and some lint oriented refactor --- include/libtorrent/aux_/session_impl.hpp | 12 +++----- include/libtorrent/sha1_hash.hpp | 2 +- include/libtorrent/sliding_average.hpp | 29 ------------------- include/libtorrent/storage.hpp | 4 +-- include/libtorrent/tracker_manager.hpp | 8 +---- include/libtorrent/udp_tracker_connection.hpp | 1 - 6 files changed, 7 insertions(+), 49 deletions(-) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 5f69df41c..529ad0033 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -209,9 +209,9 @@ namespace aux { struct TORRENT_EXTRA_EXPORT listen_endpoint_t { - listen_endpoint_t(address adr, int p, std::string dev, transport s + listen_endpoint_t(address const& adr, int p, std::string dev, transport s , duplex d = duplex::accept_incoming) - : addr(adr), port(p), device(dev), ssl(s), incoming(d) {} + : addr(adr), port(p), device(std::move(dev)), ssl(s), incoming(d) {} bool operator==(listen_endpoint_t const& o) const { @@ -289,7 +289,7 @@ namespace aux { struct session_plugin_wrapper : plugin { - explicit session_plugin_wrapper(ext_function_t const& f) : m_f(f) {} + explicit session_plugin_wrapper(ext_function_t f) : m_f(std::move(f)) {} std::shared_ptr new_torrent(torrent_handle const& t, void* user) override { return m_f(t, user); } @@ -592,7 +592,6 @@ namespace aux { void get_cache_info(torrent_handle h, cache_status* ret, int flags) const; - void set_key(std::uint32_t key); std::uint16_t listen_port() const override; std::uint16_t listen_port(listen_socket_t* sock) const; std::uint16_t ssl_listen_port() const override; @@ -659,9 +658,6 @@ namespace aux { void deferred_submit_jobs() override; - torrent_peer* allocate_peer_entry(int type); - void free_peer_entry(torrent_peer* p); - // implements dht_observer void set_external_address(aux::listen_socket_handle const& iface , address const& ip, address const& source) override; @@ -788,7 +784,7 @@ namespace aux { void on_lsd_peer(tcp::endpoint const& peer, sha1_hash const& ih) override; void set_external_address(std::shared_ptr const& sock, address const& ip - , ip_source_t const source_type, address const& source); + , ip_source_t source_type, address const& source); void interface_to_endpoints(std::string const& device, int port , transport ssl, duplex incoming, std::vector& eps); diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index 172f6d046..ba479ecef 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -64,7 +64,7 @@ namespace aux { // // This data structure is 32 bits aligned, like it's the case for // each SHA-N specification. - template + template class digest32 { static_assert(N % 32 == 0, "N must be a multiple of 32"); diff --git a/include/libtorrent/sliding_average.hpp b/include/libtorrent/sliding_average.hpp index 14174057c..068b27813 100644 --- a/include/libtorrent/sliding_average.hpp +++ b/include/libtorrent/sliding_average.hpp @@ -83,35 +83,6 @@ private: int m_num_samples = 0; }; -struct average_accumulator -{ - average_accumulator() {} - - void add_sample(std::int64_t s) - { - ++m_num_samples; - m_sample_sum += s; - } - - int mean() - { - int ret; - if (m_num_samples == 0) ret = 0; - else ret = int(m_sample_sum / m_num_samples); - // in case we don't get any more samples, at least - // let the average roll over, but only be worth a - // single sample - m_num_samples = 1; - m_sample_sum = ret; - return ret; - } - -private: - - int m_num_samples = 0; - std::int64_t m_sample_sum = 0; -}; - } #endif diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 8cb8ac5b2..9b9a3a550 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -366,7 +366,7 @@ namespace libtorrent { // the file_storage object is owned by the torrent. std::shared_ptr m_torrent; - storage_index_t m_storage_index; + storage_index_t m_storage_index{0}; // the number of block_cache_reference objects referencing this storage std::atomic m_references{1}; @@ -425,8 +425,6 @@ namespace libtorrent { private: - void delete_one_file(std::string const& p, error_code& ec); - void need_partfile(); std::unique_ptr m_mapped_files; diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 2f353bf24..ac8b01c52 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -85,9 +85,6 @@ namespace libtorrent { #endif namespace aux { struct session_logger; struct session_settings; } - // returns -1 if gzip header is invalid or the header size in bytes - TORRENT_EXTRA_EXPORT int gzip_header(const char* buf, int size); - struct TORRENT_EXTRA_EXPORT tracker_request { tracker_request() @@ -103,9 +100,6 @@ namespace libtorrent { , num_want(0) , private_torrent(false) , triggered_manually(false) -#ifdef TORRENT_USE_OPENSSL - , ssl_ctx(0) -#endif {} enum event_t @@ -167,7 +161,7 @@ namespace libtorrent { bool triggered_manually; #ifdef TORRENT_USE_OPENSSL - boost::asio::ssl::context* ssl_ctx; + boost::asio::ssl::context* ssl_ctx = nullptr; #endif #if TORRENT_USE_I2P i2p_connection* i2pconn = nullptr; diff --git a/include/libtorrent/udp_tracker_connection.hpp b/include/libtorrent/udp_tracker_connection.hpp index 50af5de96..6ba8c0326 100644 --- a/include/libtorrent/udp_tracker_connection.hpp +++ b/include/libtorrent/udp_tracker_connection.hpp @@ -84,7 +84,6 @@ namespace libtorrent { void name_lookup(error_code const& error , std::vector
const& addresses, int port); - void timeout(error_code const& error); void start_announce(); bool on_receive(udp::endpoint const& ep, span buf);