diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index ac1f2eda3..a44104efd 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -1822,7 +1822,7 @@ namespace libtorrent add_torrent_alert(aux::stack_allocator& alloc, torrent_handle h , add_torrent_params const& p, error_code ec); - TORRENT_DEFINE_ALERT_PRIO(add_torrent_alert, 67); + TORRENT_DEFINE_ALERT_PRIO(add_torrent_alert, 67) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1845,9 +1845,8 @@ namespace libtorrent // filtering, since it's only manually posted anyway. struct TORRENT_EXPORT state_update_alert : alert { - state_update_alert(aux::stack_allocator& alloc, std::vector st) - : status(st) - {} + state_update_alert(aux::stack_allocator& alloc + , std::vector st); TORRENT_DEFINE_ALERT_PRIO(state_update_alert, 68) @@ -1868,7 +1867,7 @@ namespace libtorrent struct TORRENT_EXPORT mmap_cache_alert : alert { mmap_cache_alert(aux::stack_allocator& alloc - , error_code const& ec): error(ec) {} + , error_code const& ec); TORRENT_DEFINE_ALERT(mmap_cache_alert, 69) static const int static_category = alert::error_notification; @@ -2093,11 +2092,7 @@ namespace libtorrent // internal dht_outgoing_get_peers_alert(aux::stack_allocator& alloc , sha1_hash const& ih, sha1_hash const& obfih - , udp::endpoint ep) - : info_hash(ih) - , obfuscated_info_hash(obfih) - , ip(ep) - {} + , udp::endpoint ep); TORRENT_DEFINE_ALERT(dht_outgoing_get_peers_alert, 78) @@ -2187,10 +2182,7 @@ namespace libtorrent struct TORRENT_EXPORT lsd_error_alert : alert { // internal - lsd_error_alert(aux::stack_allocator& alloc, error_code const& ec) - : alert() - , error(ec) - {} + lsd_error_alert(aux::stack_allocator& alloc, error_code const& ec); TORRENT_DEFINE_ALERT(lsd_error_alert, 82) @@ -2264,11 +2256,7 @@ namespace libtorrent // internal dht_stats_alert(aux::stack_allocator& alloc , std::vector const& table - , std::vector const& requests) - : alert() - , active_requests(requests) - , routing_table(table) - {} + , std::vector const& requests); TORRENT_DEFINE_ALERT(dht_stats_alert, 83) diff --git a/include/libtorrent/broadcast_socket.hpp b/include/libtorrent/broadcast_socket.hpp index d1c39e284..4dbf6789a 100644 --- a/include/libtorrent/broadcast_socket.hpp +++ b/include/libtorrent/broadcast_socket.hpp @@ -38,10 +38,15 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket.hpp" #include "libtorrent/address.hpp" #include "libtorrent/error_code.hpp" + +#include "aux_/disable_warnings_push.hpp" + #include #include #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 1f55a0d57..97f94981b 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISK_IO_THREAD #define TORRENT_DISK_IO_THREAD +#include "libtorrent/config.hpp" #include "libtorrent/storage.hpp" #include "libtorrent/allocator.hpp" #include "libtorrent/io_service.hpp" @@ -43,6 +44,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/file_pool.hpp" #include "libtorrent/disk_interface.hpp" #include "libtorrent/performance_counters.hpp" +#include "libtorrent/aux_/session_settings.hpp" +#include "libtorrent/thread.hpp" + +#include "aux_/disable_warnings_push.hpp" #include #include @@ -50,14 +55,13 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "libtorrent/config.hpp" #ifndef TORRENT_DISABLE_POOL_ALLOCATOR #include #endif -#include "libtorrent/aux_/session_settings.hpp" -#include "libtorrent/thread.hpp" #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { class alert; diff --git a/include/libtorrent/kademlia/find_data.hpp b/include/libtorrent/kademlia/find_data.hpp index 45a7ad307..d25347145 100644 --- a/include/libtorrent/kademlia/find_data.hpp +++ b/include/libtorrent/kademlia/find_data.hpp @@ -33,9 +33,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef FIND_DATA_050323_HPP #define FIND_DATA_050323_HPP -#include -#include - #include #include #include @@ -43,10 +40,17 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "aux_/disable_warnings_push.hpp" + +#include +#include + #include #include #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { namespace dht { diff --git a/include/libtorrent/kademlia/observer.hpp b/include/libtorrent/kademlia/observer.hpp index 2923046ba..2e9b6c403 100644 --- a/include/libtorrent/kademlia/observer.hpp +++ b/include/libtorrent/kademlia/observer.hpp @@ -33,12 +33,17 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef OBSERVER_HPP #define OBSERVER_HPP +#include +#include + +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include -#include -#include + +#include "aux_/disable_warnings_pop.hpp" namespace libtorrent { namespace dht { diff --git a/include/libtorrent/natpmp.hpp b/include/libtorrent/natpmp.hpp index 0d8dc0eab..edaaba247 100644 --- a/include/libtorrent/natpmp.hpp +++ b/include/libtorrent/natpmp.hpp @@ -40,10 +40,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/deadline_timer.hpp" +#include "aux_/disable_warnings_push.hpp" + #include #include #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 5d51159ac..9fd166583 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -764,7 +764,8 @@ namespace libtorrent virtual void on_sent(error_code const& error , std::size_t bytes_transferred) = 0; - virtual int hit_send_barrier(std::vector& iovec) { return INT_MAX; } + virtual int hit_send_barrier(std::vector&) + { return INT_MAX; } bool allocate_disk_receive_buffer(int disk_buffer_size); diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 774d03b08..d6747090a 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -461,10 +461,10 @@ namespace libtorrent // functor that compares indices on downloading_pieces struct has_index { - has_index(int i): index(i) { TORRENT_ASSERT(i >= 0); } + has_index(int i): index(boost::uint32_t(i)) { TORRENT_ASSERT(i >= 0); } bool operator()(const downloading_piece& p) const { return p.index == index; } - int index; + boost::uint32_t index; }; int blocks_in_last_piece() const diff --git a/include/libtorrent/proxy_base.hpp b/include/libtorrent/proxy_base.hpp index 00cde6e8a..fc8b2c144 100644 --- a/include/libtorrent/proxy_base.hpp +++ b/include/libtorrent/proxy_base.hpp @@ -38,7 +38,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket.hpp" #include "libtorrent/address.hpp" #include "libtorrent/error_code.hpp" + +#include "aux_/disable_warnings_push.hpp" #include +#include "aux_/disable_warnings_pop.hpp" namespace libtorrent { diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index f1568b079..d99cb2d00 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -200,8 +200,7 @@ namespace libtorrent // used as the peer-id peer_fingerprint, - max_string_setting_internal, - num_string_settings = max_string_setting_internal - string_type_base + max_string_setting_internal }; enum bool_types @@ -650,8 +649,7 @@ namespace libtorrent // unlikely to matter anyway auto_sequential, - max_bool_setting_internal, - num_bool_settings = max_bool_setting_internal - bool_type_base + max_bool_setting_internal }; enum int_types @@ -1512,8 +1510,13 @@ namespace libtorrent // .. _i2p: http://www.i2p2.de i2p_port, - max_int_setting_internal, + max_int_setting_internal + }; + enum settings_counts_t + { + num_string_settings = max_string_setting_internal - string_type_base, + num_bool_settings = max_bool_setting_internal - bool_type_base, num_int_settings = max_int_setting_internal - int_type_base }; diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index 35cfeb8f9..7d9bbde6c 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -107,13 +107,13 @@ namespace libtorrent explicit sha1_hash(std::string const& s) { TORRENT_ASSERT(s.size() >= 20); - int sl = int(s.size()) < size ? int(s.size()) : size; + size_t sl = s.size() < size_t(size) ? s.size() : size_t(size); std::memcpy(m_number, s.c_str(), sl); } void assign(std::string const& s) { TORRENT_ASSERT(s.size() >= 20); - int sl = int(s.size()) < size ? int(s.size()) : size; + size_t sl = s.size() < size_t(size) ? s.size() : size_t(size); std::memcpy(m_number, s.c_str(), sl); } void assign(char const* str) { std::memcpy(m_number, str, size); } @@ -133,7 +133,7 @@ namespace libtorrent sha1_hash& operator<<=(int n) { TORRENT_ASSERT(n >= 0); - int num_words = n / 32; + const size_t num_words = size_t(n) / 32; if (num_words >= number_size) { std::memset(m_number, 0, size); @@ -172,10 +172,10 @@ namespace libtorrent sha1_hash& operator>>=(int n) { TORRENT_ASSERT(n >= 0); - int num_words = n / 32; + const size_t num_words = size_t(n) / 32; if (num_words >= number_size) { - std::memset(m_number, 0, size); + std::memset(m_number, 0, size_t(size)); return *this; } if (num_words > 0) @@ -305,7 +305,10 @@ namespace libtorrent // return a copy of the 20 bytes representing the sha1-hash as a std::string. // It's still a binary string with 20 binary characters. std::string to_string() const - { return std::string(reinterpret_cast(&m_number[0]), size); } + { + return std::string(reinterpret_cast(&m_number[0]) + , size_t(size)); + } private: diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 5af1407ee..c73b3425b 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -526,7 +526,7 @@ namespace libtorrent , int offset, int flags, storage_error& ec); bool verify_resume_data(bdecode_node const& - , std::vector const* links + , std::vector const* , storage_error&) { return false; } void write_resume_data(entry&, storage_error&) const {} diff --git a/include/libtorrent/tailqueue.hpp b/include/libtorrent/tailqueue.hpp index 85bc7596e..84ce6bfe3 100644 --- a/include/libtorrent/tailqueue.hpp +++ b/include/libtorrent/tailqueue.hpp @@ -47,7 +47,7 @@ namespace libtorrent inline N* postinc(N*& e) { N* ret = e; - e = (N*)ret->next; + e = static_cast(ret->next); return ret; } diff --git a/include/libtorrent/torrent_peer_allocator.hpp b/include/libtorrent/torrent_peer_allocator.hpp index e10eb9c37..70091abb0 100644 --- a/include/libtorrent/torrent_peer_allocator.hpp +++ b/include/libtorrent/torrent_peer_allocator.hpp @@ -36,8 +36,12 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/torrent_peer.hpp" +#include "aux_/disable_warnings_push.hpp" + #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { diff --git a/src/alert.cpp b/src/alert.cpp index f73a40340..827286683 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -846,7 +846,7 @@ namespace libtorrent { } udp_error_alert::udp_error_alert( - aux::stack_allocator& alloc + aux::stack_allocator& , udp::endpoint const& ep , error_code const& ec) : endpoint(ep) @@ -859,7 +859,7 @@ namespace libtorrent { return "UDP error: " + convert_from_native(error.message()) + " from: " + endpoint.address().to_string(ec); } - external_ip_alert::external_ip_alert(aux::stack_allocator& alloc + external_ip_alert::external_ip_alert(aux::stack_allocator& , address const& ip) : external_address(ip) {} @@ -870,7 +870,7 @@ namespace libtorrent { return "external IP received: " + external_address.to_string(ec); } - listen_succeeded_alert::listen_succeeded_alert(aux::stack_allocator& alloc + listen_succeeded_alert::listen_succeeded_alert(aux::stack_allocator& , tcp::endpoint const& ep, socket_type_t t) : endpoint(ep) , sock_type(t) @@ -884,7 +884,7 @@ namespace libtorrent { return ret; } - portmap_error_alert::portmap_error_alert(aux::stack_allocator& alloc + portmap_error_alert::portmap_error_alert(aux::stack_allocator& , int i, int t, error_code const& e) : mapping(i), map_type(t), error(e) { @@ -899,7 +899,7 @@ namespace libtorrent { + ": " + convert_from_native(error.message()); } - portmap_alert::portmap_alert(aux::stack_allocator& alloc, int i, int port, int t) + portmap_alert::portmap_alert(aux::stack_allocator&, int i, int port, int t) : mapping(i), external_port(port), map_type(t) {} @@ -993,7 +993,7 @@ namespace libtorrent { return ret; } - dht_announce_alert::dht_announce_alert(aux::stack_allocator& alloc + dht_announce_alert::dht_announce_alert(aux::stack_allocator& , address const& i, int p , sha1_hash const& ih) : ip(i) @@ -1012,7 +1012,7 @@ namespace libtorrent { return msg; } - dht_get_peers_alert::dht_get_peers_alert(aux::stack_allocator& alloc + dht_get_peers_alert::dht_get_peers_alert(aux::stack_allocator& , sha1_hash const& ih) : info_hash(ih) {} @@ -1134,7 +1134,7 @@ namespace libtorrent { return std::string("trackerid received: ") + tracker_id(); } - dht_bootstrap_alert::dht_bootstrap_alert(aux::stack_allocator& alloc) + dht_bootstrap_alert::dht_bootstrap_alert(aux::stack_allocator&) {} std::string dht_bootstrap_alert::message() const @@ -1143,7 +1143,7 @@ namespace libtorrent { } #ifndef TORRENT_NO_DEPRECATE - rss_alert::rss_alert(aux::stack_allocator& alloc, feed_handle h + rss_alert::rss_alert(aux::stack_allocator&, feed_handle h , std::string const& u, int s, error_code const& ec) : handle(h), url(u), state(s), error(ec) {} @@ -1208,7 +1208,7 @@ namespace libtorrent { return torrent_alert::message() + " needs SSL certificate"; } - incoming_connection_alert::incoming_connection_alert(aux::stack_allocator& alloc, int t + incoming_connection_alert::incoming_connection_alert(aux::stack_allocator&, int t , tcp::endpoint const& i) : socket_type(t) , ip(i) @@ -1268,6 +1268,11 @@ namespace libtorrent { return msg; } + state_update_alert::state_update_alert(aux::stack_allocator& + , std::vector st) + : status(st) + {} + std::string state_update_alert::message() const { char msg[600]; @@ -1275,6 +1280,10 @@ namespace libtorrent { return msg; } + mmap_cache_alert::mmap_cache_alert(aux::stack_allocator& + , error_code const& ec): error(ec) + {} + std::string mmap_cache_alert::message() const { char msg[600]; @@ -1327,7 +1336,7 @@ namespace libtorrent { "get_interface", }; - if (op < 0 || op >= sizeof(names)/sizeof(names[0])) + if (op < 0 || op >= int(sizeof(names)/sizeof(names[0]))) return "unknown operation"; return names[op]; @@ -1350,7 +1359,7 @@ namespace libtorrent { } #ifndef TORRENT_NO_DEPRECATE - rss_item_alert::rss_item_alert(aux::stack_allocator& alloc, feed_handle h + rss_item_alert::rss_item_alert(aux::stack_allocator&, feed_handle h , feed_item const& item) : handle(h) , item(item) @@ -1393,7 +1402,8 @@ namespace libtorrent { return msg; } - dht_error_alert::dht_error_alert(aux::stack_allocator& alloc, int op, error_code const& ec) + dht_error_alert::dht_error_alert(aux::stack_allocator&, int op + , error_code const& ec) : error(ec), operation(op_t(op)) {} @@ -1417,7 +1427,7 @@ namespace libtorrent { return msg; } - dht_immutable_item_alert::dht_immutable_item_alert(aux::stack_allocator& alloc + dht_immutable_item_alert::dht_immutable_item_alert(aux::stack_allocator& , sha1_hash const& t, entry const& i) : target(t), item(i) {} @@ -1431,7 +1441,9 @@ namespace libtorrent { return msg; } - dht_mutable_item_alert::dht_mutable_item_alert(aux::stack_allocator& alloc + // TODO: 2 the salt here is allocated on the heap. It would be nice to + // allocate in in the stack_allocator + dht_mutable_item_alert::dht_mutable_item_alert(aux::stack_allocator& , boost::array k , boost::array sig , boost::uint64_t sequence @@ -1451,12 +1463,12 @@ namespace libtorrent { return msg; } - dht_put_alert::dht_put_alert(aux::stack_allocator& alloc, sha1_hash const& t) + dht_put_alert::dht_put_alert(aux::stack_allocator&, sha1_hash const& t) : target(t) , seq(0) {} - dht_put_alert::dht_put_alert(aux::stack_allocator& alloc + dht_put_alert::dht_put_alert(aux::stack_allocator& , boost::array key , boost::array sig , std::string s @@ -1479,7 +1491,7 @@ namespace libtorrent { return msg; } - i2p_alert::i2p_alert(aux::stack_allocator& alloc, error_code const& ec) + i2p_alert::i2p_alert(aux::stack_allocator&, error_code const& ec) : error(ec) {} @@ -1491,6 +1503,14 @@ namespace libtorrent { return msg; } + dht_outgoing_get_peers_alert::dht_outgoing_get_peers_alert(aux::stack_allocator& + , sha1_hash const& ih, sha1_hash const& obfih + , udp::endpoint ep) + : info_hash(ih) + , obfuscated_info_hash(obfih) + , ip(ep) + {} + std::string dht_outgoing_get_peers_alert::message() const { char msg[600]; @@ -1556,6 +1576,11 @@ namespace libtorrent { return torrent_alert::message() + " [" + print_endpoint(ip) + "] " + msg(); } + lsd_error_alert::lsd_error_alert(aux::stack_allocator&, error_code const& ec) + : alert() + , error(ec) + {} + std::string lsd_error_alert::message() const { return "Local Service Discovery error: " + error.message(); @@ -1574,6 +1599,14 @@ namespace libtorrent { return msg; } + dht_stats_alert::dht_stats_alert(aux::stack_allocator& + , std::vector const& table + , std::vector const& requests) + : alert() + , active_requests(requests) + , routing_table(table) + {} + std::string dht_stats_alert::message() const { char buf[2048]; diff --git a/src/file.cpp b/src/file.cpp index d145c9308..6bed7baa4 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1590,6 +1590,8 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { // defined in storage.cpp int bufs_size(file::iovec_t const* bufs, int num_bufs); + namespace { + void gather_copy(file::iovec_t const* bufs, int num_bufs, char* dst) { int offset = 0; @@ -1741,6 +1743,8 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { #endif } + } // anonymous namespace + // this has to be thread safe and atomic. i.e. on posix systems it has to be // turned into a series of pread() calls boost::int64_t file::readv(boost::int64_t file_offset, iovec_t const* bufs, int num_bufs