diff --git a/Jamfile b/Jamfile index 342928505..d1da0b7be 100644 --- a/Jamfile +++ b/Jamfile @@ -280,7 +280,7 @@ rule warnings ( properties * ) # in the code (without final) result += -Wno-non-virtual-dtor ; -# enable these warnings again, once the other ones are delt with +# enable these warnings again, once the other ones are dealt with result += -Wno-weak-vtables ; result += -Wno-sign-compare ; result += -Wno-sign-conversion ; @@ -291,11 +291,18 @@ rule warnings ( properties * ) { result += -Wall ; result += -Wextra ; + result += -Wpedantic ; +# result += -Wmisleading-indentation ; + result += -Wparentheses ; + result += -Wvla ; + result += -Wc++11-compat ; + result += -Wc++14-compat ; - result += -Wno-deprecated-declarations ; + result += -Wno-format-zero-length ; # enable these warnings again, once the other ones are dealt with result += -Wno-sign-compare ; + result += -Wno-unused-variable ; } if msvc in $(properties) diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index c15d5ec80..86b1b28d7 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -266,6 +266,10 @@ namespace libtorrent { virtual int category() const = 0; #ifndef TORRENT_NO_DEPRECATE + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + // determines whether or not an alert is allowed to be discarded // when the alert queue is full. There are a few alerts which may not be discared, // since they would break the user contract, such as save_resume_data_alert. @@ -284,6 +288,9 @@ namespace libtorrent { virtual bool discardable_impl() const { return true; } virtual std::auto_ptr clone_impl() const = 0; + +#pragma GCC diagnostic pop + #endif private: diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index d7fe70e48..7d2079aeb 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -69,7 +69,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" #include "libtorrent/piece_block_progress.hpp" #include "libtorrent/ip_filter.hpp" -#include "libtorrent/config.hpp" #include "libtorrent/session_settings.hpp" #include "libtorrent/session_status.hpp" #include "libtorrent/add_torrent_params.hpp" diff --git a/include/libtorrent/disk_interface.hpp b/include/libtorrent/disk_interface.hpp index daf22b6a3..206faf0e3 100644 --- a/include/libtorrent/disk_interface.hpp +++ b/include/libtorrent/disk_interface.hpp @@ -39,7 +39,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bdecode.hpp" #include -#include namespace libtorrent { @@ -68,7 +67,7 @@ namespace libtorrent = boost::function()) = 0; virtual void async_check_fastresume(piece_manager* storage , bdecode_node const* resume_data - , std::auto_ptr >& links + , std::vector& links , boost::function const& handler) = 0; #ifndef TORRENT_NO_DEPRECATE virtual void async_finalize_file(piece_manager*, int file diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 7eae4b7a5..8febbcc96 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -235,7 +235,7 @@ namespace libtorrent // number of read jobs in the disk job queue int read_queue_size; - + // number of jobs blocked because of a fence int blocked_jobs; @@ -315,7 +315,7 @@ namespace libtorrent , boost::function const& handler); void async_check_fastresume(piece_manager* storage , bdecode_node const* resume_data - , std::auto_ptr >& links + , std::vector& links , boost::function const& handler); void async_save_resume_data(piece_manager* storage , boost::function const& handler); diff --git a/include/libtorrent/ip_filter.hpp b/include/libtorrent/ip_filter.hpp index 84e4adcd1..12d18daf3 100644 --- a/include/libtorrent/ip_filter.hpp +++ b/include/libtorrent/ip_filter.hpp @@ -33,11 +33,13 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_IP_FILTER_HPP #define TORRENT_IP_FILTER_HPP -#include -#include +#include "libtorrent/config.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" +#include +#include + #include #include #include @@ -45,7 +47,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" -#include "libtorrent/config.hpp" #include "libtorrent/address.hpp" #include "libtorrent/assert.hpp" @@ -148,15 +149,15 @@ namespace detail { TORRENT_ASSERT(!m_access_list.empty()); TORRENT_ASSERT(first < last || first == last); - + typename range_t::iterator i = m_access_list.upper_bound(first); typename range_t::iterator j = m_access_list.upper_bound(last); if (i != m_access_list.begin()) --i; - + TORRENT_ASSERT(j != m_access_list.begin()); TORRENT_ASSERT(j != i); - + boost::uint32_t first_access = i->access; boost::uint32_t last_access = boost::prior(j)->access; @@ -184,7 +185,7 @@ namespace detail { m_access_list.insert(i, range(first, flags)); } - + if ((j != m_access_list.end() && minus_one(j->start) != last) || (j == m_access_list.end() @@ -228,14 +229,14 @@ namespace detail r.last = ExternalAddressType(max_addr()); else r.last = ExternalAddressType(minus_one(i->start)); - + ret.push_back(r); } return ret; } private: - + struct range { range(Addr addr, int a = 0): start(addr), access(a) {} @@ -300,7 +301,7 @@ struct TORRENT_EXPORT ip_filter #else typedef std::vector > filter_tuple_t; #endif - + // This function will return the current state of the filter in the minimum number of // ranges possible. They are sorted from ranges in low addresses to high addresses. Each // entry in the returned vector is a range with the access control specified in its @@ -311,7 +312,7 @@ struct TORRENT_EXPORT ip_filter filter_tuple_t export_filter() const; // void print() const; - + private: detail::filter_impl m_filter4; diff --git a/include/libtorrent/kademlia/traversal_algorithm.hpp b/include/libtorrent/kademlia/traversal_algorithm.hpp index 8f0778299..e1909b5f2 100644 --- a/include/libtorrent/kademlia/traversal_algorithm.hpp +++ b/include/libtorrent/kademlia/traversal_algorithm.hpp @@ -41,11 +41,15 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + namespace libtorrent { struct dht_lookup; } namespace libtorrent { namespace dht { diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index d4487ac13..6ac7f386f 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -892,11 +892,17 @@ namespace libtorrent TORRENT_DEPRECATED int max_uploads() const; - TORRENT_DEPRECATED - std::auto_ptr pop_alert(); TORRENT_DEPRECATED void pop_alerts(std::deque* alerts); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + TORRENT_DEPRECATED + std::auto_ptr pop_alert(); + +#pragma GCC diagnostic pop + #endif // Alerts is the main mechanism for libtorrent to report errors and @@ -974,6 +980,9 @@ namespace libtorrent TORRENT_DEPRECATED boost::uint32_t get_alert_mask() const; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + // This sets a function to be called (from within libtorrent's netowrk // thread) every time an alert is posted. Since the function (``fun``) is // run in libtorrent's internal thread, it may not block. @@ -986,6 +995,8 @@ namespace libtorrent void set_alert_dispatch( boost::function)> const& fun); +#pragma GCC diagnostic pop + // Starts and stops Local Service Discovery. This service will broadcast // the infohashes of all the non-private torrents on the local network to // look for peers on the same swarm within multicast reach. diff --git a/src/alert_manager.cpp b/src/alert_manager.cpp index 44cb0d62a..8eac4b624 100644 --- a/src/alert_manager.cpp +++ b/src/alert_manager.cpp @@ -117,6 +117,9 @@ namespace libtorrent return false; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + void alert_manager::set_dispatch_function( boost::function)> const& fun) { @@ -137,6 +140,9 @@ namespace libtorrent m_dispatch((*i)->clone()); } } + +#pragma GCC diagnostic pop + #endif void alert_manager::set_notify_function(boost::function const& fun) diff --git a/src/block_cache.cpp b/src/block_cache.cpp index 7d4e215b0..de03b557c 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -283,7 +283,7 @@ const char* const job_action_name[] = "hash_passed: %d\nread_jobs: %d\njobs: %d\n" "piece_log:\n" , int(pe->piece), pe->refcount, pe->piece_refcount, int(pe->num_blocks) - , int(pe->hashing), pe->hash, pe->hash ? pe->hash->offset : -1 + , int(pe->hashing), static_cast(pe->hash), pe->hash ? pe->hash->offset : -1 , int(pe->cache_state) , pe->cache_state < cached_piece_entry::num_lrus ? cache_state[pe->cache_state] : "" , int(pe->outstanding_flush), int(pe->piece), int(pe->num_dirty) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index dc341d4cf..4a8722ee6 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -31,6 +31,10 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "libtorrent/config.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include @@ -39,6 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // autp_ptr #endif +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include "libtorrent/bt_peer_connection.hpp" #include "libtorrent/session.hpp" #include "libtorrent/identify_client.hpp" @@ -196,7 +202,6 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING char const* policy_name[] = {"forced", "enabled", "disabled"}; TORRENT_ASSERT(out_policy < sizeof(policy_name)/sizeof(policy_name[0])); - TORRENT_ASSERT(out_policy >= 0); peer_log(peer_log_alert::info, "ENCRYPTION" , "outgoing encryption policy: %s", policy_name[out_policy]); #endif diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 9299ef0ee..4db5da4fb 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1878,7 +1878,7 @@ namespace libtorrent void disk_io_thread::async_check_fastresume(piece_manager* storage , bdecode_node const* resume_data - , std::auto_ptr >& links + , std::vector& links , boost::function const& handler) { #ifdef TORRENT_DEBUG @@ -1887,14 +1887,17 @@ namespace libtorrent storage->assert_torrent_refcount(); #endif + std::vector* links_vector + = new std::vector(); + links_vector->swap(links); + disk_io_job* j = allocate_job(disk_io_job::check_fastresume); j->storage = storage->shared_from_this(); j->buffer.string = (char*)resume_data; - j->d.links = links.get(); + j->d.links = links_vector; j->callback = handler; add_fence_job(storage, j); - links.release(); } void disk_io_thread::async_save_resume_data(piece_manager* storage @@ -2570,7 +2573,7 @@ namespace libtorrent #if TORRENT_USE_ASSERTS m_disk_cache.mark_deleted(*j->storage->files()); #endif - + flush_cache(j->storage.get(), flush_delete_cache | flush_expect_clear , completed_jobs, l); l.unlock(); @@ -2588,7 +2591,7 @@ namespace libtorrent bdecode_node tmp; if (rd == NULL) rd = &tmp; - std::auto_ptr > links(j->d.links); + boost::scoped_ptr > links(j->d.links); return j->storage->check_fastresume(*rd, links.get(), j->error); } diff --git a/src/file_pool.cpp b/src/file_pool.cpp index 54ce13126..149cff661 100644 --- a/src/file_pool.cpp +++ b/src/file_pool.cpp @@ -30,8 +30,15 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "libtorrent/config.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include + +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include "libtorrent/assert.hpp" #include "libtorrent/file_pool.hpp" #include "libtorrent/error_code.hpp" diff --git a/src/http_connection.cpp b/src/http_connection.cpp index 025393bee..4f6c375cc 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -45,10 +45,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" #endif +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + namespace libtorrent { http_connection::http_connection(io_service& ios diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index 29107b8d6..d32a30de1 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -30,10 +30,16 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "libtorrent/config.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include "libtorrent/http_seed_connection.hpp" #include "libtorrent/session.hpp" #include "libtorrent/identify_client.hpp" diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 64367a9cb..b87b93034 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -30,24 +30,20 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "libtorrent/config.hpp" +#include "libtorrent/gzip.hpp" +#include "libtorrent/socket_io.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include #include -#include "libtorrent/config.hpp" -#include "libtorrent/gzip.hpp" -#include "libtorrent/socket_io.hpp" - -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/tracker_manager.hpp" #include "libtorrent/http_tracker_connection.hpp" diff --git a/src/kademlia/find_data.cpp b/src/kademlia/find_data.cpp index 5d14537ac..886a5680c 100644 --- a/src/kademlia/find_data.cpp +++ b/src/kademlia/find_data.cpp @@ -54,7 +54,7 @@ void find_data_observer::reply(msg const& m) { #ifndef TORRENT_DISABLE_LOGGING get_observer()->log(dht_logger::traversal, "[%p] missing response dict" - , algorithm()); + , static_cast(algorithm())); #endif return; } @@ -64,7 +64,7 @@ void find_data_observer::reply(msg const& m) { #ifndef TORRENT_DISABLE_LOGGING get_observer()->log(dht_logger::traversal, "[%p] invalid id in response" - , algorithm()); + , static_cast(algorithm())); #endif return; } @@ -112,8 +112,10 @@ void find_data::start() void find_data::got_write_token(node_id const& n, std::string const& write_token) { #ifndef TORRENT_DISABLE_LOGGING - get_node().observer()->log(dht_logger::traversal, "[%p] adding write token '%s' under id '%s'" - , this, to_hex(write_token).c_str(), to_hex(n.to_string()).c_str()); + get_node().observer()->log(dht_logger::traversal + , "[%p] adding write token '%s' under id '%s'" + , static_cast(this), to_hex(write_token).c_str() + , to_hex(n.to_string()).c_str()); #endif m_write_tokens[n] = write_token; } @@ -138,7 +140,7 @@ void find_data::done() #ifndef TORRENT_DISABLE_LOGGING get_node().observer()->log(dht_logger::traversal, "[%p] %s DONE" - , this, name()); + , static_cast(this), name()); #endif std::vector > results; @@ -151,7 +153,7 @@ void find_data::done() { #ifndef TORRENT_DISABLE_LOGGING get_node().observer()->log(dht_logger::traversal, "[%p] not alive: %s" - , this, print_endpoint(o->target_ep()).c_str()); + , static_cast(this), print_endpoint(o->target_ep()).c_str()); #endif continue; } @@ -160,14 +162,14 @@ void find_data::done() { #ifndef TORRENT_DISABLE_LOGGING get_node().observer()->log(dht_logger::traversal, "[%p] no write token: %s" - , this, print_endpoint(o->target_ep()).c_str()); + , static_cast(this), print_endpoint(o->target_ep()).c_str()); #endif continue; } results.push_back(std::make_pair(node_entry(o->id(), o->target_ep()), j->second)); #ifndef TORRENT_DISABLE_LOGGING get_node().observer()->log(dht_logger::traversal, "[%p] %s" - , this, print_endpoint(o->target_ep()).c_str()); + , static_cast(this), print_endpoint(o->target_ep()).c_str()); #endif --num_results; } diff --git a/src/kademlia/get_item.cpp b/src/kademlia/get_item.cpp index 74b28725d..a794ed922 100644 --- a/src/kademlia/get_item.cpp +++ b/src/kademlia/get_item.cpp @@ -213,7 +213,7 @@ void get_item::put(std::vector > const& v) // the bencoded dict if logging is disabled get_node().observer()->log(dht_logger::traversal, "[%p] sending put " "[ seq: %" PRId64 " nodes: %d ]" - , this, (m_data.is_mutable() ? m_data.seq() : -1) + , static_cast(this), (m_data.is_mutable() ? m_data.seq() : -1) , int(v.size())); #endif @@ -227,7 +227,7 @@ void get_item::put(std::vector > const& v) { #ifndef TORRENT_DISABLE_LOGGING get_node().observer()->log(dht_logger::traversal, "[%p] put-distance: %d" - , this, 160 - distance_exp(m_target, i->first.id)); + , static_cast(this), 160 - distance_exp(m_target, i->first.id)); #endif void* ptr = m_node.m_rpc.allocate_observer(); @@ -269,7 +269,7 @@ void get_item_observer::reply(msg const& m) { #ifndef TORRENT_DISABLE_LOGGING get_observer()->log(dht_logger::traversal, "[%p] missing response dict" - , algorithm()); + , static_cast(algorithm())); #endif return; } diff --git a/src/kademlia/get_peers.cpp b/src/kademlia/get_peers.cpp index 78b034865..12d44828d 100644 --- a/src/kademlia/get_peers.cpp +++ b/src/kademlia/get_peers.cpp @@ -52,7 +52,7 @@ void get_peers_observer::reply(msg const& m) { #ifndef TORRENT_DISABLE_LOGGING get_observer()->log(dht_logger::traversal, "[%p] missing response dict" - , algorithm()); + , static_cast(algorithm())); #endif return; } @@ -74,7 +74,7 @@ void get_peers_observer::reply(msg const& m) { get_observer()->log(dht_logger::traversal, "[%p] PEERS " "invoke-count: %d branch-factor: %d addr: %s id: %s distance: %d p: %d" - , algorithm() + , static_cast(algorithm()) , algorithm()->invoke_count() , algorithm()->branch_factor() , print_endpoint(m.addr).c_str() @@ -96,7 +96,7 @@ void get_peers_observer::reply(msg const& m) { get_observer()->log(dht_logger::traversal, "[%p] PEERS " "invoke-count: %d branch-factor: %d addr: %s id: %s distance: %d p: %d" - , algorithm() + , static_cast(algorithm()) , algorithm()->invoke_count() , algorithm()->branch_factor() , print_endpoint(m.addr).c_str() @@ -279,7 +279,8 @@ void obfuscated_get_peers::done() #ifndef TORRENT_DISABLE_LOGGING get_node().observer()->log(dht_logger::traversal, "[%p] obfuscated get_peers " "phase 1 done, spawning get_peers [ %p ]" - , this, ta.get()); + , static_cast(this) + , static_cast(ta.get())); #endif int num_added = 0; @@ -309,7 +310,7 @@ void obfuscated_get_peers_observer::reply(msg const& m) { #ifndef TORRENT_DISABLE_LOGGING get_observer()->log(dht_logger::traversal, "[%p] missing response dict" - , algorithm()); + , static_cast(algorithm())); #endif return; } @@ -319,7 +320,7 @@ void obfuscated_get_peers_observer::reply(msg const& m) { #ifndef TORRENT_DISABLE_LOGGING get_observer()->log(dht_logger::traversal, "[%p] invalid id in response" - , algorithm()); + , static_cast(algorithm())); #endif return; } diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index 96d0899f2..efa74ca47 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -484,7 +484,7 @@ struct ping_observer : observer { get_observer()->log(dht_logger::node , "[%p] missing response dict" - , algorithm()); + , static_cast(algorithm())); } #endif return; diff --git a/src/kademlia/refresh.cpp b/src/kademlia/refresh.cpp index 48f50e096..fee53e6fa 100644 --- a/src/kademlia/refresh.cpp +++ b/src/kademlia/refresh.cpp @@ -89,7 +89,7 @@ void bootstrap::done() { #ifndef TORRENT_DISABLE_LOGGING get_node().observer()->log(dht_logger::traversal, "[%p] bootstrap done, pinging remaining nodes" - , this); + , static_cast(this)); #endif for (std::vector::iterator i = m_results.begin() diff --git a/src/kademlia/rpc_manager.cpp b/src/kademlia/rpc_manager.cpp index 1bd1b24e5..56fcd346f 100644 --- a/src/kademlia/rpc_manager.cpp +++ b/src/kademlia/rpc_manager.cpp @@ -337,7 +337,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id #ifndef TORRENT_DISABLE_LOGGING m_log->log(dht_logger::rpc_manager, "[%p] reply with transaction id: %d from %s" - , o->algorithm(), int(transaction_id.size()) + , static_cast(o->algorithm()), int(transaction_id.size()) , print_endpoint(m.addr).c_str()); #endif o->reply(m); @@ -357,7 +357,7 @@ time_duration rpc_manager::tick() static const int short_timeout = 1; static const int timeout = 15; - // look for observers that have timed out + // look for observers that have timed out if (m_transactions.empty()) return seconds(short_timeout); @@ -377,7 +377,7 @@ time_duration rpc_manager::tick() { #ifndef TORRENT_DISABLE_LOGGING m_log->log(dht_logger::rpc_manager, "[%p] timing out transaction id: %d from: %s" - , o->algorithm(), o->transaction_id() + , static_cast(o->algorithm()), o->transaction_id() , print_endpoint(o->target_ep()).c_str()); #endif m_transactions.erase(i++); @@ -391,7 +391,7 @@ time_duration rpc_manager::tick() { #ifndef TORRENT_DISABLE_LOGGING m_log->log(dht_logger::rpc_manager, "[%p] short-timing out transaction id: %d from: %s" - , o->algorithm(), o->transaction_id() + , static_cast(o->algorithm()), o->transaction_id() , print_endpoint(o->target_ep()).c_str()); #endif ++i; @@ -438,7 +438,7 @@ bool rpc_manager::invoke(entry& e, udp::endpoint target_addr #ifndef TORRENT_DISABLE_LOGGING m_log->log(dht_logger::rpc_manager, "[%p] invoking %s -> %s" - , o->algorithm(), e["q"].string().c_str() + , static_cast(o->algorithm()), e["q"].string().c_str() , print_endpoint(target_addr).c_str()); #endif diff --git a/src/kademlia/traversal_algorithm.cpp b/src/kademlia/traversal_algorithm.cpp index 16e405525..f2482c942 100644 --- a/src/kademlia/traversal_algorithm.cpp +++ b/src/kademlia/traversal_algorithm.cpp @@ -95,7 +95,7 @@ traversal_algorithm::traversal_algorithm( char hex_target[41]; to_hex(reinterpret_cast(&target[0]), 20, hex_target); get_node().observer()->log(dht_logger::traversal, "[%p] NEW target: %s k: %d" - , this, hex_target, int(m_node.m_table.bucket_size())); + , static_cast(this), hex_target, int(m_node.m_table.bucket_size())); } #endif } @@ -124,7 +124,7 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig if (get_node().observer()) { get_node().observer()->log(dht_logger::traversal, "[%p] failed to allocate memory or observer. aborting!" - , this); + , static_cast(this)); } #endif done(); @@ -180,7 +180,7 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig to_hex(reinterpret_cast(&o->id()[0]), 20, hex_id); get_node().observer()->log(dht_logger::traversal , "[%p] IGNORING result id: %s addr: %s type: %s" - , this, hex_id, print_address(o->target_addr()).c_str(), name()); + , static_cast(this), hex_id, print_address(o->target_addr()).c_str(), name()); } #endif return; @@ -200,7 +200,7 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig to_hex(reinterpret_cast(&id[0]), 20, hex_id); get_node().observer()->log(dht_logger::traversal , "[%p] ADD id: %s addr: %s distance: %d invoke-count: %d type: %s" - , this, hex_id, print_endpoint(addr).c_str() + , static_cast(this), hex_id, print_endpoint(addr).c_str() , distance_exp(m_target, id), m_invoke_count, name()); } #endif @@ -257,7 +257,7 @@ void traversal_algorithm::traverse(node_id const& id, udp::endpoint addr) { get_node().observer()->log(dht_logger::traversal , "[%p] WARNING node returned a list which included a node with id 0" - , this); + , static_cast(this)); } #endif @@ -326,7 +326,7 @@ void traversal_algorithm::failed(observer_ptr o, int flags) get_node().observer()->log(dht_logger::traversal , "[%p] 1ST_TIMEOUT id: %s distance: %d addr: %s branch-factor: %d " "invoke-count: %d type: %s" - , this, hex_id, distance_exp(m_target, o->id()) + , static_cast(this), hex_id, distance_exp(m_target, o->id()) , print_address(o->target_addr()).c_str(), m_branch_factor , m_invoke_count, name()); } @@ -348,7 +348,7 @@ void traversal_algorithm::failed(observer_ptr o, int flags) get_node().observer()->log(dht_logger::traversal , "[%p] TIMEOUT id: %s distance: %d addr: %s branch-factor: %d " "invoke-count: %d type: %s" - , this, hex_id, distance_exp(m_target, o->id()) + , static_cast(this), hex_id, distance_exp(m_target, o->id()) , print_address(o->target_addr()).c_str(), m_branch_factor , m_invoke_count, name()); } @@ -387,7 +387,7 @@ void traversal_algorithm::done() to_hex(reinterpret_cast(&o->id()[0]), 20, hex_id); get_node().observer()->log(dht_logger::traversal , "[%p] id: %s distance: %d addr: %s" - , this, hex_id, closest_target + , static_cast(this), hex_id, closest_target , print_endpoint(o->target_ep()).c_str()); --results_target; @@ -400,7 +400,7 @@ void traversal_algorithm::done() { get_node().observer()->log(dht_logger::traversal , "[%p] COMPLETED distance: %d type: %s" - , this, closest_target, name()); + , static_cast(this), closest_target, name()); } #endif // delete all our references to the observer objects so @@ -465,7 +465,7 @@ bool traversal_algorithm::add_requests() , "[%p] INVOKE nodes-left: %d top-invoke-count: %d " "invoke-count: %d branch-factor: %d " "distance: %d id: %s addr: %s type: %s" - , this, int(m_results.end() - i), outstanding, int(m_invoke_count) + , static_cast(this), int(m_results.end() - i), outstanding, int(m_invoke_count) , int(m_branch_factor), distance_exp(m_target, o->id()), hex_id , print_address(o->target_addr()).c_str(), name()); } @@ -499,7 +499,7 @@ void traversal_algorithm::add_router_entries() { get_node().observer()->log(dht_logger::traversal , "[%p] using router nodes to initiate traversal algorithm %d routers" - , this, int(std::distance(m_node.m_table.router_begin(), m_node.m_table.router_end()))); + , static_cast(this), int(std::distance(m_node.m_table.router_begin(), m_node.m_table.router_end()))); } #endif for (routing_table::router_iterator i = m_node.m_table.router_begin() @@ -557,7 +557,7 @@ void traversal_observer::reply(msg const& m) { get_observer()->log(dht_logger::traversal , "[%p] missing response dict" - , algorithm()); + , static_cast(algorithm())); } #endif return; @@ -571,7 +571,7 @@ void traversal_observer::reply(msg const& m) to_hex(nid.string_ptr(), 20, hex_id); get_observer()->log(dht_logger::traversal , "[%p] RESPONSE id: %s invoke-count: %d addr: %s type: %s" - , algorithm(), hex_id, algorithm()->invoke_count() + , static_cast(algorithm()), hex_id, algorithm()->invoke_count() , print_endpoint(target_ep()).c_str(), algorithm()->name()); } #endif @@ -598,7 +598,7 @@ void traversal_observer::reply(msg const& m) if (get_observer()) { get_observer()->log(dht_logger::traversal, "[%p] invalid id in response" - , algorithm()); + , static_cast(algorithm())); } #endif return; @@ -623,7 +623,7 @@ void traversal_algorithm::abort() if (get_node().observer()) { get_node().observer()->log(dht_logger::traversal, "[%p] ABORTED type: %s" - , this, name()); + , static_cast(this), name()); } #endif diff --git a/src/natpmp.cpp b/src/natpmp.cpp index 1006284e8..2f5407f14 100644 --- a/src/natpmp.cpp +++ b/src/natpmp.cpp @@ -30,6 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/config.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #if defined TORRENT_OS2 #include #endif @@ -37,6 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include "libtorrent/natpmp.hpp" #include "libtorrent/io.hpp" #include "libtorrent/assert.hpp" diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 20df3505d..adc457e50 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -230,7 +230,8 @@ namespace libtorrent , "ep: %s type: %s seed: %d p: %p local: %s" , print_endpoint(m_remote).c_str() , m_socket->type_name() - , m_peer_info ? m_peer_info->seed : 0, m_peer_info + , m_peer_info ? m_peer_info->seed : 0 + , static_cast(m_peer_info) , print_endpoint(local_ep).c_str()); #endif #ifdef TORRENT_DEBUG @@ -389,7 +390,7 @@ namespace libtorrent disconnect(ec, op_sock_bind); return; } - + #ifndef TORRENT_DISABLE_LOGGING peer_log(peer_log_alert::outgoing, "ASYNC_CONNECT", "dst: %s" , print_endpoint(m_remote).c_str()); @@ -400,7 +401,8 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING if (t) - t->debug_log("START connect [%p] (%d)", this, int(t->num_peers())); + t->debug_log("START connect [%p] (%d)", static_cast(this) + , int(t->num_peers())); #endif m_socket->async_connect(m_remote @@ -706,7 +708,8 @@ namespace libtorrent if (m_num_pieces == int(m_have_piece.size())) { #ifndef TORRENT_DISABLE_LOGGING - peer_log(peer_log_alert::info, "INIT", "this is a seed p: %p", m_peer_info); + peer_log(peer_log_alert::info, "INIT", "this is a seed p: %p" + , static_cast(m_peer_info)); #endif TORRENT_ASSERT(m_have_piece.all_set()); @@ -1576,7 +1579,8 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING m_unchoke_time = clock_type::now(); - t->debug_log("UNCHOKE [%p] (%d ms)", this, int(total_milliseconds(m_unchoke_time - m_bitfield_time))); + t->debug_log("UNCHOKE [%p] (%d ms)", static_cast(this) + , int(total_milliseconds(m_unchoke_time - m_bitfield_time))); #endif #ifndef TORRENT_DISABLE_EXTENSIONS @@ -1881,7 +1885,8 @@ namespace libtorrent if (is_seed()) { #ifndef TORRENT_DISABLE_LOGGING - peer_log(peer_log_alert::info, "SEED", "this is a seed. p: %p", m_peer_info); + peer_log(peer_log_alert::info, "SEED", "this is a seed. p: %p" + , static_cast(m_peer_info)); #endif TORRENT_ASSERT(m_have_piece.all_set()); @@ -2039,7 +2044,9 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING m_bitfield_time = clock_type::now(); - t->debug_log("HANDSHAKE [%p] (%d ms)", this, int(total_milliseconds(m_bitfield_time - m_connect_time))); + t->debug_log("HANDSHAKE [%p] (%d ms)" + , static_cast(this) + , int(total_milliseconds(m_bitfield_time - m_connect_time))); #endif // if we don't have metadata yet // just remember the bitmask @@ -2049,7 +2056,8 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_LOGGING if (m_num_pieces == int(bits.size())) - peer_log(peer_log_alert::info, "SEED", "this is a seed. p: %p", m_peer_info); + peer_log(peer_log_alert::info, "SEED", "this is a seed. p: %p" + , static_cast(m_peer_info)); #endif m_have_piece = bits; m_num_pieces = bits.count(); @@ -2063,12 +2071,13 @@ namespace libtorrent } TORRENT_ASSERT(t->valid_metadata()); - + int num_pieces = bits.count(); if (num_pieces == int(m_have_piece.size())) { #ifndef TORRENT_DISABLE_LOGGING - peer_log(peer_log_alert::info, "SEED", "this is a seed. p: %p", m_peer_info); + peer_log(peer_log_alert::info, "SEED", "this is a seed. p: %p" + , static_cast(m_peer_info)); #endif t->set_seed(m_peer_info, true); @@ -2780,7 +2789,7 @@ namespace libtorrent } #ifndef TORRENT_DISABLE_LOGGING - t->debug_log("PIECE [%p] (%d ms) (%d)", this + t->debug_log("PIECE [%p] (%d ms) (%d)", static_cast(this) , int(total_milliseconds(clock_type::now() - m_unchoke_time)), t->num_have()); peer_log(peer_log_alert::info, "FILE_ASYNC_WRITE", "piece: %d s: %x l: %x" @@ -2977,7 +2986,7 @@ namespace libtorrent if (t->alerts().should_post()) { - t->alerts().emplace_alert(t->get_handle(), + t->alerts().emplace_alert(t->get_handle(), remote(), pid(), int(block_finished.block_index) , int(block_finished.piece_index)); } @@ -3111,7 +3120,8 @@ namespace libtorrent m_have_all = true; #ifndef TORRENT_DISABLE_LOGGING - peer_log(peer_log_alert::info, "SEED", "this is a seed p: %p", m_peer_info); + peer_log(peer_log_alert::info, "SEED", "this is a seed p: %p" + , static_cast(m_peer_info)); #endif t->set_seed(m_peer_info, true); @@ -3120,7 +3130,9 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING m_bitfield_time = clock_type::now(); - t->debug_log("HANDSHAKE [%p] (%d ms)", this, int(total_milliseconds(m_bitfield_time - m_connect_time))); + t->debug_log("HANDSHAKE [%p] (%d ms)" + , static_cast(this) + , int(total_milliseconds(m_bitfield_time - m_connect_time))); #endif // if we don't have metadata yet @@ -3140,7 +3152,7 @@ namespace libtorrent TORRENT_ASSERT(!m_have_piece.empty()); m_have_piece.set_all(); m_num_pieces = m_have_piece.size(); - + t->peer_has_all(this); #if TORRENT_USE_INVARIANT_CHECKS @@ -3192,12 +3204,14 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING m_bitfield_time = clock_type::now(); - t->debug_log("HANDSHAKE [%p] (%d ms)", this, int(total_milliseconds(m_bitfield_time - m_connect_time))); + t->debug_log("HANDSHAKE [%p] (%d ms)" + , static_cast(this) + , int(total_milliseconds(m_bitfield_time - m_connect_time))); #endif m_have_piece.clear_all(); m_num_pieces = 0; - // if the peer is ready to download stuff, it must have metadata + // if the peer is ready to download stuff, it must have metadata m_has_metadata = true; // we're never interested in a peer that doesn't have anything @@ -3222,7 +3236,9 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING { time_point now = clock_type::now(); - t->debug_log("ALLOW FAST [%p] (%d ms)", this, int(total_milliseconds(now - m_connect_time))); + t->debug_log("ALLOW FAST [%p] (%d ms)" + , static_cast(this) + , int(total_milliseconds(now - m_connect_time))); if (m_peer_choked) m_unchoke_time = now; } peer_log(peer_log_alert::incoming_message, "ALLOWED_FAST", "%d", index); @@ -3901,7 +3917,7 @@ namespace libtorrent // request timeout. m_requested = aux::time_now(); #ifndef TORRENT_DISABLE_LOGGING - t->debug_log("REQUEST [%p] (%d ms)", this + t->debug_log("REQUEST [%p] (%d ms)", static_cast(this) , int(total_milliseconds(clock_type::now() - m_unchoke_time))); #endif } @@ -5211,7 +5227,8 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING peer_log(peer_log_alert::info, "FILE_ASYNC_READ_COMPLETE" , "ret: %d piece: %d s: %x l: %x b: %p c: %s e: %s rtt: %d us" - , j->ret, r.piece, r.start, r.length, j->buffer.disk_block + , j->ret, r.piece, r.start, r.length + , static_cast(j->buffer.disk_block) , (j->flags & disk_io_job::cache_hit ? "cache hit" : "cache miss") , j->error.ec.message().c_str(), disk_rtt); #endif @@ -5229,7 +5246,7 @@ namespace libtorrent disconnect(j->error.ec, op_file_read); return; } - + TORRENT_ASSERT(j->buffer.disk_block == 0); write_dont_have(r.piece); write_reject_request(r); @@ -6225,7 +6242,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING { boost::shared_ptr t = m_torrent.lock(); - if (t) t->debug_log("END connect [%p]", this); + if (t) t->debug_log("END connect [%p]", static_cast(this)); m_connect_time = completed; } #endif @@ -6249,7 +6266,7 @@ namespace libtorrent } if (m_disconnecting) return; - + if (e) { connect_failed(e); diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index cb3b61fec..5ef500a02 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -3270,9 +3270,6 @@ get_out: // if we already have this piece, just ignore this if (have_piece(block.piece_index)) return false; -#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS - TORRENT_PIECE_PICKER_INVARIANT_CHECK; -#endif int prio = p.priority(this); TORRENT_ASSERT(prio < int(m_priority_boundries.size()) || m_dirty); diff --git a/src/rss.cpp b/src/rss.cpp index 943ee4f1f..d55f005a6 100644 --- a/src/rss.cpp +++ b/src/rss.cpp @@ -78,6 +78,7 @@ struct feed_state case rss2: return string_equal_no_case(tag, "item"); case none: return false; } + return false; } bool is_title(char const* tag) const @@ -88,6 +89,7 @@ struct feed_state case rss2: return string_equal_no_case(tag, "title"); case none: return false; } + return false; } bool is_url(char const* tag) const @@ -98,6 +100,7 @@ struct feed_state case rss2: return string_equal_no_case(tag, "link"); case none: return false; } + return false; } bool is_desc(char const* tag) const @@ -109,6 +112,7 @@ struct feed_state || string_equal_no_case(tag, "media:text"); case none: return false; } + return false; } bool is_uuid(char const* tag) const @@ -119,6 +123,7 @@ struct feed_state case rss2: return string_equal_no_case(tag, "guid"); case none: return false; } + return false; } bool is_comment(char const* tag) const @@ -129,6 +134,7 @@ struct feed_state case rss2: return string_equal_no_case(tag, "comments"); case none: return false; } + return false; } bool is_category(char const* tag) const @@ -139,6 +145,7 @@ struct feed_state case rss2: return string_equal_no_case(tag, "category"); case none: return false; } + return false; } bool is_size(char const* tag) const diff --git a/src/session.cpp b/src/session.cpp index a4ebd2fa0..97eb3627f 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -30,6 +30,10 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "libtorrent/config.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include @@ -37,17 +41,15 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include -#ifdef _MSC_VER -#pragma warning(pop) +#ifdef TORRENT_PROFILE_CALLS +#include #endif +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include "libtorrent/extensions/ut_pex.hpp" #include "libtorrent/extensions/ut_metadata.hpp" #include "libtorrent/extensions/smart_ban.hpp" @@ -75,10 +77,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/magnet_uri.hpp" #include "libtorrent/lazy_entry.hpp" -#ifdef TORRENT_PROFILE_CALLS -#include -#endif - using boost::shared_ptr; using boost::weak_ptr; using libtorrent::aux::session_impl; diff --git a/src/session_handle.cpp b/src/session_handle.cpp index d5e8ce1b2..23408fd08 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -838,6 +838,9 @@ namespace libtorrent return TORRENT_SYNC_CALL_RET(int, max_connections); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + std::auto_ptr session_handle::pop_alert() { alert const* a = m_impl->pop_alert(); @@ -845,6 +848,8 @@ namespace libtorrent return a->clone(); } +#pragma GCC diagnostic pop + void session_handle::pop_alerts(std::deque* alerts) { m_impl->pop_alerts(alerts); @@ -906,11 +911,16 @@ namespace libtorrent return get_settings().get_int(settings_pack::alert_mask); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + void session_handle::set_alert_dispatch(boost::function)> const& fun) { m_impl->alerts().set_dispatch_function(fun); } +#pragma GCC diagnostic pop + void session_handle::start_lsd() { settings_pack p; diff --git a/src/torrent.cpp b/src/torrent.cpp index c0b71692a..594df33bf 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2013,7 +2013,7 @@ namespace libtorrent if (num_pad_files > 0) m_picker->set_num_pad_files(num_pad_files); - std::auto_ptr > links; + std::vector links; #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS if (!m_torrent_file->similar_torrents().empty() || !m_torrent_file->collections().empty()) @@ -2055,7 +2055,6 @@ namespace libtorrent std::vector const& l = res.get_links(); if (!l.empty()) { - links.reset(new std::vector(l.size())); for (std::vector::const_iterator i = l.begin() , end(l.end()); i != end; ++i) { @@ -2063,7 +2062,7 @@ namespace libtorrent torrent_info const& ti = *i->ti; std::string const& save_path = i->save_path; - links->push_back(combine_path(save_path + links.push_back(combine_path(save_path , ti.files().file_path(i->file_idx))); } } @@ -2071,7 +2070,7 @@ namespace libtorrent #endif // TORRENT_DISABLE_MUTABLE_TORRENTS inc_refcount("check_fastresume"); - // async_check_fastresume will release links + // async_check_fastresume will gut links m_ses.disk_thread().async_check_fastresume( m_storage.get(), m_resume_data ? &m_resume_data->node : NULL , links, boost::bind(&torrent::on_resume_data_checked @@ -2601,7 +2600,7 @@ namespace libtorrent m_resume_data.reset(); - std::auto_ptr > links; + std::vector links; inc_refcount("force_recheck"); m_ses.disk_thread().async_check_fastresume(m_storage.get(), NULL , links, boost::bind(&torrent::on_force_recheck @@ -6483,7 +6482,8 @@ namespace libtorrent if (c->is_disconnecting()) return; #ifndef TORRENT_DISABLE_LOGGING - debug_log("START queue peer [%p] (%d)", c.get(), num_peers()); + debug_log("START queue peer [%p] (%d)", static_cast(c.get()) + , num_peers()); #endif } TORRENT_CATCH (std::exception& e) diff --git a/src/web_connection_base.cpp b/src/web_connection_base.cpp index 76dea2950..db96b35cf 100644 --- a/src/web_connection_base.cpp +++ b/src/web_connection_base.cpp @@ -30,11 +30,17 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "libtorrent/config.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include "libtorrent/web_connection_base.hpp" #include "libtorrent/session.hpp" #include "libtorrent/identify_client.hpp" diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index c8a5afae3..0965e1874 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -30,11 +30,17 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "libtorrent/config.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include "libtorrent/web_peer_connection.hpp" #include "libtorrent/session.hpp" #include "libtorrent/identify_client.hpp" diff --git a/test/test_bdecode.cpp b/test/test_bdecode.cpp index 2c7525a77..6652370de 100644 --- a/test/test_bdecode.cpp +++ b/test/test_bdecode.cpp @@ -732,7 +732,7 @@ TORRENT_TEST(parse_length_overflow) "d1:a9205357638345293824:11111", }; - for (int i = 0; i < sizeof(b)/sizeof(b[0]); ++i) + for (int i = 0; i < int(sizeof(b)/sizeof(b[0])); ++i) { error_code ec; bdecode_node e; diff --git a/test/test_bencoding.cpp b/test/test_bencoding.cpp index 8d687cb66..c9d369c22 100644 --- a/test/test_bencoding.cpp +++ b/test/test_bencoding.cpp @@ -599,7 +599,7 @@ TORRENT_TEST(bencoding) "d1:a9205357638345293824:11111", }; - for (int i = 0; i < sizeof(b)/sizeof(b[0]); ++i) + for (int i = 0; i < int(sizeof(b)/sizeof(b[0])); ++i) { lazy_entry e; error_code ec; diff --git a/test/test_block_cache.cpp b/test/test_block_cache.cpp index 519a02e8b..b28816b68 100644 --- a/test/test_block_cache.cpp +++ b/test/test_block_cache.cpp @@ -142,7 +142,7 @@ static void nop() {} rj.d.io.ref.storage = 0 #define FLUSH(flushing) \ - for (int i = 0; i < sizeof(flushing)/sizeof(flushing[0]); ++i) \ + for (int i = 0; i < int(sizeof(flushing)/sizeof(flushing[0])); ++i) \ { \ pe->blocks[flushing[i]].pending = true; \ bc.inc_block_refcount(pe, 0, block_cache::ref_flushing); \ diff --git a/test/test_dht.cpp b/test/test_dht.cpp index 912ff3243..49c7f9047 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -774,7 +774,7 @@ TORRENT_TEST(dht) { generate_next(), 8 } }; - for (int i = 0; i < sizeof(items)/sizeof(items[0]); ++i) + for (int i = 0; i < int(sizeof(items)/sizeof(items[0])); ++i) items[i].gen(); announce_immutable_items(node, eps, items, sizeof(items)/sizeof(items[0])); @@ -1729,7 +1729,7 @@ TORRENT_TEST(dht) TEST_EQUAL(g_got_items.front().value(), items[0].ent); TEST_CHECK(memcmp(g_got_items.front().pk().data(), public_key, item_pk_len) == 0); TEST_CHECK(memcmp(g_got_items.front().sig().data(), signature, item_sig_len) == 0); - TEST_EQUAL(g_got_items.front().seq(), seq); + TEST_EQUAL(int(g_got_items.front().seq()), seq); g_got_items.clear(); } while (false); diff --git a/test/test_file_progress.cpp b/test/test_file_progress.cpp index 1c3d76caf..da6e81298 100644 --- a/test/test_file_progress.cpp +++ b/test/test_file_progress.cpp @@ -70,7 +70,7 @@ TORRENT_TEST(init) for (int i = 0; i < int(vec.size()); ++i) sum += vec[i]; - TEST_EQUAL(sum, fs.piece_size(idx)); + TEST_EQUAL(int(sum), fs.piece_size(idx)); } } @@ -99,7 +99,7 @@ TORRENT_TEST(init2) fp.export_progress(vec); boost::uint64_t sum = 0; - for (int i = 0; i < vec.size(); ++i) + for (int i = 0; i < int(vec.size()); ++i) sum += vec[i]; TEST_EQUAL(int(sum), fs.piece_size(idx)); diff --git a/test/test_heterogeneous_queue.cpp b/test/test_heterogeneous_queue.cpp index 1cf201aff..32543121a 100644 --- a/test/test_heterogeneous_queue.cpp +++ b/test/test_heterogeneous_queue.cpp @@ -161,7 +161,7 @@ TORRENT_TEST(push_back) std::vector ptrs; q.get_pointers(ptrs); - TEST_EQUAL(ptrs.size(), q.size()); + TEST_EQUAL(int(ptrs.size()), q.size()); TEST_EQUAL(ptrs[0]->type(), 1); TEST_EQUAL(ptrs[1]->type(), 1); TEST_EQUAL(ptrs[2]->type(), 1); @@ -207,14 +207,14 @@ TORRENT_TEST(swap) std::vector ptrs; q1.get_pointers(ptrs); - TEST_EQUAL(ptrs.size(), q1.size()); + TEST_EQUAL(int(ptrs.size()), q1.size()); TEST_EQUAL(ptrs[0]->type(), 1); TEST_EQUAL(ptrs[1]->type(), 1); TEST_EQUAL(ptrs[2]->type(), 1); q2.get_pointers(ptrs); - TEST_EQUAL(ptrs.size(), q2.size()); + TEST_EQUAL(int(ptrs.size()), q2.size()); TEST_EQUAL(ptrs[0]->type(), 2); TEST_EQUAL(ptrs[1]->type(), 2); @@ -223,14 +223,14 @@ TORRENT_TEST(swap) q1.get_pointers(ptrs); TEST_EQUAL(q1.size(), 2); - TEST_EQUAL(ptrs.size(), q1.size()); + TEST_EQUAL(int(ptrs.size()), q1.size()); TEST_EQUAL(ptrs[0]->type(), 2); TEST_EQUAL(ptrs[1]->type(), 2); q2.get_pointers(ptrs); TEST_EQUAL(q2.size(), 3); - TEST_EQUAL(ptrs.size(), q2.size()); + TEST_EQUAL(int(ptrs.size()), q2.size()); TEST_EQUAL(ptrs[0]->type(), 1); TEST_EQUAL(ptrs[1]->type(), 1); @@ -274,9 +274,9 @@ TORRENT_TEST(copy_move) std::vector ptrs; q.get_pointers(ptrs); - TEST_EQUAL(ptrs.size(), 1000); + TEST_EQUAL(int(ptrs.size()), 1000); - for (int i = 0; i < ptrs.size(); ++i) + for (int i = 0; i < int(ptrs.size()); ++i) { ptrs[i]->check_invariant(); TEST_EQUAL(ptrs[i]->f, i); diff --git a/test/test_http_parser.cpp b/test/test_http_parser.cpp index 1727fd62a..a7c2fb465 100644 --- a/test/test_http_parser.cpp +++ b/test/test_http_parser.cpp @@ -68,7 +68,7 @@ tuple feed_bytes(http_parser& parser, char const* str) TEST_CHECK(prev == make_tuple(0, 0, false) || ret == prev || ret.get<2>()); if (!ret.get<2>()) { - TEST_EQUAL(ret.get<0>() + ret.get<1>(), strlen(str)); + TEST_EQUAL(ret.get<0>() + ret.get<1>(), int(strlen(str))); } prev = ret; @@ -227,7 +227,7 @@ TORRENT_TEST(http_parser) received = feed_bytes(parser, chunked_test); printf("payload: %d protocol: %d\n", received.get<0>(), received.get<1>()); - TEST_CHECK(received == make_tuple(20, strlen(chunked_test) - 20, false)); + TEST_CHECK(received == make_tuple(20, int(strlen(chunked_test)) - 20, false)); TEST_CHECK(parser.finished()); TEST_CHECK(std::equal(parser.get_body().begin, parser.get_body().end , "4\r\ntest\r\n10\r\n0123456789abcdef")); diff --git a/test/test_ip_filter.cpp b/test/test_ip_filter.cpp index 06d200483..29aa50ea3 100644 --- a/test/test_ip_filter.cpp +++ b/test/test_ip_filter.cpp @@ -83,8 +83,8 @@ void test_rules_invariant(std::vector > const& r, ip_filter const& f for (iterator i(r.begin()), j(boost::next(r.begin())) , end(r.end()); j != end; ++j, ++i) { - TEST_CHECK(f.access(i->last) == i->flags); - TEST_CHECK(f.access(j->first) == j->flags); + TEST_EQUAL(f.access(i->last), int(i->flags)); + TEST_EQUAL(f.access(j->first), int(j->flags)); TEST_CHECK(detail::plus_one(i->last.to_bytes()) == j->first.to_bytes()); } } @@ -261,7 +261,7 @@ TORRENT_TEST(ip_filter) range = boost::get<1>(f.export_filter()); test_rules_invariant(range, f); - TEST_CHECK(range.size() == 3); + TEST_EQUAL(range.size(), 3); TEST_CHECK(std::equal(range.begin(), range.end(), expected2, &compare)); } diff --git a/test/test_piece_picker.cpp b/test/test_piece_picker.cpp index 4aa005f2f..e3671d5d9 100644 --- a/test/test_piece_picker.cpp +++ b/test/test_piece_picker.cpp @@ -36,6 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/performance_counters.hpp" #include "libtorrent/random.hpp" +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include @@ -44,6 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include "test.hpp" using namespace libtorrent; @@ -97,7 +101,7 @@ boost::shared_ptr setup_picker( { const int avail = availability[i] - '0'; assert(avail >= 0); - + static const torrent_peer* peers[10] = { &tmp0, &tmp1, &tmp2 , &tmp3, &tmp4, &tmp5, &tmp6, &tmp7, &tmp8, &tmp9 }; TORRENT_ASSERT(avail < 10); @@ -141,12 +145,12 @@ boost::shared_ptr setup_picker( piece_picker::downloading_piece st; p->piece_info(i, st); - TEST_CHECK(st.writing == 0); - TEST_CHECK(st.requested == 0); - TEST_CHECK(st.index == i); + TEST_EQUAL(int(st.writing), 0); + TEST_EQUAL(int(st.requested), 0); + TEST_EQUAL(int(st.index), i); - TEST_CHECK(st.finished == counter); - TEST_CHECK(st.finished + st.requested + st.writing == counter); + TEST_EQUAL(st.finished, counter); + TEST_EQUAL(st.finished + st.requested + st.writing, counter); TEST_CHECK(p->is_piece_finished(i) == (counter == 4)); } @@ -1774,11 +1778,14 @@ TORRENT_TEST(piece_picker) TEST_EQUAL(downloads.size(), 3); TEST_CHECK(std::find_if(downloads.begin(), downloads.end() - , boost::bind(&piece_picker::downloading_piece::index, _1) == 1) != downloads.end()); + , boost::bind(&piece_picker::downloading_piece::index, _1) + == boost::uint32_t(1)) != downloads.end()); TEST_CHECK(std::find_if(downloads.begin(), downloads.end() - , boost::bind(&piece_picker::downloading_piece::index, _1) == 2) != downloads.end()); + , boost::bind(&piece_picker::downloading_piece::index, _1) + == boost::uint32_t(2)) != downloads.end()); TEST_CHECK(std::find_if(downloads.begin(), downloads.end() - , boost::bind(&piece_picker::downloading_piece::index, _1) == 3) != downloads.end()); + , boost::bind(&piece_picker::downloading_piece::index, _1) + == boost::uint32_t(3)) != downloads.end()); // ======================================================== diff --git a/test/test_resolve_links.cpp b/test/test_resolve_links.cpp index abfd57c3e..c2f23c934 100644 --- a/test/test_resolve_links.cpp +++ b/test/test_resolve_links.cpp @@ -90,7 +90,7 @@ TORRENT_TEST(resolve_links) std::string path = combine_path(parent_path(current_working_directory()) , "mutable_test_torrents"); - for (int i = 0; i < sizeof(test_torrents)/sizeof(test_torrents[0]); ++i) + for (int i = 0; i < int(sizeof(test_torrents)/sizeof(test_torrents[0])); ++i) { test_torrent_t const& e = test_torrents[i]; @@ -115,7 +115,7 @@ TORRENT_TEST(resolve_links) if (num_matches > e.expected_matches) { file_storage const& fs = ti1->files(); - for (int i = 0; i < links.size(); ++i) + for (int i = 0; i < int(links.size()); ++i) { TORRENT_ASSERT(i < fs.num_files()); fprintf(stderr, "%s --> %s : %d\n", fs.file_name(i).c_str() diff --git a/test/test_resume.cpp b/test/test_resume.cpp index c53e4503c..214437f6b 100644 --- a/test/test_resume.cpp +++ b/test/test_resume.cpp @@ -209,7 +209,7 @@ TORRENT_TEST(piece_priorities) { fprintf(stderr, "%s\n", ra->resume_data->to_string().c_str()); entry::string_type prios = (*ra->resume_data)["piece_priority"].string(); - TEST_EQUAL(prios.size(), ti->num_pieces()); + TEST_EQUAL(int(prios.size()), ti->num_pieces()); TEST_EQUAL(prios[0], '\0'); TEST_EQUAL(prios[1], '\x04'); TEST_EQUAL(prios[ti->num_pieces()-1], '\0'); diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 3b830883f..657626625 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -463,7 +463,7 @@ void test_check_files(std::string const& test_path bool done = false; bdecode_node frd; - std::auto_ptr > links; + std::vector links; io.async_check_fastresume(pm.get(), &frd, links , boost::bind(&on_check_resume_data, _1, &done)); io.submit_jobs(); diff --git a/test/test_threads.cpp b/test/test_threads.cpp index 7a2d1e295..5c9475d92 100644 --- a/test/test_threads.cpp +++ b/test/test_threads.cpp @@ -30,9 +30,14 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include #include #include + +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #include "libtorrent/thread.hpp" #include "test.hpp" #include "setup_transfer.hpp" // for test_sleep diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 2f62bb333..b32b370bc 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -112,7 +112,7 @@ void test_running_torrent(boost::shared_ptr info, boost::int64_t f TEST_EQUAL(st.total_wanted_done, 0); if (!st.is_seeding) { - TEST_EQUAL(h.file_priorities().size(), info->num_files()); + TEST_EQUAL(int(h.file_priorities().size()), info->num_files()); TEST_EQUAL(h.file_priorities()[0], 0); if (info->num_files() > 1) TEST_EQUAL(h.file_priorities()[1], 0);