fix some warnings

This commit is contained in:
arvidn
2015-08-02 15:55:05 -04:00
parent 8473696d62
commit e0c3d28321
15 changed files with 113 additions and 26 deletions

View File

@@ -46,6 +46,10 @@ namespace libtorrent
struct socket_job
{
socket_job() : type(none), vec(NULL), recv_buf(NULL), buf_size(0) {}
#if __cplusplus >= 201103L
socket_job(socket_job const& st) = default;
socket_job& operator=(socket_job const& st) = default;
#endif
enum job_type_t
{

View File

@@ -144,6 +144,10 @@ namespace libtorrent
struct has_block
{
#if __cplusplus >= 201103L
has_block(has_block const&) = default;
#endif
has_block(piece_block const& b): block(b) {}
piece_block const& block;
bool operator()(pending_block const& pb) const

View File

@@ -129,7 +129,7 @@ namespace libtorrent
i2p_proxy
};
#endif
// tells libtorrent what kind of proxy server it is. See proxy_type
// enum for options
boost::uint8_t type;
@@ -159,6 +159,10 @@ namespace libtorrent
session_settings(std::string const& user_agent = "libtorrent/"
LIBTORRENT_VERSION);
~session_settings();
#if __cplusplus >= 201103L
session_settings(session_settings const& st) = default;
session_settings& operator=(session_settings const& st) = default;
#endif
// automatically set to the libtorrent version you're using in order to
// be forward binary compatible. This field should not be changed.

View File

@@ -509,10 +509,9 @@ namespace libtorrent
// of normal bittorrent operation, since it will just send garbage
// to peers and throw away all the data it downloads. It would end
// up being banned immediately
class disabled_storage : public storage_interface, boost::noncopyable
class disabled_storage TORRENT_FINAL : public storage_interface, boost::noncopyable
{
public:
disabled_storage(int piece_size) : m_piece_size(piece_size) {}
virtual bool has_any_file(storage_error&) TORRENT_OVERRIDE { return false; }
virtual void set_file_priority(std::vector<boost::uint8_t> const&
, storage_error&) TORRENT_OVERRIDE {}
@@ -531,15 +530,11 @@ namespace libtorrent
, std::vector<std::string> const*
, storage_error&) TORRENT_OVERRIDE { return false; }
virtual void write_resume_data(entry&, storage_error&) const TORRENT_OVERRIDE {}
private:
int m_piece_size;
};
// this storage implementation always reads zeroes, and always discards
// anything written to it
struct zero_storage : storage_interface
struct zero_storage TORRENT_FINAL : storage_interface
{
virtual void initialize(storage_error&) TORRENT_OVERRIDE {}

View File

@@ -50,13 +50,13 @@ namespace libtorrent
thread_pool() : m_num_threads(0) {}
virtual ~thread_pool() {}
void stop() { set_num_threads(0, true); }
void set_num_threads(int i, bool wait = true)
void set_num_threads(int n, bool wait = true)
{
if (i == m_num_threads) return;
if (i > m_num_threads)
if (n == m_num_threads) return;
if (n > m_num_threads)
{
while (m_num_threads < i)
while (m_num_threads < n)
{
++m_num_threads;
m_threads.push_back(boost::shared_ptr<thread>(
@@ -65,11 +65,15 @@ namespace libtorrent
}
else
{
while (m_num_threads > i) { --m_num_threads; }
while (m_num_threads > n) { --m_num_threads; }
mutex::scoped_lock l(m_mutex);
m_cond.notify_all();
l.unlock();
if (wait) for (int i = m_num_threads; i < int(m_threads.size()); ++i) m_threads[i]->join();
if (wait)
{
for (int i = m_num_threads; i < int(m_threads.size()); ++i)
m_threads[i]->join();
}
// this will detach the threads
m_threads.resize(m_num_threads);
}

View File

@@ -83,6 +83,10 @@ namespace libtorrent
announce_entry(std::string const& u);
announce_entry();
~announce_entry();
#if __cplusplus >= 201103L
announce_entry(announce_entry const& st) = default;
announce_entry& operator=(announce_entry const& st) = default;
#endif
// tracker URL as it appeared in the torrent file
std::string url;

View File

@@ -272,6 +272,10 @@ private:
TORRENT_ASSERT(magic == 1337);
magic = 0;
}
#if __cplusplus >= 201103L
rootdevice(rootdevice const& st) = default;
rootdevice& operator=(rootdevice const& st) = default;
#endif
#endif
// the interface url, through which the list of

View File

@@ -39,6 +39,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/packet_buffer.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/bind.hpp>
#include <boost/function/function1.hpp>
#include <boost/function/function2.hpp>
@@ -47,6 +49,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/system/system_error.hpp>
#endif
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#define CCONTROL_TARGET 100
namespace libtorrent

View File

@@ -161,7 +161,23 @@ POSSIBILITY OF SUCH DAMAGE.
#define DEBUG_CACHE 0
#define DLOG if (DEBUG_CACHE) fprintf
#if __cplusplus >= 201103L
#if DEBUG_CACHE
#define DLOG(...) fprintf(__VA_ARGS__)
#else
#define DLOG(...) do {} while (false)
#endif
#else // cplusplus
#if DEBUG_CACHE
#define DLOG fprintf
#else
#define DLOG TORRENT_WHILE_0 fprintf
#endif
#endif // cplusplus
namespace libtorrent {

View File

@@ -33,11 +33,22 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/version.hpp>
#include "libtorrent/config.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#if defined TORRENT_OS2
#include <pthread.h>
#endif
#include <boost/bind.hpp>
#include <boost/asio/ip/host_name.hpp>
#include <boost/asio/ip/multicast.hpp>
#ifdef TORRENT_WINDOWS
#include <iphlpapi.h> // for if_nametoindex
#endif
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/enum_net.hpp"
@@ -52,13 +63,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket_io.hpp"
#endif
#include <boost/asio/ip/host_name.hpp>
#include <boost/asio/ip/multicast.hpp>
#ifdef TORRENT_WINDOWS
#include <iphlpapi.h> // for if_nametoindex
#endif
namespace libtorrent
{
bool is_local(address const& a)

View File

@@ -60,12 +60,24 @@ POSSIBILITY OF SUCH DAMAGE.
#define DEBUG_DISK_THREAD 0
#if __cplusplus >= 201103L
#if DEBUG_DISK_THREAD
#define DLOG(...) debug_log(__VA_ARGS__)
#else
#define DLOG(...) do {} while(false)
#endif
#else
#if DEBUG_DISK_THREAD
#define DLOG debug_log
#else
#define DLOG TORRENT_WHILE_0 debug_log
#endif
#endif // cplusplus
namespace libtorrent
{

View File

@@ -90,6 +90,22 @@ POSSIBILITY OF SUCH DAMAGE.
#define DEBUG_STORAGE 0
#define DEBUG_DELETE_FILES 0
#if __cplusplus >= 201103L
#if DEBUG_STORAGE
#define DLOG(...) fprintf(__VA_ARGS__)
#else
#define DLOG(...) do {} while (false)
#endif
#if DEBUG_DELETE_FILES
#define DFLOG(...) fprintf(__VA_ARGS__)
#else
#define DFLOG(...) do {} while (false)
#endif
#else
#if DEBUG_STORAGE
#define DLOG fprintf
#else
@@ -102,6 +118,8 @@ POSSIBILITY OF SUCH DAMAGE.
#define DFLOG TORRENT_WHILE_0 fprintf
#endif
#endif // cplusplus
namespace libtorrent
{
@@ -1389,7 +1407,7 @@ namespace libtorrent
storage_interface* disabled_storage_constructor(storage_params const& params)
{
return new disabled_storage(params.files->piece_length());
return new disabled_storage;
}
// -- zero_storage ------------------------------------------------------

View File

@@ -132,14 +132,14 @@ namespace libtorrent
return ret;
}
torrent_peer::torrent_peer(boost::uint16_t port, bool conn, int src)
torrent_peer::torrent_peer(boost::uint16_t port_, bool conn, int src)
: prev_amount_upload(0)
, prev_amount_download(0)
, connection(0)
, peer_rank(0)
, last_optimistically_unchoked(0)
, last_connected(0)
, port(port)
, port(port_)
, hashfails(0)
, failcount(0)
, connectable(conn)

View File

@@ -45,10 +45,15 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/debug.hpp"
#endif
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <boost/asio/ip/host_name.hpp>
#include <boost/asio/ip/multicast.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <cstdlib>
namespace libtorrent {

View File

@@ -95,9 +95,18 @@ void utp_log(char const* fmt, ...)
#else
#if __cplusplus >= 201103L
#define UTP_LOG(...) do {} while(false)
#define UTP_LOGV(...) do {} while(false)
#else
#define UTP_LOG TORRENT_WHILE_0 printf
#define UTP_LOGV TORRENT_WHILE_0 printf
#endif // cplusplus
#endif
enum