diff --git a/Jamfile b/Jamfile index 734e26bf2..d5ff64c2d 100755 --- a/Jamfile +++ b/Jamfile @@ -240,6 +240,7 @@ rule warnings ( properties * ) result += -Wno-exit-time-destructors ; result += -Wno-documentation-unknown-command ; result += -Wno-disabled-macro-expansion ; + result += -Wno-weak-vtables ; } if gcc in $(properties) diff --git a/include/libtorrent/alert_manager.hpp b/include/libtorrent/alert_manager.hpp index 9aa6df7a6..da91a85d2 100644 --- a/include/libtorrent/alert_manager.hpp +++ b/include/libtorrent/alert_manager.hpp @@ -46,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include #include +#include #include #include // for std::forward @@ -67,7 +68,7 @@ namespace libtorrent { , boost::uint32_t alert_mask = alert::error_notification); ~alert_manager(); -#if __cplusplus >= 201103L +#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES template void emplace_alert(Args&&... args) diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index c4cba067e..311163458 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -119,6 +119,8 @@ namespace libtorrent { namespace aux virtual bool any_torrent_has_peer(peer_connection const* p) const = 0; virtual bool is_posting_torrent_updates() const = 0; #endif + protected: + ~session_logger() {} }; #endif // TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS @@ -336,6 +338,8 @@ namespace libtorrent { namespace aux virtual counters& stats_counters() = 0; virtual void received_buffer(int size) = 0; virtual void sent_buffer(int size) = 0; + protected: + ~session_interface() {} }; }} diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 548025b6b..f946f2774 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -402,12 +402,25 @@ int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_EXCEPTION_THROW_SPECIFIER _GLIBCXX_USE_NOEXCEPT #else -#if __cplusplus > 199711L && defined BOOST_NO_CXX11_NOEXCEPT +#if __cplusplus <= 199711L || defined BOOST_NO_CXX11_NOEXCEPT #define TORRENT_EXCEPTION_THROW_SPECIFIER throw() #else #define TORRENT_EXCEPTION_THROW_SPECIFIER noexcept #endif +#if __cplusplus <= 199711L || defined BOOST_NO_CXX11_FINAL +#define TORRENT_FINAL +#else +#define TORRENT_FINAL final +#endif + +#if __cplusplus <= 199711L +#define TORRENT_OVERRIDE +#else +#define TORRENT_OVERRIDE override +#endif + + #endif // __GLIBC__ #ifndef TORRENT_ICONV_ARG diff --git a/include/libtorrent/disk_buffer_holder.hpp b/include/libtorrent/disk_buffer_holder.hpp index caf47a318..b7d23937a 100644 --- a/include/libtorrent/disk_buffer_holder.hpp +++ b/include/libtorrent/disk_buffer_holder.hpp @@ -55,6 +55,8 @@ namespace libtorrent , char const* category) = 0; virtual char* async_allocate_disk_buffer(char const* category , boost::function const& handler) = 0; + protected: + ~buffer_allocator_interface() {} }; // The disk buffer holder acts like a ``scoped_ptr`` that frees a disk buffer diff --git a/include/libtorrent/disk_interface.hpp b/include/libtorrent/disk_interface.hpp index 74b73d224..95f5c15f4 100644 --- a/include/libtorrent/disk_interface.hpp +++ b/include/libtorrent/disk_interface.hpp @@ -110,6 +110,8 @@ namespace libtorrent #if TORRENT_USE_ASSERTS virtual bool is_disk_buffer(char* buffer) const = 0; #endif + protected: + ~disk_interface() {} }; } diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 97f94981b..5cd82caf8 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -279,7 +279,7 @@ namespace libtorrent // this is a singleton consisting of the thread and a queue // of disk io jobs - struct TORRENT_EXTRA_EXPORT disk_io_thread + struct TORRENT_EXTRA_EXPORT disk_io_thread TORRENT_FINAL : disk_job_pool , disk_interface , buffer_allocator_interface diff --git a/include/libtorrent/disk_observer.hpp b/include/libtorrent/disk_observer.hpp index 8ef452253..e82f0fd41 100644 --- a/include/libtorrent/disk_observer.hpp +++ b/include/libtorrent/disk_observer.hpp @@ -43,6 +43,8 @@ namespace libtorrent // below the low watermark again and we can // resume downloading from peers virtual void on_disk() = 0; + protected: + ~disk_observer() {} }; } diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index ebfafb943..6e84cef7e 100644 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -58,22 +58,26 @@ POSSIBILITY OF SUCH DAMAGE. * */ +#include "libtorrent/config.hpp" + +#include "aux_/disable_warnings_push.hpp" #include #include #include #include #include - -#include "libtorrent/config.hpp" -#include "libtorrent/assert.hpp" -#include "libtorrent/error_code.hpp" -#include "libtorrent/max.hpp" - +#include #if TORRENT_USE_IOSTREAM #include #endif +#include "aux_/disable_warnings_pop.hpp" + +#include "libtorrent/assert.hpp" +#include "libtorrent/error_code.hpp" +#include "libtorrent/max.hpp" + namespace libtorrent { #ifndef TORRENT_NO_DEPRECATE @@ -303,7 +307,7 @@ namespace libtorrent #ifndef BOOST_NO_EXCEPTIONS // internal - TORRENT_NO_RETURN inline void throw_type_error() + BOOST_NORETURN inline void throw_type_error() { throw libtorrent_exception(error_code(errors::invalid_entry_type , get_libtorrent_category())); diff --git a/include/libtorrent/kademlia/dht_observer.hpp b/include/libtorrent/kademlia/dht_observer.hpp index 1e21c36bf..f5dc6437e 100644 --- a/include/libtorrent/kademlia/dht_observer.hpp +++ b/include/libtorrent/kademlia/dht_observer.hpp @@ -46,6 +46,8 @@ namespace libtorrent { namespace dht virtual void outgoing_get_peers(sha1_hash const& target , sha1_hash const& sent_target, udp::endpoint const& ep) = 0; virtual void announce(sha1_hash const& ih, address const& addr, int port) = 0; + protected: + ~dht_observer() {} }; }} diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index b49bcd67a..55f105902 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -189,6 +189,8 @@ struct udp_socket_interface { virtual bool has_quota() = 0; virtual bool send_packet(entry& e, udp::endpoint const& addr, int flags) = 0; +protected: + ~udp_socket_interface() {} }; class TORRENT_EXTRA_EXPORT node_impl : boost::noncopyable diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 9fd166583..6b35ed764 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -336,7 +336,7 @@ namespace libtorrent // this is called when the metadata is retrieved // and the files has been checked - virtual void on_metadata() {}; + virtual void on_metadata() {} void on_metadata_impl(); diff --git a/include/libtorrent/peer_connection_interface.hpp b/include/libtorrent/peer_connection_interface.hpp index 9cfd0f5cf..9d9060381 100644 --- a/include/libtorrent/peer_connection_interface.hpp +++ b/include/libtorrent/peer_connection_interface.hpp @@ -65,6 +65,8 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING virtual void peer_log(char const* fmt, ...) const = 0; #endif + protected: + ~peer_connection_interface() {} }; } diff --git a/include/libtorrent/resolver.hpp b/include/libtorrent/resolver.hpp index 2c998dbe1..690039c5d 100644 --- a/include/libtorrent/resolver.hpp +++ b/include/libtorrent/resolver.hpp @@ -51,7 +51,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -struct TORRENT_EXTRA_EXPORT resolver : resolver_interface +struct TORRENT_EXTRA_EXPORT resolver TORRENT_FINAL : resolver_interface { resolver(io_service& ios); diff --git a/include/libtorrent/resolver_interface.hpp b/include/libtorrent/resolver_interface.hpp index 70a6bd916..d678b489c 100644 --- a/include/libtorrent/resolver_interface.hpp +++ b/include/libtorrent/resolver_interface.hpp @@ -64,6 +64,8 @@ struct resolver_interface , callback_t const& h) = 0; virtual void abort() = 0; +protected: + ~resolver_interface() {} }; } diff --git a/include/libtorrent/ssl_stream.hpp b/include/libtorrent/ssl_stream.hpp index bb63788bd..9eaa25327 100644 --- a/include/libtorrent/ssl_stream.hpp +++ b/include/libtorrent/ssl_stream.hpp @@ -36,6 +36,12 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef TORRENT_USE_OPENSSL #include "libtorrent/socket.hpp" +#include "libtorrent/error_code.hpp" +#include "libtorrent/io_service.hpp" + +#include "aux_/disable_warnings_push.hpp" + +#include #include #if BOOST_VERSION < 103500 #include @@ -46,6 +52,8 @@ POSSIBILITY OF SUCH DAMAGE. // this name in every single scope #undef set_key +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { template diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 0913ec7c8..1c7a98a0a 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -696,14 +696,14 @@ namespace libtorrent tracker_request const& r , address const& tracker_ip , std::list
const& ip_list - , struct tracker_response const& resp); + , struct tracker_response const& resp) TORRENT_OVERRIDE; virtual void tracker_request_error(tracker_request const& r , int response_code, error_code const& ec, const std::string& msg - , int retry_interval); + , int retry_interval) TORRENT_OVERRIDE; virtual void tracker_warning(tracker_request const& req - , std::string const& msg); + , std::string const& msg) TORRENT_OVERRIDE; virtual void tracker_scrape_response(tracker_request const& req - , int complete, int incomplete, int downloaded, int downloaders); + , int complete, int incomplete, int downloaded, int downloaders) TORRENT_OVERRIDE; void update_scrape_state(); @@ -1022,7 +1022,7 @@ namespace libtorrent // LOGGING #ifndef TORRENT_DISABLE_LOGGING - virtual void debug_log(const char* fmt, ...) const; + virtual void debug_log(const char* fmt, ...) const TORRENT_OVERRIDE; void log_to_all_peers(char const* message); time_point m_dht_start_time; #endif diff --git a/include/libtorrent/torrent_peer_allocator.hpp b/include/libtorrent/torrent_peer_allocator.hpp index 70091abb0..c03c0fa86 100644 --- a/include/libtorrent/torrent_peer_allocator.hpp +++ b/include/libtorrent/torrent_peer_allocator.hpp @@ -56,9 +56,12 @@ namespace libtorrent virtual torrent_peer* allocate_peer_entry(int type) = 0; virtual void free_peer_entry(torrent_peer* p) = 0; + protected: + ~torrent_peer_allocator_interface() {} }; - struct TORRENT_EXTRA_EXPORT torrent_peer_allocator : torrent_peer_allocator_interface + struct TORRENT_EXTRA_EXPORT torrent_peer_allocator TORRENT_FINAL + : torrent_peer_allocator_interface { torrent_peer_allocator(); diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 7af8d4f33..61b595e48 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -322,7 +322,7 @@ namespace libtorrent tracker_manager& m_man; }; - class TORRENT_EXTRA_EXPORT tracker_manager + class TORRENT_EXTRA_EXPORT tracker_manager TORRENT_FINAL : public udp_socket_observer , boost::noncopyable { diff --git a/include/libtorrent/udp_socket.hpp b/include/libtorrent/udp_socket.hpp index fb8821738..c6a6b118b 100644 --- a/include/libtorrent/udp_socket.hpp +++ b/include/libtorrent/udp_socket.hpp @@ -61,6 +61,8 @@ namespace libtorrent // called every time the socket is drained of packets virtual void socket_drained() {} + protected: + ~udp_socket_observer() {} }; class udp_socket : single_threaded diff --git a/include/libtorrent/uncork_interface.hpp b/include/libtorrent/uncork_interface.hpp index 24cd8182b..e146eadd2 100644 --- a/include/libtorrent/uncork_interface.hpp +++ b/include/libtorrent/uncork_interface.hpp @@ -48,6 +48,8 @@ namespace libtorrent struct uncork_interface { virtual void do_delayed_uncork() = 0; + protected: + ~uncork_interface() {} }; } diff --git a/include/libtorrent/utp_socket_manager.hpp b/include/libtorrent/utp_socket_manager.hpp index d06c1a143..d9c83f181 100644 --- a/include/libtorrent/utp_socket_manager.hpp +++ b/include/libtorrent/utp_socket_manager.hpp @@ -49,7 +49,7 @@ namespace libtorrent typedef boost::function const&)> incoming_utp_callback_t; - struct utp_socket_manager : udp_socket_observer + struct utp_socket_manager TORRENT_FINAL : udp_socket_observer { utp_socket_manager(aux::session_settings const& sett, udp_socket& s , counters& cnt, void* ssl_context, incoming_utp_callback_t cb); @@ -57,12 +57,12 @@ namespace libtorrent // return false if this is not a uTP packet virtual bool incoming_packet(error_code const& ec, udp::endpoint const& ep - , char const* p, int size); - virtual bool incoming_packet(error_code const&, char const*, char const*, int) + , char const* p, int size) TORRENT_OVERRIDE; + virtual bool incoming_packet(error_code const&, char const*, char const*, int) TORRENT_OVERRIDE { return false; } - virtual void writable(); + virtual void writable() TORRENT_OVERRIDE; - virtual void socket_drained(); + virtual void socket_drained() TORRENT_OVERRIDE; void tick(time_point now); diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index c51c099c7..85c27baf2 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -219,7 +219,7 @@ public: error_code get_option(GettableSocketOption&, error_code& ec) { return ec; } - error_code cancel(error_code& ec) + error_code cancel(error_code&) { cancel_handlers(asio::error::operation_aborted); return error_code(); diff --git a/src/choker.cpp b/src/choker.cpp index 479dcfae4..185436a4a 100644 --- a/src/choker.cpp +++ b/src/choker.cpp @@ -40,6 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { + namespace { + // return true if 'lhs' peer should be preferred to be unchoke over 'rhs' bool unchoke_compare_rr(peer_connection const* lhs , peer_connection const* rhs, int pieces) @@ -247,6 +249,8 @@ namespace libtorrent return lhs->time_of_last_unchoke() < rhs->time_of_last_unchoke(); } + } // anonymous namespace + int unchoke_sort(std::vector& peers , int max_upload_rate , time_duration unchoke_interval diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index bcebe32b7..8415e1b12 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -323,7 +323,8 @@ namespace libtorrent check_buffer_level(l); } - char* disk_buffer_pool::allocate_buffer_impl(mutex::scoped_lock& l, char const* category) + char* disk_buffer_pool::allocate_buffer_impl(mutex::scoped_lock& l + , char const*) { TORRENT_ASSERT(m_settings_set); TORRENT_ASSERT(m_magic == 0x1337); diff --git a/src/peer_list.cpp b/src/peer_list.cpp index 0242d4a35..2d69948c8 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -169,7 +169,7 @@ namespace libtorrent { // disconnecting the peer here may also delete the // peer_info_struct. If that is the case, just continue - int count = m_peers.size(); + size_t count = m_peers.size(); peer_connection_interface* p = (*i)->connection; banned.push_back(p->remote().address()); diff --git a/src/session.cpp b/src/session.cpp index 135cb059a..e87fd4493 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -480,15 +480,15 @@ namespace libtorrent } #ifndef TORRENT_NO_DEPRECATE - void session::load_asnum_db(char const* file) {} - void session::load_country_db(char const* file) {} + void session::load_asnum_db(char const*) {} + void session::load_country_db(char const*) {} - int session::as_for_ip(address const& addr) + int session::as_for_ip(address const&) { return 0; } #if TORRENT_USE_WSTRING - void session::load_asnum_db(wchar_t const* file) {} - void session::load_country_db(wchar_t const* file) {} + void session::load_asnum_db(wchar_t const*) {} + void session::load_country_db(wchar_t const*) {} #endif // TORRENT_USE_WSTRING void session::load_state(entry const& ses_state) diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index f32069384..c4393c51a 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -122,6 +122,8 @@ namespace libtorrent #pragma GCC diagnostic ignored "-Winvalid-offsetof" #endif + namespace { + using aux::session_impl; str_setting_entry_t str_settings[settings_pack::num_string_settings] = @@ -352,6 +354,8 @@ namespace libtorrent #pragma GCC diagnostic pop #endif + } // anonymous namespace + int setting_by_name(std::string const& key) { for (int k = 0; k < sizeof(str_settings)/sizeof(str_settings[0]); ++k) diff --git a/src/storage.cpp b/src/storage.cpp index 2107c2227..2b495ff97 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -188,6 +188,8 @@ namespace libtorrent std::memset(i->iov_base, 0, i->iov_len); } + namespace { + #if TORRENT_USE_ASSERTS int count_bufs(file::iovec_t const* bufs, int bytes) { @@ -202,6 +204,7 @@ namespace libtorrent } } #endif + } // anonymous namespace default_storage::default_storage(storage_params const& params) : m_files(*params.files) @@ -530,7 +533,7 @@ namespace libtorrent m_mapped_files->rename_file(index, new_filename); } - void default_storage::release_files(storage_error& ec) + void default_storage::release_files(storage_error&) { // make sure we don't have the files open m_pool.release(this); @@ -1363,14 +1366,14 @@ namespace libtorrent return new default_storage(params); } - int disabled_storage::readv(file::iovec_t const* bufs - , int num_bufs, int slot, int offset, int flags, storage_error& ec) + int disabled_storage::readv(file::iovec_t const* + , int, int, int, int, storage_error&) { return 0; } - int disabled_storage::writev(file::iovec_t const* bufs - , int num_bufs, int slot, int offset, int flags, storage_error& ec) + int disabled_storage::writev(file::iovec_t const* + , int, int, int, int, storage_error&) { return 0; }