From f382936d564769be70944bf01e9fafd2a893edfd Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Sun, 11 Dec 2016 21:37:07 -0500 Subject: [PATCH] headers, end of file, code cleanup --- Jamfile | 3 -- include/libtorrent/assert.hpp | 1 - include/libtorrent/bdecode.hpp | 1 + include/libtorrent/enum_net.hpp | 4 +-- include/libtorrent/peer.hpp | 1 - include/libtorrent/peer_connection.hpp | 2 +- include/libtorrent/tracker_manager.hpp | 2 -- include/libtorrent/udp_tracker_connection.hpp | 6 ---- include/libtorrent/web_peer_connection.hpp | 5 ---- src/assert.cpp | 1 - src/bdecode.cpp | 2 -- src/enum_net.cpp | 2 -- src/file.cpp | 2 +- src/file_progress.cpp | 2 +- src/file_storage.cpp | 2 -- src/http_tracker_connection.cpp | 1 - src/kademlia/rpc_manager.cpp | 1 - src/kademlia/traversal_algorithm.cpp | 3 -- src/natpmp.cpp | 1 - src/packet_buffer.cpp | 1 - src/part_file.cpp | 1 - src/peer_connection.cpp | 2 +- src/stat_cache.cpp | 1 - src/torrent.cpp | 5 +--- src/tracker_manager.cpp | 30 ++++--------------- src/udp_tracker_connection.cpp | 13 ++------ src/upnp.cpp | 2 -- src/ut_metadata.cpp | 4 +-- src/web_peer_connection.cpp | 9 ++---- src/xml_parse.cpp | 1 - test/Jamfile | 1 - 31 files changed, 20 insertions(+), 92 deletions(-) diff --git a/Jamfile b/Jamfile index 496c875a0..5415a27dc 100644 --- a/Jamfile +++ b/Jamfile @@ -238,7 +238,6 @@ rule warnings ( properties * ) result += -Wno-c++98-compat-pedantic ; result += -Wno-padded ; result += -Wno-global-constructors ; - result += -Wno-c++98-compat ; # this warns on any global static object, which are used for error_category # objects result += -Wno-exit-time-destructors ; @@ -261,7 +260,6 @@ rule warnings ( properties * ) result += -Wno-long-long ; # enable these warnings again, once the other ones are dealt with - result += -Wno-sign-compare ; result += -Wno-unused-variable ; } @@ -778,4 +776,3 @@ package.install install : torrent : $(headers) ; - diff --git a/include/libtorrent/assert.hpp b/include/libtorrent/assert.hpp index 7a8b9038f..00503dfba 100644 --- a/include/libtorrent/assert.hpp +++ b/include/libtorrent/assert.hpp @@ -123,4 +123,3 @@ extern char const* libtorrent_assert_log; #endif // TORRENT_USE_ASSERTS #endif - diff --git a/include/libtorrent/bdecode.hpp b/include/libtorrent/bdecode.hpp index dc13ddbbc..100739fd3 100644 --- a/include/libtorrent/bdecode.hpp +++ b/include/libtorrent/bdecode.hpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "libtorrent/aux_/disable_warnings_push.hpp" #include diff --git a/include/libtorrent/enum_net.hpp b/include/libtorrent/enum_net.hpp index d44f55707..ce694d808 100644 --- a/include/libtorrent/enum_net.hpp +++ b/include/libtorrent/enum_net.hpp @@ -37,8 +37,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" -#include - #if TORRENT_USE_IFCONF || TORRENT_USE_NETLINK || TORRENT_USE_SYSCTL #include // for SO_BINDTODEVICE #endif @@ -51,6 +49,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket.hpp" #include "libtorrent/aux_/bind_to_device.hpp" +#include + namespace libtorrent { struct socket_type; diff --git a/include/libtorrent/peer.hpp b/include/libtorrent/peer.hpp index 23d5f33fb..fa0234a31 100644 --- a/include/libtorrent/peer.hpp +++ b/include/libtorrent/peer.hpp @@ -71,4 +71,3 @@ namespace libtorrent } #endif // TORRENT_PEER_HPP_INCLUDED - diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 29eb01088..ec7d08a0c 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -64,7 +64,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/span.hpp" #include "libtorrent/piece_block.hpp" #include "libtorrent/peer_info.hpp" -#include "libtorrent/disk_interface.hpp" #include #include @@ -79,6 +78,7 @@ namespace libtorrent { class torrent; struct torrent_peer; + struct disk_interface; #ifndef TORRENT_DISABLE_EXTENSIONS struct peer_plugin; diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 4bb8debdc..94711ed21 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -68,10 +68,8 @@ namespace libtorrent struct request_callback; class tracker_manager; struct timeout_handler; - struct tracker_connection; class udp_tracker_connection; class http_tracker_connection; - class udp_socket; struct resolver_interface; struct counters; struct ip_filter; diff --git a/include/libtorrent/udp_tracker_connection.hpp b/include/libtorrent/udp_tracker_connection.hpp index 3bfbd172f..53fe50ded 100644 --- a/include/libtorrent/udp_tracker_connection.hpp +++ b/include/libtorrent/udp_tracker_connection.hpp @@ -36,16 +36,11 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include #include #include "libtorrent/udp_socket.hpp" -#include "libtorrent/entry.hpp" -#include "libtorrent/session_settings.hpp" -#include "libtorrent/peer_id.hpp" -#include "libtorrent/peer.hpp" #include "libtorrent/tracker_manager.hpp" #include "libtorrent/config.hpp" @@ -133,4 +128,3 @@ namespace libtorrent } #endif // TORRENT_UDP_TRACKER_CONNECTION_HPP_INCLUDED - diff --git a/include/libtorrent/web_peer_connection.hpp b/include/libtorrent/web_peer_connection.hpp index c8596775a..2e90cdd74 100644 --- a/include/libtorrent/web_peer_connection.hpp +++ b/include/libtorrent/web_peer_connection.hpp @@ -42,16 +42,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/web_connection_base.hpp" -#include "libtorrent/disk_buffer_holder.hpp" -#include "libtorrent/torrent.hpp" #include "libtorrent/piece_block_progress.hpp" -#include "libtorrent/http_parser.hpp" #include "libtorrent/operations.hpp" // for operation_t enum namespace libtorrent { - class torrent; - class TORRENT_EXTRA_EXPORT web_peer_connection : public web_connection_base { diff --git a/src/assert.cpp b/src/assert.cpp index 0214f6a8e..6b16252bf 100644 --- a/src/assert.cpp +++ b/src/assert.cpp @@ -374,4 +374,3 @@ TORRENT_EXPORT void assert_fail(char const*, int, char const* , char const*, char const*, int) {} #endif - diff --git a/src/bdecode.cpp b/src/bdecode.cpp index 6b6bb2ecf..ca53148fd 100644 --- a/src/bdecode.cpp +++ b/src/bdecode.cpp @@ -32,7 +32,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bdecode.hpp" #include "libtorrent/alloca.hpp" -#include #include #include // for memset #include // for snprintf @@ -1021,4 +1020,3 @@ done: return ret; } } - diff --git a/src/enum_net.cpp b/src/enum_net.cpp index 4e881f153..8fd3c2331 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -33,12 +33,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/enum_net.hpp" #include "libtorrent/broadcast_socket.hpp" -#include "libtorrent/error_code.hpp" #include "libtorrent/assert.hpp" #include "libtorrent/socket_type.hpp" #include -#include #include // for wcstombscstombs #include "libtorrent/aux_/disable_warnings_push.hpp" diff --git a/src/file.cpp b/src/file.cpp index 305c8f32d..5cc3dc5da 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -2156,7 +2156,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { // update the modification time of the file for no good // reason. if ((m_open_mode & sparse) == 0 - && st.st_blocks < (s + st.st_blksize - 1) / st.st_blksize) + && std::int64_t(st.st_blocks) < (s + st.st_blksize - 1) / st.st_blksize) { // How do we know that the file is already allocated? // if we always try to allocate the space, we'll update diff --git a/src/file_progress.cpp b/src/file_progress.cpp index f16379c8a..9a503e4e1 100644 --- a/src/file_progress.cpp +++ b/src/file_progress.cpp @@ -158,7 +158,7 @@ namespace libtorrent { namespace aux TORRENT_ASSERT(file_index != fs.num_files()); TORRENT_ASSERT(file_offset <= fs.file_size(file_index)); std::int64_t const add = (std::min)(fs.file_size(file_index) - - file_offset, std::int64_t(size)); + - file_offset, size); m_file_progress[file_index] += add; TORRENT_ASSERT(m_file_progress[file_index] diff --git a/src/file_storage.cpp b/src/file_storage.cpp index 321a20204..b3151240f 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -36,9 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/utf8.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" - #include - #include "libtorrent/aux_/disable_warnings_pop.hpp" #include diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index a8c921de5..1da10497a 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -56,7 +56,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/resolver_interface.hpp" #include "libtorrent/ip_filter.hpp" -using namespace libtorrent; using namespace std::placeholders; namespace libtorrent diff --git a/src/kademlia/rpc_manager.cpp b/src/kademlia/rpc_manager.cpp index 2f7c749ae..ba49b4956 100644 --- a/src/kademlia/rpc_manager.cpp +++ b/src/kademlia/rpc_manager.cpp @@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include // for generate_random_id #include #include #include diff --git a/src/kademlia/traversal_algorithm.cpp b/src/kademlia/traversal_algorithm.cpp index 6da801eb9..8dfd2f4d0 100644 --- a/src/kademlia/traversal_algorithm.cpp +++ b/src/kademlia/traversal_algorithm.cpp @@ -30,10 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "libtorrent/time.hpp" // for total_seconds - #include -#include #include #include #include // for dht_logger diff --git a/src/natpmp.cpp b/src/natpmp.cpp index 04d57778a..c8fcd4c35 100644 --- a/src/natpmp.cpp +++ b/src/natpmp.cpp @@ -684,4 +684,3 @@ void natpmp::close_impl() } } // namespace libtorrent - diff --git a/src/packet_buffer.cpp b/src/packet_buffer.cpp index f66fc74a6..80e0d5aba 100644 --- a/src/packet_buffer.cpp +++ b/src/packet_buffer.cpp @@ -216,4 +216,3 @@ namespace libtorrent { } } - diff --git a/src/part_file.cpp b/src/part_file.cpp index 2300186c5..172ef567d 100644 --- a/src/part_file.cpp +++ b/src/part_file.cpp @@ -414,6 +414,5 @@ namespace libtorrent file::iovec_t b = {header.get(), std::size_t(m_header_size)}; m_file.writev(0, b, ec); - if (ec) return; } } diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 2ee16ad05..b54d893a9 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -57,7 +57,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bandwidth_manager.hpp" #include "libtorrent/request_blocks.hpp" // for request_a_block #include "libtorrent/performance_counters.hpp" // for counters -#include "libtorrent/alert_manager.hpp" // for alert_manageralert_manager +#include "libtorrent/alert_manager.hpp" // for alert_manager #include "libtorrent/ip_filter.hpp" #include "libtorrent/ip_voter.hpp" #include "libtorrent/kademlia/node_id.hpp" diff --git a/src/stat_cache.cpp b/src/stat_cache.cpp index 91b263b1b..50be8f6a5 100644 --- a/src/stat_cache.cpp +++ b/src/stat_cache.cpp @@ -119,4 +119,3 @@ namespace libtorrent return int(m_errors.size()) - 1; } } - diff --git a/src/torrent.cpp b/src/torrent.cpp index c5f84e562..8f8c2d2df 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -7799,7 +7799,7 @@ namespace libtorrent #if TORRENT_USE_INVARIANT_CHECKS void torrent::check_invariant() const { - TORRENT_ASSERT(current_stats_state() == m_current_gauge_state + counters::num_checking_torrents + TORRENT_ASSERT(current_stats_state() == int(m_current_gauge_state + counters::num_checking_torrents) || m_current_gauge_state == no_gauge_state); for (std::vector::const_iterator i = m_time_critical_pieces.begin() @@ -9429,7 +9429,6 @@ namespace libtorrent int peer_index(libtorrent::tcp::endpoint addr , std::vector const& peers) { - using namespace libtorrent; std::vector::const_iterator i = std::find_if(peers.begin() , peers.end(), std::bind(&peer_info::ip, _1) == addr); if (i == peers.end()) return -1; @@ -9441,8 +9440,6 @@ namespace libtorrent , std::vector const& peers , std::vector const& time_critical) { - using namespace libtorrent; - time_point const now = clock_type::now(); float deadline = 0.f; diff --git a/src/tracker_manager.cpp b/src/tracker_manager.cpp index 772e519e1..d22bbc341 100644 --- a/src/tracker_manager.cpp +++ b/src/tracker_manager.cpp @@ -30,35 +30,20 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include -#include #include -#include #include "libtorrent/tracker_manager.hpp" #include "libtorrent/http_tracker_connection.hpp" #include "libtorrent/udp_tracker_connection.hpp" -#include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/aux_/io.hpp" -#include "libtorrent/span.hpp" - +#include "libtorrent/aux_/session_interface.hpp" +#include "libtorrent/performance_counters.hpp" +#include "libtorrent/socket_io.hpp" using namespace std::placeholders; -namespace -{ - enum - { - minimum_tracker_response_length = 3, - http_buffer_size = 2048 - }; - -} - namespace libtorrent { - using namespace libtorrent::aux; - timeout_handler::timeout_handler(io_service& ios) : m_start_time(clock_type::now()) , m_read_time(m_start_time) @@ -173,8 +158,8 @@ namespace libtorrent , char const* msg, int interval, int min_interval) { // we need to post the error to avoid deadlock - get_io_service().post(std::bind(&tracker_connection::fail_impl - , shared_from_this(), ec, code, std::string(msg), interval, min_interval)); + get_io_service().post(std::bind(&tracker_connection::fail_impl + , shared_from_this(), ec, code, std::string(msg), interval, min_interval)); } void tracker_connection::fail_impl(error_code const& ec, int code @@ -240,7 +225,6 @@ namespace libtorrent if (i != m_http_conns.end()) { m_http_conns.erase(i); - return; } } @@ -441,14 +425,10 @@ namespace libtorrent } for (auto const& c : close_http_connections) - { c->close(); - } for (auto const& c : close_udp_connections) - { c->close(); - } } bool tracker_manager::empty() const diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index 7670aab0c..5a5dc9143 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -30,18 +30,10 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include -#include #include - -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - -#include "libtorrent/tracker_manager.hpp" #include "libtorrent/parse_url.hpp" #include "libtorrent/udp_tracker_connection.hpp" #include "libtorrent/io.hpp" @@ -54,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/time.hpp" #include "libtorrent/aux_/io.hpp" #include "libtorrent/span.hpp" +#include "libtorrent/peer.hpp" #ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/socket_io.hpp" @@ -661,11 +654,9 @@ namespace libtorrent bool udp_tracker_connection::on_scrape_response(span buf) { - using namespace libtorrent::aux; - restart_read_timeout(); auto const action = static_cast(aux::read_int32(buf)); - std::uint32_t const transaction = read_uint32(buf); + std::uint32_t const transaction = aux::read_uint32(buf); if (transaction != m_transaction_id) { diff --git a/src/upnp.cpp b/src/upnp.cpp index 3c03bbaea..6f2f07ad1 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -341,8 +341,6 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer TORRENT_ASSERT(is_single_thread()); std::shared_ptr me(self()); - using namespace libtorrent::detail; - // parse out the url for the device /* diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index e41346f06..f70ab3a8f 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -272,9 +272,9 @@ namespace libtorrent { namespace int len = bencode(p, e); int total_size = 2 + len + metadata_piece_size; namespace io = detail; - io::write_uint32(std::uint32_t(total_size), header); + io::write_uint32(total_size, header); io::write_uint8(bt_peer_connection::msg_extended, header); - io::write_uint8(std::uint8_t(m_message_index), header); + io::write_uint8(m_message_index, header); m_pc.send_buffer(msg, len + 6); // TODO: we really need to increment the refcounter on the torrent diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index a22ec167b..6ff6caf72 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -33,33 +33,30 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include -#include #include #include // for snprintf #include // for PRId64 et.al. #include "libtorrent/web_peer_connection.hpp" #include "libtorrent/session.hpp" -#include "libtorrent/identify_client.hpp" #include "libtorrent/entry.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/invariant_check.hpp" #include "libtorrent/io.hpp" -#include "libtorrent/version.hpp" #include "libtorrent/parse_url.hpp" #include "libtorrent/peer_info.hpp" #include "libtorrent/aux_/session_interface.hpp" -#include "libtorrent/alert_manager.hpp" // for alert_manageralert_manager +#include "libtorrent/alert_manager.hpp" // for alert_manager #include "libtorrent/aux_/escape_string.hpp" // for escape_path #include "libtorrent/hex.hpp" // for is_hex +#include "libtorrent/torrent.hpp" +#include "libtorrent/http_parser.hpp" namespace libtorrent { constexpr int request_size_overhead = 5000; -struct disk_interface; - web_peer_connection::web_peer_connection(peer_connection_args const& pack , web_seed_t& web) : web_connection_base(pack, web) diff --git a/src/xml_parse.cpp b/src/xml_parse.cpp index feee43410..a2d915122 100644 --- a/src/xml_parse.cpp +++ b/src/xml_parse.cpp @@ -196,4 +196,3 @@ namespace libtorrent } } - diff --git a/test/Jamfile b/test/Jamfile index b4e5d1506..c2036906f 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -256,4 +256,3 @@ alias arm-tests : ; explicit arm-tests ; -