diff --git a/Jamfile b/Jamfile index 3e7a503f9..6ef1bee40 100644 --- a/Jamfile +++ b/Jamfile @@ -392,9 +392,6 @@ feature iconv : auto on off : composite propagated ; feature.compose on : TORRENT_USE_ICONV=1 ; feature.compose off : TORRENT_USE_ICONV=0 ; -feature use-valgrind : off on : composite propagated link-incompatible ; -feature.compose on : TORRENT_USE_VALGRIND=1 ; - feature memory-optimization : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_OPTIMIZE_MEMORY_USAGE ; diff --git a/bindings/python/src/big_number.cpp b/bindings/python/src/big_number.cpp index 10e896de8..df250c1b8 100644 --- a/bindings/python/src/big_number.cpp +++ b/bindings/python/src/big_number.cpp @@ -3,6 +3,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include + #include "boost_python.hpp" #include "bytes.hpp" @@ -36,7 +38,6 @@ void bind_sha1_hash() .def("to_bytes", sha1_hash_bytes) ; - scope().attr("big_number") = scope().attr("sha1_hash"); - scope().attr("peer_id") = scope().attr("sha1_hash"); + scope().attr("peer_id") = scope().attr("sha1_hash"); } diff --git a/bindings/python/src/boost_python.hpp b/bindings/python/src/boost_python.hpp index 12c1f3ea2..dd60b0132 100644 --- a/bindings/python/src/boost_python.hpp +++ b/bindings/python/src/boost_python.hpp @@ -6,8 +6,15 @@ #define BOOST_PYTHON_HPP #include +#include #include #include +// something in here creates a define for this, presumably to make older +// versions of msvc appear to support snprintf +#ifdef snprintf +#undef snprintf +#endif + #endif diff --git a/examples/client_test.cpp b/examples/client_test.cpp index a59b0ae0d..4b1d20a71 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -72,6 +72,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/time.hpp" #include "libtorrent/create_torrent.hpp" #include "libtorrent/read_resume_data.hpp" +#include "libtorrent/hex.hpp" // for to_hex, from_hex #include "torrent_view.hpp" #include "session_view.hpp" diff --git a/examples/dump_torrent.cpp b/examples/dump_torrent.cpp index 2f6ef05d2..7614be22a 100644 --- a/examples/dump_torrent.cpp +++ b/examples/dump_torrent.cpp @@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/announce_entry.hpp" #include "libtorrent/bdecode.hpp" #include "libtorrent/magnet_uri.hpp" +#include "libtorrent/hex.hpp" // for to_hex, from_hex int load_file(std::string const& filename, std::vector& v , libtorrent::error_code& ec, int limit = 8000000) diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index a7aba731d..10c097ce1 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/version.hpp" #include "libtorrent/socket.hpp" // for tcp::endpoint #include "libtorrent/bitfield.hpp" +#include "libtorrent/error_code.hpp" namespace libtorrent { diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index dd1cee8d0..2827d6492 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -42,23 +42,19 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_peer_allocator.hpp" #include "libtorrent/performance_counters.hpp" // for counters -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include #include #include #include #include #include -#include // for va_start, va_end +#include // for va_start, va_end #include #ifdef TORRENT_USE_OPENSSL #include "libtorrent/ssl_stream.hpp" #endif -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include "libtorrent/session.hpp" // for user_load_function_t #include "libtorrent/ip_voter.hpp" #include "libtorrent/entry.hpp" diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index 1510da75f..76c27d49f 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -71,20 +71,12 @@ POSSIBILITY OF SUCH DAMAGE. // performs a little bit better and can have a higher recursion limit on the // structures it's parsing. -#include #include #include #include // for distance -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - -#include "libtorrent/entry.hpp" #include "libtorrent/config.hpp" - +#include "libtorrent/entry.hpp" #include "libtorrent/assert.hpp" #include "libtorrent/io.hpp" // for write_string @@ -103,7 +95,7 @@ namespace libtorrent // the stack allocated buffer for keeping the // decimal representation of the number can // not hold number bigger than this: - BOOST_STATIC_ASSERT(sizeof(entry::integer_type) <= 8); + static_assert(sizeof(entry::integer_type) <= 8, "64 bit integers required"); char buf[21]; int ret = 0; for (char const* str = integer_to_str(buf, 21, val); diff --git a/include/libtorrent/bloom_filter.hpp b/include/libtorrent/bloom_filter.hpp index 582a34280..f6b37882f 100644 --- a/include/libtorrent/bloom_filter.hpp +++ b/include/libtorrent/bloom_filter.hpp @@ -36,10 +36,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_id.hpp" // for sha1_hash #include "libtorrent/config.hpp" // for sha1_hash +#include // for log() + #include "libtorrent/aux_/disable_warnings_push.hpp" #include -#include // for log() #include "libtorrent/aux_/disable_warnings_pop.hpp" @@ -70,7 +71,7 @@ namespace libtorrent { const int c = (std::min)(count_zero_bits(bits, N), (N * 8) - 1); const int m = N * 8; - return ::log(c / float(m)) / (2.f * ::log(1.f - 1.f/m)); + return std::log(c / float(m)) / (2.f * std::log(1.f - 1.f/m)); } bloom_filter() { clear(); } diff --git a/include/libtorrent/buffer.hpp b/include/libtorrent/buffer.hpp index 1ec882d10..3ddba7752 100644 --- a/include/libtorrent/buffer.hpp +++ b/include/libtorrent/buffer.hpp @@ -37,9 +37,12 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/invariant_check.hpp" #include "libtorrent/assert.hpp" #include // malloc/free/realloc -#include #include // for std::swap +#include "libtorrent/aux_/disable_warnings_push.hpp" +#include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + namespace libtorrent { class buffer diff --git a/include/libtorrent/peer_class_type_filter.hpp b/include/libtorrent/peer_class_type_filter.hpp index 3f45097ec..989e7c05b 100644 --- a/include/libtorrent/peer_class_type_filter.hpp +++ b/include/libtorrent/peer_class_type_filter.hpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_PEER_CLASS_TYPE_FILTER_HPP_INCLUDED #define TORRENT_PEER_CLASS_TYPE_FILTER_HPP_INCLUDED -#include // for memset +#include // for memset #include namespace libtorrent @@ -46,8 +46,8 @@ namespace libtorrent { peer_class_type_filter() { - memset(m_peer_class_type_mask, 0xff, sizeof(m_peer_class_type_mask)); - memset(m_peer_class_type, 0, sizeof(m_peer_class_type)); + std::memset(m_peer_class_type_mask, 0xff, sizeof(m_peer_class_type_mask)); + std::memset(m_peer_class_type, 0, sizeof(m_peer_class_type)); } enum socket_type_t diff --git a/include/libtorrent/peer_id.hpp b/include/libtorrent/peer_id.hpp index 0614b9fca..4b561d2fd 100644 --- a/include/libtorrent/peer_id.hpp +++ b/include/libtorrent/peer_id.hpp @@ -33,15 +33,11 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_PEER_ID_HPP_INCLUDED #define TORRENT_PEER_ID_HPP_INCLUDED -#include "libtorrent/config.hpp" #include "libtorrent/sha1_hash.hpp" namespace libtorrent { - typedef sha1_hash peer_id; -#ifndef TORRENT_NO_DEPRECATE - typedef sha1_hash big_number; -#endif + using peer_id = sha1_hash; } #endif // TORRENT_PEER_ID_HPP_INCLUDED diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 5c3482e5f..883678c5b 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -37,17 +37,18 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include #include #include #include -#include +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #ifdef TORRENT_DEBUG_REFCOUNTS #include #endif @@ -56,8 +57,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include "libtorrent/peer_id.hpp" #include "libtorrent/assert.hpp" #include "libtorrent/time.hpp" @@ -707,9 +706,9 @@ namespace libtorrent #ifndef TORRENT_DEBUG_REFCOUNTS #ifdef TORRENT_OPTIMIZE_MEMORY_USAGE - BOOST_STATIC_ASSERT(sizeof(piece_pos) == sizeof(char) * 4); + static_assert(sizeof(piece_pos) == sizeof(char) * 4, "unexpected struct size"); #else - BOOST_STATIC_ASSERT(sizeof(piece_pos) == sizeof(char) * 8); + static_assert(sizeof(piece_pos) == sizeof(char) * 8, "unexpected struct size"); #endif #endif diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index 457b228db..4496bfe56 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -42,11 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/aux_/byteswap.hpp" -#include "libtorrent/hex.hpp" // to_hex, from_hex -#if TORRENT_USE_IOSTREAM -#include -#include -#endif +#include #ifdef max #undef max @@ -151,8 +147,8 @@ namespace libtorrent { for (int i = 0; i < number_size; ++i) { - boost::uint32_t lhs = aux::network_to_host(m_number[i]); - boost::uint32_t rhs = aux::network_to_host(n.m_number[i]); + boost::uint32_t const lhs = aux::network_to_host(m_number[i]); + boost::uint32_t const rhs = aux::network_to_host(n.m_number[i]); if (lhs < rhs) return true; if (lhs > rhs) return false; } @@ -222,8 +218,8 @@ namespace libtorrent return reinterpret_cast(m_number)[i]; } - typedef const boost::uint8_t* const_iterator; - typedef boost::uint8_t* iterator; + using const_iterator = boost::uint8_t const*; + using iterator = boost::uint8_t*; // start and end iterators for the hash. The value type // of these iterators is ``boost::uint8_t``. @@ -259,26 +255,11 @@ namespace libtorrent return ret; } -#if TORRENT_USE_IOSTREAM - // print a sha1_hash object to an ostream as 40 hexadecimal digits - inline std::ostream& operator<<(std::ostream& os, sha1_hash const& peer) - { - char out[41]; - to_hex(reinterpret_cast(&peer[0]), sha1_hash::size, out); - return os << out; - } + TORRENT_EXPORT std::ostream& operator<<(std::ostream& os, sha1_hash const& peer); // read 40 hexadecimal digits from an istream into a sha1_hash - inline std::istream& operator>>(std::istream& is, sha1_hash& peer) - { - char hex[40]; - is.read(hex, 40); - if (!from_hex(hex, 40, reinterpret_cast(&peer[0]))) - is.setstate(std::ios_base::failbit); - return is; - } -#endif // TORRENT_USE_IOSTREAM + TORRENT_EXPORT std::istream& operator>>(std::istream& is, sha1_hash& peer); } namespace std { @@ -296,5 +277,5 @@ namespace std { }; } -#endif // TORRENT_PEER_ID_HPP_INCLUDED +#endif // TORRENT_SHA1_HASH_HPP_INCLUDED diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp index a1e209456..8357aaab4 100644 --- a/include/libtorrent/stat.hpp +++ b/include/libtorrent/stat.hpp @@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include #include #include #include diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index b898129c3..660d3c1d5 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -388,8 +388,6 @@ namespace libtorrent // these functions will be removed in a future version TORRENT_DEPRECATED torrent_info(entry const& torrent_file); - TORRENT_DEPRECATED - void print(std::ostream& os) const; // ------- end deprecation ------- #endif diff --git a/include/libtorrent/torrent_status.hpp b/include/libtorrent/torrent_status.hpp index a40938f0a..53afb301c 100644 --- a/include/libtorrent/torrent_status.hpp +++ b/include/libtorrent/torrent_status.hpp @@ -39,15 +39,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/sha1_hash.hpp" #include "libtorrent/time.hpp" // for time_duration #include "libtorrent/storage_defs.hpp" // for storage_mode_t +#include "libtorrent/error_code.hpp" // for storage_mode_t #include "libtorrent/aux_/disable_warnings_push.hpp" - #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" #include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - namespace libtorrent { // holds a snapshot of the status of a torrent, as queried by diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 0bd23edde..05ba9b13a 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -35,13 +35,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include #include #include #include +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include @@ -66,6 +66,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/array_view.hpp" #include "libtorrent/time.hpp" #include "libtorrent/debug.hpp" +#include "libtorrent/error_code.hpp" namespace libtorrent { diff --git a/simulation/test_dht_storage.cpp b/simulation/test_dht_storage.cpp index e0b947992..0d82020c3 100644 --- a/simulation/test_dht_storage.cpp +++ b/simulation/test_dht_storage.cpp @@ -34,11 +34,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "settings.hpp" #include "libtorrent/config.hpp" #include "libtorrent/kademlia/node.hpp" // for verify_message - #include "libtorrent/kademlia/dht_storage.hpp" #include "libtorrent/io_service.hpp" #include "libtorrent/address.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/aux_/time.hpp" #include "simulator/simulator.hpp" diff --git a/simulation/test_http_connection.cpp b/simulation/test_http_connection.cpp index 27fb954a9..909bde5ca 100644 --- a/simulation/test_http_connection.cpp +++ b/simulation/test_http_connection.cpp @@ -42,8 +42,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/http_connection.hpp" #include "libtorrent/resolver.hpp" #include "libtorrent/io.hpp" + #include "make_proxy_settings.hpp" +#include #include using namespace libtorrent; diff --git a/src/alert.cpp b/src/alert.cpp index 408c3f3be..6aa1e4e2f 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/performance_counters.hpp" #include "libtorrent/stack_allocator.hpp" #include "libtorrent/piece_picker.hpp" // for piece_block +#include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/aux_/escape_string.hpp" // for convert_from_native #include "libtorrent/aux_/max_path.hpp" // for TORRENT_MAX_PATH diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index e94fcea91..1d53a3651 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -45,6 +45,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" +#ifndef TORRENT_DISABLE_LOGGING +#include "libtorrent/hex.hpp" // to_hex, from_hex +#endif + #include "libtorrent/bt_peer_connection.hpp" #include "libtorrent/session.hpp" #include "libtorrent/identify_client.hpp" diff --git a/src/file.cpp b/src/file.cpp index f9ef939ee..b9d23b480 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -71,15 +71,14 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef TORRENT_DEBUG_FILE_LEAKS #include +#include #endif // for convert_to_wstring and convert_to_native #include "libtorrent/aux_/escape_string.hpp" -#include #include "libtorrent/assert.hpp" #include -#include #ifdef TORRENT_DISK_STATS #include "libtorrent/io.hpp" @@ -147,7 +146,7 @@ POSSIBILITY OF SUCH DAMAGE. // related functions support 64-bit offsets. // this test makes sure lseek() returns a type // at least 64 bits wide -BOOST_STATIC_ASSERT(sizeof(lseek(0, 0, 0)) >= 8); +static_assert(sizeof(lseek(0, 0, 0)) >= 8, "64 bit file operations are required"); #endif // posix part @@ -323,9 +322,9 @@ done: #endif #ifdef TORRENT_DEBUG -BOOST_STATIC_ASSERT((libtorrent::file::rw_mask & libtorrent::file::sparse) == 0); -BOOST_STATIC_ASSERT((libtorrent::file::rw_mask & libtorrent::file::attribute_mask) == 0); -BOOST_STATIC_ASSERT((libtorrent::file::sparse & libtorrent::file::attribute_mask) == 0); +static_assert((libtorrent::file::rw_mask & libtorrent::file::sparse) == 0, "internal flags error"); +static_assert((libtorrent::file::rw_mask & libtorrent::file::attribute_mask) == 0, "internal flags error"); +static_assert((libtorrent::file::sparse & libtorrent::file::attribute_mask) == 0, "internal flags error"); #endif #if defined TORRENT_WINDOWS && defined UNICODE && !TORRENT_USE_WSTRING @@ -2352,7 +2351,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { void print_open_files(char const* event, char const* name) { - FILE* out = fopen("open_files.log", "a+"); + FILE* out = std::fopen("open_files.log", "a+"); std::lock_guard l(file_handle_mutex); std::fprintf(out, "\n\nEVENT: %s TORRENT: %s\n\n", event, name); for (std::set::iterator i = global_file_handles.begin() @@ -2367,7 +2366,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { h->print_info(out); std::fprintf(out, "\n%s\n\n", h.stack); } - fclose(out); + std::fclose(out); } #endif } diff --git a/src/kademlia/dht_tracker.cpp b/src/kademlia/dht_tracker.cpp index e8ec8c2e5..583a4b45e 100644 --- a/src/kademlia/dht_tracker.cpp +++ b/src/kademlia/dht_tracker.cpp @@ -51,6 +51,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/aux_/time.hpp" +#ifndef TORRENT_DISABLE_LOGGING +#include "libtorrent/hex.hpp" // to_hex, from_hex +#endif + #include "libtorrent/aux_/disable_warnings_push.hpp" #include diff --git a/src/kademlia/find_data.cpp b/src/kademlia/find_data.cpp index 17092ae42..10a3c403b 100644 --- a/src/kademlia/find_data.cpp +++ b/src/kademlia/find_data.cpp @@ -36,6 +36,11 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include + +#ifndef TORRENT_DISABLE_LOGGING +#include // to_hex, from_hex +#endif + #include namespace libtorrent { namespace dht diff --git a/src/kademlia/get_peers.cpp b/src/kademlia/get_peers.cpp index c4717dd98..dd2b3c78b 100644 --- a/src/kademlia/get_peers.cpp +++ b/src/kademlia/get_peers.cpp @@ -36,6 +36,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#ifndef TORRENT_DISABLE_LOGGING +#include // to_hex, from_hex +#endif + namespace libtorrent { namespace dht { diff --git a/src/kademlia/item.cpp b/src/kademlia/item.cpp index 1bfa0e81d..0dde37de4 100644 --- a/src/kademlia/item.cpp +++ b/src/kademlia/item.cpp @@ -42,10 +42,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bdecode.hpp" #endif -#ifdef TORRENT_USE_VALGRIND -#include -#endif - namespace libtorrent { namespace dht { @@ -107,12 +103,6 @@ bool verify_mutable_item( , char const* pk , char const* sig) { -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(v.first, v.second); - VALGRIND_CHECK_MEM_IS_DEFINED(pk, item_pk_len); - VALGRIND_CHECK_MEM_IS_DEFINED(sig, item_sig_len); -#endif - char str[canonical_length]; int len = canonical_string(v, seq, salt, str); @@ -136,12 +126,6 @@ void sign_mutable_item( , char const* sk , char* sig) { -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(v.first, v.second); - VALGRIND_CHECK_MEM_IS_DEFINED(sk, item_sk_len); - VALGRIND_CHECK_MEM_IS_DEFINED(pk, item_pk_len); -#endif - char str[canonical_length]; int len = canonical_string(v, seq, salt, str); diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index f90ad5b6f..caa8f63c5 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -32,20 +32,21 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include #include // for PRId64 et.al. + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include -#ifdef TORRENT_USE_VALGRIND -#include -#endif - #include "libtorrent/aux_/disable_warnings_pop.hpp" +#ifndef TORRENT_DISABLE_LOGGING +#include // to_hex, from_hex +#endif + #include "libtorrent/io.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/hasher.hpp" @@ -1061,12 +1062,7 @@ void node::incoming_request(msg const& m, entry& e) else { // mutable put, we must verify the signature - -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(msg_keys[4].string_ptr(), item_sig_len); - VALGRIND_CHECK_MEM_IS_DEFINED(pk, item_pk_len); -#endif - boost::int64_t seq = msg_keys[2].int_value(); + boost::int64_t const seq = msg_keys[2].int_value(); if (seq < 0) { diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index 66a7d5801..34cc18a51 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" +#include // to_hex, from_hex #include "libtorrent/kademlia/routing_table.hpp" #include "libtorrent/broadcast_socket.hpp" // for cidr_distance #include "libtorrent/session_status.hpp" diff --git a/src/kademlia/traversal_algorithm.cpp b/src/kademlia/traversal_algorithm.cpp index af124087e..a2bb23acf 100644 --- a/src/kademlia/traversal_algorithm.cpp +++ b/src/kademlia/traversal_algorithm.cpp @@ -42,6 +42,10 @@ POSSIBILITY OF SUCH DAMAGE. #include // for dht_lookup #include +#ifndef TORRENT_DISABLE_LOGGING +#include // to_hex, from_hex +#endif + #include namespace libtorrent { namespace dht diff --git a/src/lsd.cpp b/src/lsd.cpp index b348c263e..82246a94e 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -30,6 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include +#include + #include "libtorrent/lsd.hpp" #include "libtorrent/io.hpp" #include "libtorrent/http_tracker_connection.hpp" @@ -38,15 +41,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/http_parser.hpp" #include "libtorrent/socket_io.hpp" // for print_address #include "libtorrent/debug.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/aux_/disable_warnings_push.hpp" #include #include #include -#include #include -#include #include "libtorrent/aux_/disable_warnings_pop.hpp" diff --git a/src/magnet_uri.cpp b/src/magnet_uri.cpp index 7658d893b..5cca31ed1 100644 --- a/src/magnet_uri.cpp +++ b/src/magnet_uri.cpp @@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_status.hpp" #include "libtorrent/torrent_info.hpp" #include "libtorrent/announce_entry.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex #include diff --git a/src/part_file.cpp b/src/part_file.cpp index f85d052cc..9e76024df 100644 --- a/src/part_file.cpp +++ b/src/part_file.cpp @@ -66,10 +66,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include -#ifdef TORRENT_USE_VALGRIND -#include -#endif - namespace { // round up to even kilobyte @@ -414,9 +410,6 @@ namespace libtorrent } memset(ptr, 0, m_header_size - (ptr - reinterpret_cast(header.get()))); -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(header.get(), m_header_size); -#endif file::iovec_t b = {header.get(), size_t(m_header_size) }; m_file.writev(0, &b, 1, ec); if (ec) return; diff --git a/src/peer_class.cpp b/src/peer_class.cpp index 34af2c84e..77069a1a2 100644 --- a/src/peer_class.cpp +++ b/src/peer_class.cpp @@ -33,10 +33,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_class.hpp" #include "libtorrent/peer_connection.hpp" -#ifdef TORRENT_USE_VALGRIND -#include -#endif - namespace libtorrent { void peer_class::set_upload_limit(int limit) @@ -99,9 +95,6 @@ namespace libtorrent void peer_class_pool::decref(peer_class_t c) { -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(c); -#endif TORRENT_ASSERT(c < m_peer_classes.size()); TORRENT_ASSERT(m_peer_classes[c].get()); @@ -113,9 +106,6 @@ namespace libtorrent void peer_class_pool::incref(peer_class_t c) { -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(c); -#endif TORRENT_ASSERT(c < m_peer_classes.size()); TORRENT_ASSERT(m_peer_classes[c].get()); @@ -124,9 +114,6 @@ namespace libtorrent peer_class* peer_class_pool::at(peer_class_t c) { -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(c); -#endif if (c >= m_peer_classes.size()) return 0; return m_peer_classes[c].get(); } diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 26d577c28..74a390329 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -48,9 +48,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #ifndef TORRENT_DISABLE_LOGGING -#include // for va_start, va_end -#include // for vsnprintf +#include // for va_start, va_end +#include // for vsnprintf #include "libtorrent/socket_io.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex #endif #include "libtorrent/peer_connection.hpp" @@ -517,7 +518,7 @@ namespace libtorrent // TODO: it would be neat to be able to print this straight into the // alert's stack allocator char buf[512]; - vsnprintf(buf, sizeof(buf), fmt, v); + std::vsnprintf(buf, sizeof(buf), fmt, v); va_end(v); torrent_handle h; diff --git a/src/performance_counters.cpp b/src/performance_counters.cpp index be12606d5..21e7a2377 100644 --- a/src/performance_counters.cpp +++ b/src/performance_counters.cpp @@ -34,10 +34,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include // for memset -#ifdef TORRENT_USE_VALGRIND -#include -#endif - namespace libtorrent { @@ -86,9 +82,6 @@ namespace libtorrent { { TORRENT_ASSERT(i >= 0); TORRENT_ASSERT(i < num_counters); -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(m_stats_counter[i]); -#endif #ifdef ATOMIC_LLONG_LOCK_FREE return m_stats_counter[i].load(std::memory_order_relaxed); diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 9eb956bbe..8b6f7dd5a 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -56,10 +56,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_peer.hpp" #endif -#ifdef TORRENT_USE_VALGRIND -#include -#endif - #include "libtorrent/invariant_check.hpp" #define TORRENT_PIECE_PICKER_INVARIANT_CHECK INVARIANT_CHECK @@ -230,28 +226,17 @@ namespace libtorrent TORRENT_ASSERT(int(ret.info_idx) * m_blocks_per_piece + m_blocks_per_piece <= int(m_block_info.size())); -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(piece); - VALGRIND_CHECK_VALUE_IS_DEFINED(block_index); -#endif block_info* info = blocks_for_piece(ret); for (int i = 0; i < m_blocks_per_piece; ++i) { info[i].num_peers = 0; info[i].state = block_info::state_none; info[i].peer = 0; -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(info[i].peer); -#endif #if TORRENT_USE_ASSERTS info[i].piece_index = piece; info[i].peers.clear(); #endif } -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(ret.info_idx); - VALGRIND_CHECK_VALUE_IS_DEFINED(ret.index); -#endif downloading_iter = m_downloads[download_state].insert(downloading_iter, ret); #if TORRENT_USE_INVARIANT_CHECKS @@ -3027,9 +3012,6 @@ get_out: */ bool piece_picker::is_requested(piece_block block) const { -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(block); -#endif TORRENT_ASSERT(block.block_index != piece_block::invalid.block_index); TORRENT_ASSERT(block.piece_index != piece_block::invalid.piece_index); TORRENT_ASSERT(block.piece_index < m_piece_map.size()); @@ -3048,9 +3030,6 @@ get_out: bool piece_picker::is_downloaded(piece_block block) const { -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(block); -#endif TORRENT_ASSERT(block.block_index != piece_block::invalid.block_index); TORRENT_ASSERT(block.piece_index != piece_block::invalid.piece_index); TORRENT_ASSERT(block.piece_index < m_piece_map.size()); @@ -3070,9 +3049,6 @@ get_out: bool piece_picker::is_finished(piece_block block) const { -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_VALUE_IS_DEFINED(block); -#endif TORRENT_ASSERT(block.block_index != piece_block::invalid.block_index); TORRENT_ASSERT(block.piece_index != piece_block::invalid.piece_index); TORRENT_ASSERT(block.piece_index < m_piece_map.size()); diff --git a/src/session.cpp b/src/session.cpp index d41636b64..23064c802 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -329,11 +329,6 @@ namespace libtorrent // configurations this will give a link error void TORRENT_EXPORT TORRENT_CFG() {} -#if defined _MSC_VER && defined TORRENT_DEBUG - static void straight_to_debugger(unsigned int, _EXCEPTION_POINTERS*) - { throw; } -#endif - void session::start(int flags, settings_pack const& pack, io_service* ios) { bool const internal_executor = ios == NULL; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 99b26d959..3afbf00dc 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -32,8 +32,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include #include #include @@ -45,16 +43,14 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif // TORRENT_DEBUG && !TORRENT_DISABLE_INVARIANT_CHECKS +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include #include #include -#ifdef TORRENT_USE_VALGRIND -#include -#endif - #if TORRENT_USE_RLIMIT #ifdef __GNUC__ @@ -120,6 +116,7 @@ const rlim_t rlim_infinity = RLIM_INFINITY; #ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/socket_io.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex // for logging stat layout #include "libtorrent/stat.hpp" diff --git a/src/sha1_hash.cpp b/src/sha1_hash.cpp index 3f59eebb0..018bb2683 100644 --- a/src/sha1_hash.cpp +++ b/src/sha1_hash.cpp @@ -32,9 +32,31 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/sha1_hash.hpp" #include "libtorrent/aux_/cpuid.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex + +#include +#include namespace libtorrent { + // print a sha1_hash object to an ostream as 40 hexadecimal digits + std::ostream& operator<<(std::ostream& os, sha1_hash const& peer) + { + char out[sha1_hash::size * 2 + 1]; + to_hex(peer.data(), sha1_hash::size, out); + return os << out; + } + + // read 40 hexadecimal digits from an istream into a sha1_hash + std::istream& operator>>(std::istream& is, sha1_hash& peer) + { + char hex[sha1_hash::size]; + is.read(hex, sha1_hash::size); + if (!from_hex(hex, sha1_hash::size, peer.data())) + is.setstate(std::ios_base::failbit); + return is; + } + int sha1_hash::count_leading_zeroes() const { int ret = 0; diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index 8065af093..637c88b0e 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -37,14 +37,14 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include #include #include #include #include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include "libtorrent/hasher.hpp" #include "libtorrent/torrent.hpp" #include "libtorrent/torrent_handle.hpp" @@ -57,63 +57,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/random.hpp" #include "libtorrent/operations.hpp" // for operation_t enum -//#define TORRENT_LOG_HASH_FAILURES - #ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/socket_io.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex #endif -#ifdef TORRENT_LOG_HASH_FAILURES - -#include "libtorrent/peer_id.hpp" // sha1_hash -#include "libtorrent/hex.hpp" // to_hex -#include "libtorrent/socket_io.hpp" - -void log_hash_block(FILE** f, libtorrent::torrent const& t, int piece, int block - , libtorrent::address a, char const* bytes, int len, bool corrupt) -{ - using namespace libtorrent; - - mkdir("hash_failures", 0755); - - if (*f == NULL) - { - char filename[1024]; - std::snprintf(filename, sizeof(filename), "hash_failures/%s.log" - , to_hex(t.info_hash().to_string()).c_str()); - *f = fopen(filename, "w"); - } - - file_storage const& fs = t.torrent_file().files(); - std::vector files = fs.map_block(piece, block * 0x4000, len); - - std::string fn = fs.file_path(fs.internal_at(files[0].file_index)); - - char filename[4094]; - int offset = 0; - for (int i = 0; i < files.size(); ++i) - { - offset += std::snprintf(filename+offset, sizeof(filename)-offset - , "%s[%" PRId64 ",%d]", libtorrent::filename(fn).c_str(), files[i].offset, int(files[i].size)); - if (offset >= sizeof(filename)) break; - } - - std::fprintf(*f, "%s\t%04d\t%04d\t%s\t%s\t%s\n", to_hex(t.info_hash().to_string()).c_str(), piece - , block, corrupt ? " bad" : "good", print_address(a).c_str(), filename); - - std::snprintf(filename, sizeof(filename), "hash_failures/%s_%d_%d_%s.block" - , to_hex(t.info_hash().to_string()).c_str(), piece, block, corrupt ? "bad" : "good"); - FILE* data = fopen(filename, "w+"); - fwrite(bytes, 1, len, data); - fclose(data); -} - -#endif - - namespace libtorrent { - class torrent; +class torrent; namespace { @@ -125,16 +76,7 @@ namespace smart_ban_plugin(torrent& t) : m_torrent(t) , m_salt(random()) - { -#ifdef TORRENT_LOG_HASH_FAILURES - m_log_file = NULL; -#endif - } - -#ifdef TORRENT_LOG_HASH_FAILURES - ~smart_ban_plugin() - { fclose(m_log_file); } -#endif + {} virtual void on_piece_pass(int p) override { @@ -259,11 +201,6 @@ namespace torrent_peer* p = (*range.first); block_entry e = {p, h.final()}; -#ifdef TORRENT_LOG_HASH_FAILURES - log_hash_block(&m_log_file, m_torrent, b.piece_index - , b.block_index, p->address(), j->buffer.disk_block, j->buffer_size, true); -#endif - std::map::iterator i = m_block_hashes.lower_bound(b); if (i != m_block_hashes.end() && i->first == b && i->second.peer == p) @@ -299,7 +236,7 @@ namespace // we don't have to insert it return; } - + m_block_hashes.insert(i, std::pair(b, e)); #ifndef TORRENT_DISABLE_LOGGING @@ -334,11 +271,6 @@ namespace if (b.second.digest == ok_digest) return; -#ifdef TORRENT_LOG_HASH_FAILURES - log_hash_block(&m_log_file, m_torrent, b.first.piece_index - , b.first.block_index, a, j->buffer.disk_block, j->buffer_size, false); -#endif - // find the peer std::pair range = m_torrent.find_peers(a); @@ -384,9 +316,6 @@ namespace // that is forged to match the CRC of the good data. int m_salt; -#ifdef TORRENT_LOG_HASH_FAILURES - FILE* m_log_file; -#endif // explicitly disallow assignment, to silence msvc warning smart_ban_plugin& operator=(smart_ban_plugin const&); }; diff --git a/src/storage.cpp b/src/storage.cpp index 2c865dd2e..be1702940 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -33,12 +33,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/error_code.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include #include #include #include +#include + +#include "libtorrent/aux_/disable_warnings_push.hpp" #include #include @@ -79,8 +80,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/disk_buffer_holder.hpp" #include "libtorrent/alloca.hpp" #include "libtorrent/stat_cache.hpp" - -#include +#include "libtorrent/hex.hpp" // to_hex, from_hex //#define TORRENT_PARTIAL_HASH_LOG diff --git a/src/torrent.cpp b/src/torrent.cpp index e8944d5de..51e2b00dc 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -100,6 +100,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_manager.hpp" #include "libtorrent/disk_interface.hpp" #include "libtorrent/broadcast_socket.hpp" // for is_ip_address +#include "libtorrent/hex.hpp" // to_hex, from_hex // TODO: factor out cache_status to its own header #include "libtorrent/disk_io_thread.hpp" // for cache_status diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 66af9fe3d..f6d9d4f62 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/add_torrent_params.hpp" #include "libtorrent/magnet_uri.hpp" #include "libtorrent/announce_entry.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex #ifndef TORRENT_NO_DEPRECATE #include "libtorrent/lazy_entry.hpp" @@ -65,11 +66,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#if !defined TORRENT_NO_DEPRECATE && TORRENT_USE_IOSTREAM -#include -#include -#endif - #include "libtorrent/aux_/disable_warnings_pop.hpp" #if TORRENT_USE_I2P @@ -1724,33 +1720,6 @@ namespace libtorrent return ret; } -#if !defined TORRENT_NO_DEPRECATE && TORRENT_USE_IOSTREAM -// ------- start deprecation ------- - - void torrent_info::print(std::ostream& os) const - { - INVARIANT_CHECK; - - os << "trackers:\n"; - for (std::vector::const_iterator i = trackers().begin(); - i != trackers().end(); ++i) - { - os << i->tier << ": " << i->url << "\n"; - } - if (!m_comment.empty()) - os << "comment: " << m_comment << "\n"; - os << "private: " << (m_private?"yes":"no") << "\n"; - os << "number of pieces: " << num_pieces() << "\n"; - os << "piece length: " << piece_length() << "\n"; - os << "files:\n"; - for (int i = 0; i < m_files.num_files(); ++i) - os << " " << std::setw(11) << m_files.file_size(i) - << " " << m_files.file_path(i) << "\n"; - } - -// ------- end deprecation ------- -#endif - #if TORRENT_USE_INVARIANT_CHECKS void torrent_info::check_invariant() const { diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 45878dd7e..13051b292 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -48,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/random.hpp" #include "libtorrent/torrent_info.hpp" #include "libtorrent/broadcast_socket.hpp" // for supports_ipv6() +#include "libtorrent/hex.hpp" // to_hex, from_hex #include #include diff --git a/test/test_checking.cpp b/test/test_checking.cpp index f1b41fc19..a75f11fea 100644 --- a/test/test_checking.cpp +++ b/test/test_checking.cpp @@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for chmod #include "libtorrent/torrent_info.hpp" #include "libtorrent/torrent_status.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex static const int file_sizes[] = { 5, 16 - 5, 16000, 17, 10, 8000, 8000, 1,1,1,1,1,100,1,1,1,1,100,1,1,1,1,1,1 diff --git a/test/test_dht.cpp b/test/test_dht.cpp index f72218d65..09d7609da 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -41,27 +41,21 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/random.hpp" #include "libtorrent/ed25519.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/kademlia/node_id.hpp" #include "libtorrent/kademlia/routing_table.hpp" #include "libtorrent/kademlia/item.hpp" #include "libtorrent/kademlia/dht_observer.hpp" -#include "libtorrent/ed25519.hpp" + #include #include #include +#include #include "test.hpp" #include "setup_transfer.hpp" -#ifdef TORRENT_USE_VALGRIND -#include -#endif - -#if TORRENT_USE_IOSTREAM -#include -#endif - using namespace libtorrent; using namespace libtorrent::dht; @@ -227,14 +221,6 @@ void send_dht_request(node& node, char const* msg, udp::endpoint const& ep e["a"].dict().insert(std::make_pair("id", generate_next().to_string())); char msg_buf[1500]; int size = bencode(msg_buf, e); -#if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM -// this yields a lot of output. too much -// std::cerr << "sending: " << e << "\n"; -#endif - -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(msg_buf, size); -#endif bdecode_node decoded; error_code ec; @@ -281,10 +267,6 @@ void send_dht_response(node& node, bdecode_node const& request, udp::endpoint co char msg_buf[1500]; int size = bencode(msg_buf, e); -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(msg_buf, size); -#endif - bdecode_node decoded; error_code ec; bdecode(msg_buf, msg_buf + size, decoded, ec); @@ -989,9 +971,6 @@ void do_test_dht(address(&rand_addr)()) itemv = std::pair(buffer, bencode(buffer, items[0].ent)); sign_mutable_item(itemv, salt, seq, public_key, private_key, signature); TEST_EQUAL(verify_mutable_item(itemv, salt, seq, public_key, signature), true); -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(signature, item_sig_len); -#endif send_dht_request(node, "put", source, &response , msg_args() @@ -1063,9 +1042,6 @@ void do_test_dht(address(&rand_addr)()) itemv.second = bencode(buffer, items[0].ent); sign_mutable_item(itemv, salt, seq, public_key, private_key, signature); TEST_EQUAL(verify_mutable_item(itemv, salt, seq, public_key, signature), 1); -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(signature, item_sig_len); -#endif // break the signature signature[2] ^= 0xaa; @@ -1131,9 +1107,6 @@ void do_test_dht(address(&rand_addr)()) itemv.second = bencode(buffer, items[1].ent); sign_mutable_item(itemv, salt, seq, public_key, private_key, signature); TEST_EQUAL(verify_mutable_item(itemv, salt, seq, public_key, signature), 1); -#ifdef TORRENT_USE_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(signature, item_sig_len); -#endif TEST_CHECK(item_target_id(salt, public_key) == target_id); @@ -1342,11 +1315,7 @@ void do_test_dht(address(&rand_addr)()) // part of the closest nodes std::set duplicates; -#ifdef TORRENT_USE_VALGRIND - const int reps = 3; -#else const int reps = 50; -#endif for (int r = 0; r < reps; ++r) { diff --git a/test/test_dht_storage.cpp b/test/test_dht_storage.cpp index 428870322..08e476ad5 100644 --- a/test/test_dht_storage.cpp +++ b/test/test_dht_storage.cpp @@ -41,14 +41,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/random.hpp" #include "libtorrent/ed25519.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/kademlia/dht_storage.hpp" #include "libtorrent/kademlia/node_id.hpp" #include "libtorrent/kademlia/routing_table.hpp" #include "libtorrent/kademlia/item.hpp" #include "libtorrent/kademlia/dht_observer.hpp" -#include "libtorrent/random.hpp" -#include "libtorrent/ed25519.hpp" + #include #include "test.hpp" diff --git a/test/test_magnet.cpp b/test/test_magnet.cpp index 5644afa62..08049d3ba 100644 --- a/test/test_magnet.cpp +++ b/test/test_magnet.cpp @@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bencode.hpp" #include "libtorrent/torrent_info.hpp" // for announce_entry #include "libtorrent/announce_entry.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex using namespace libtorrent; namespace lt = libtorrent; diff --git a/test/test_pe_crypto.cpp b/test/test_pe_crypto.cpp index d6ebf065b..123ae4b19 100644 --- a/test/test_pe_crypto.cpp +++ b/test/test_pe_crypto.cpp @@ -45,11 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. void test_enc_handler(libtorrent::crypto_plugin* a, libtorrent::crypto_plugin* b) { -#ifdef TORRENT_USE_VALGRIND - const int repcount = 10; -#else const int repcount = 128; -#endif for (int rep = 0; rep < repcount; ++rep) { int const buf_len = rand() % (512 * 1024); @@ -106,11 +102,7 @@ TORRENT_TEST(diffie_hellman) { using namespace libtorrent; -#ifdef TORRENT_USE_VALGRIND - const int repcount = 10; -#else const int repcount = 128; -#endif for (int rep = 0; rep < repcount; ++rep) { diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index 278f3f50c..d9afafa75 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/socket_io.hpp" // for print_endpoint #include "libtorrent/announce_entry.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex #include "test.hpp" #include "setup_transfer.hpp" diff --git a/test/test_privacy.cpp b/test/test_privacy.cpp index 4319e5b6e..386b01a3d 100644 --- a/test/test_privacy.cpp +++ b/test/test_privacy.cpp @@ -168,11 +168,7 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, int flags) rejected_trackers.clear(); -#ifdef TORRENT_USE_VALGRIND - const int timeout = 100; -#else const int timeout = 20; -#endif for (int i = 0; i < timeout; ++i) { diff --git a/test/test_read_piece.cpp b/test/test_read_piece.cpp index 95b66a637..8de8b870d 100644 --- a/test/test_read_piece.cpp +++ b/test/test_read_piece.cpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/create_torrent.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/torrent_info.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex enum flags_t { diff --git a/test/test_resolve_links.cpp b/test/test_resolve_links.cpp index 8da6aa4e2..2e87b38cf 100644 --- a/test/test_resolve_links.cpp +++ b/test/test_resolve_links.cpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_info.hpp" #include "libtorrent/resolve_links.hpp" #include "libtorrent/file.hpp" // for combine_path +#include "libtorrent/hex.hpp" // to_hex, from_hex #include #include diff --git a/test/test_sha1_hash.cpp b/test/test_sha1_hash.cpp index 4a4fcd55a..805de1013 100644 --- a/test/test_sha1_hash.cpp +++ b/test/test_sha1_hash.cpp @@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "libtorrent/sha1_hash.hpp" +#include "libtorrent/hex.hpp" // to_hex, from_hex using namespace libtorrent; diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index f76a037ce..c943c33b0 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/file.hpp" #include "libtorrent/session_status.hpp" #include "libtorrent/torrent_info.hpp" +#include "libtorrent/hex.hpp" // for to_hex, from_hex #include "test.hpp" #include "test_utils.hpp" @@ -232,11 +233,7 @@ void test_ssl(int test_idx, bool use_utp) tor1.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec) , port)); -#ifdef TORRENT_USE_VALGRIND - const int timeout = 100; -#else const int timeout = 40; -#endif for (int i = 0; i < timeout; ++i) { print_alerts(ses1, "ses1", true, true, true, &on_alert); diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 28118519a..25bbc107e 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -37,7 +37,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/create_torrent.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/torrent.hpp" -#include #include #include diff --git a/test/test_torrent_info.cpp b/test/test_torrent_info.cpp index ac8189777..1210f7bc3 100644 --- a/test/test_torrent_info.cpp +++ b/test/test_torrent_info.cpp @@ -36,17 +36,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/create_torrent.hpp" #include "libtorrent/announce_entry.hpp" #include "libtorrent/aux_/escape_string.hpp" // for convert_path_to_posix +#include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/aux_/disable_warnings_push.hpp" - #include -#include - #include "libtorrent/aux_/disable_warnings_pop.hpp" -#if TORRENT_USE_IOSTREAM -#include -#endif +#include using namespace libtorrent; @@ -737,20 +733,6 @@ TORRENT_TEST(parse_torrents) , flags & file_storage::flag_symlink ? "-> ": "" , flags & file_storage::flag_symlink ? fs.symlink(i).c_str() : ""); } - - // test swap -#if !defined TORRENT_NO_DEPRECATE && TORRENT_USE_IOSTREAM - std::stringstream str1; - ti->print(str1); - - torrent_info temp("temp", ec); - temp.swap(*ti); - - std::stringstream str2; - temp.print(str2); - TEST_EQUAL(str1.str(), str2.str()); -#endif - } for (int i = 0; i < int(sizeof(test_error_torrents)/sizeof(test_error_torrents[0])); ++i) diff --git a/test/test_utp.cpp b/test/test_utp.cpp index f5c39dbbc..5f089c7a4 100644 --- a/test/test_utp.cpp +++ b/test/test_utp.cpp @@ -105,11 +105,7 @@ void test_transfer() boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0 , true, false, true, "_utp", 0, &t, false, &atp); -#ifdef TORRENT_USE_VALGRIND - const int timeout = 16; -#else const int timeout = 8; -#endif for (int i = 0; i < timeout; ++i) {