more warnings fixes and cleanup

This commit is contained in:
Arvid Norberg 2015-04-19 06:28:21 +00:00
parent 51e86ca2d5
commit 21751347bc
29 changed files with 101 additions and 37 deletions

View File

@ -240,6 +240,7 @@ rule warnings ( properties * )
result += <cflags>-Wno-exit-time-destructors ;
result += <cflags>-Wno-documentation-unknown-command ;
result += <cflags>-Wno-disabled-macro-expansion ;
result += <cflags>-Wno-weak-vtables ;
}
if <toolset>gcc in $(properties)

View File

@ -46,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include <boost/function/function0.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/config.hpp>
#include <list>
#include <utility> // 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 <class T, typename... Args>
void emplace_alert(Args&&... args)

View File

@ -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() {}
};
}}

View File

@ -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

View File

@ -55,6 +55,8 @@ namespace libtorrent
, char const* category) = 0;
virtual char* async_allocate_disk_buffer(char const* category
, boost::function<void(char*)> const& handler) = 0;
protected:
~buffer_allocator_interface() {}
};
// The disk buffer holder acts like a ``scoped_ptr`` that frees a disk buffer

View File

@ -110,6 +110,8 @@ namespace libtorrent
#if TORRENT_USE_ASSERTS
virtual bool is_disk_buffer(char* buffer) const = 0;
#endif
protected:
~disk_interface() {}
};
}

View File

@ -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

View File

@ -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() {}
};
}

View File

@ -58,22 +58,26 @@ POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "libtorrent/config.hpp"
#include "aux_/disable_warnings_push.hpp"
#include <map>
#include <list>
#include <string>
#include <stdexcept>
#include <boost/cstdint.hpp>
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/max.hpp"
#include <boost/config.hpp>
#if TORRENT_USE_IOSTREAM
#include <iosfwd>
#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()));

View File

@ -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() {}
};
}}

View File

@ -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

View File

@ -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();

View File

@ -65,6 +65,8 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_LOGGING
virtual void peer_log(char const* fmt, ...) const = 0;
#endif
protected:
~peer_connection_interface() {}
};
}

View File

@ -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);

View File

@ -64,6 +64,8 @@ struct resolver_interface
, callback_t const& h) = 0;
virtual void abort() = 0;
protected:
~resolver_interface() {}
};
}

View File

@ -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 <boost/function/function1.hpp>
#include <boost/bind.hpp>
#if BOOST_VERSION < 103500
#include <asio/ssl.hpp>
@ -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 <class Stream>

View File

@ -696,14 +696,14 @@ namespace libtorrent
tracker_request const& r
, address const& tracker_ip
, std::list<address> 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

View File

@ -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();

View File

@ -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
{

View File

@ -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

View File

@ -48,6 +48,8 @@ namespace libtorrent
struct uncork_interface
{
virtual void do_delayed_uncork() = 0;
protected:
~uncork_interface() {}
};
}

View File

@ -49,7 +49,7 @@ namespace libtorrent
typedef boost::function<void(boost::shared_ptr<socket_type> 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);

View File

@ -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();

View File

@ -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<peer_connection*>& peers
, int max_upload_rate
, time_duration unchoke_interval

View File

@ -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);

View File

@ -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());

View File

@ -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)

View File

@ -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)

View File

@ -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;
}