fix some msvc warnings

This commit is contained in:
arvidn 2015-11-18 19:51:17 -05:00
parent 6fc0b3609f
commit fba0762353
29 changed files with 51 additions and 44 deletions

View File

@ -260,7 +260,7 @@ namespace libtorrent
std::string const& collection) const TORRENT_OVERRIDE TORRENT_FINAL;
#endif
boost::weak_ptr<torrent> find_disconnect_candidate_torrent() const TORRENT_OVERRIDE TORRENT_FINAL;
int num_torrents() const TORRENT_OVERRIDE TORRENT_FINAL { return m_torrents.size(); }
int num_torrents() const TORRENT_OVERRIDE TORRENT_FINAL { return int(m_torrents.size()); }
void insert_torrent(sha1_hash const& ih, boost::shared_ptr<torrent> const& t
, std::string uuid);
@ -458,8 +458,7 @@ namespace libtorrent
bool preemptive_unchoke() const;
int num_uploads() const
{ return int(m_stats_counters[counters::num_peers_up_unchoked]); }
int num_connections() const
{ return m_connections.size(); }
int num_connections() const { return int(m_connections.size()); }
int peak_up_rate() const { return m_peak_up_rate; }

View File

@ -107,7 +107,7 @@ namespace libtorrent { namespace aux
// This is the basic logging and debug interface offered by the session.
// a release build with logging disabled (which is the default) will
// not have this class at all
struct session_logger
struct TORRENT_EXTRA_EXPORT session_logger
{
#ifndef TORRENT_DISABLE_LOGGING
virtual void session_log(char const* fmt, ...) const TORRENT_FORMAT(2,3) = 0;
@ -128,7 +128,7 @@ namespace libtorrent { namespace aux
// TOOD: 2 make this interface a lot smaller. It could be split up into
// several smaller interfaces. Each subsystem could then limit the size
// of the mock object to test it.
struct session_interface
struct TORRENT_EXTRA_EXPORT session_interface
: buffer_allocator_interface
#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
, session_logger

View File

@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct bandwidth_socket
struct TORRENT_EXTRA_EXPORT bandwidth_socket
{
virtual void assign_bandwidth(int channel, int amount) = 0;
virtual bool is_disconnecting() const = 0;

View File

@ -94,7 +94,7 @@ namespace libtorrent
#ifndef TORRENT_NO_DEPRECATE
// thrown by bdecode() if the provided bencoded buffer does not contain
// valid encoding.
struct TORRENT_EXPORT invalid_encoding: std::exception
struct invalid_encoding: std::exception
{
// hidden
virtual const char* what() const TORRENT_EXCEPTION_THROW_SPECIFIER

View File

@ -360,12 +360,12 @@ namespace libtorrent
// returns a range of all pieces. This migh be a very
// long list, use carefully
std::pair<iterator, iterator> all_pieces() const;
int num_pieces() const { return m_pieces.size(); }
int num_pieces() const { return int(m_pieces.size()); }
list_iterator<cached_piece_entry> write_lru_pieces() const
{ return m_lru[cached_piece_entry::write_lru].iterate(); }
int num_write_lru_pieces() const { return m_lru[cached_piece_entry::write_lru].size(); }
int num_write_lru_pieces() const { return int(m_lru[cached_piece_entry::write_lru].size()); }
// mark this piece for deletion. If there are no outstanding
// requests to this piece, it's removed immediately, and the

View File

@ -79,7 +79,7 @@ namespace libtorrent
void send(char const* buffer, int size, error_code& ec, int flags = 0);
void close();
int num_send_sockets() const { return m_unicast_sockets.size(); }
int num_send_sockets() const { return int(m_unicast_sockets.size()); }
void enable_ip_broadcast(bool e);
private:

View File

@ -50,7 +50,7 @@ namespace libtorrent
struct disk_io_thread;
struct disk_observer;
struct buffer_allocator_interface
struct TORRENT_EXTRA_EXPORT buffer_allocator_interface
{
virtual char* allocate_disk_buffer(char const* category) = 0;
virtual void free_disk_buffer(char* b) = 0;

View File

@ -50,7 +50,7 @@ namespace libtorrent
struct add_torrent_params;
struct cache_status;
struct disk_interface
struct TORRENT_EXTRA_EXPORT disk_interface
{
virtual void async_read(piece_manager* storage, peer_request const& r
, boost::function<void(disk_io_job const*)> const& handler, void* requester

View File

@ -46,7 +46,7 @@ namespace libtorrent
{
struct disk_io_job;
struct disk_job_pool
struct TORRENT_EXTRA_EXPORT disk_job_pool
{
disk_job_pool();
~disk_job_pool();

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct disk_observer
struct TORRENT_EXTRA_EXPORT disk_observer
{
// called when the disk cache size has dropped
// below the low watermark again and we can

View File

@ -88,7 +88,7 @@ namespace libtorrent
// thrown by any accessor function of entry if the accessor
// function requires a type different than the actual type
// of the entry object.
struct TORRENT_EXPORT type_error: std::runtime_error
struct type_error : std::runtime_error
{
// internal
type_error(const char* error): std::runtime_error(error) {}

View File

@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent { namespace dht
{
struct dht_logger
struct TORRENT_EXTRA_EXPORT dht_logger
{
enum module_t
{
@ -64,7 +64,7 @@ namespace libtorrent { namespace dht
~dht_logger() {}
};
struct dht_observer : dht_logger
struct TORRENT_EXTRA_EXPORT dht_observer : dht_logger
{
virtual void set_external_address(address const& addr
, address const& source) = 0;

View File

@ -128,7 +128,6 @@ namespace libtorrent
struct TORRENT_EXTRA_EXPORT peer_class_pool
{
peer_class_t new_peer_class(std::string const& label);
void decref(peer_class_t c);
void incref(peer_class_t c);

View File

@ -40,7 +40,7 @@ namespace libtorrent {
// this represents an object that can have many peer classes applied
// to it. Most notably, peer connections and torrents derive from this.
struct peer_class_set
struct TORRENT_EXTRA_EXPORT peer_class_set
{
peer_class_set() : m_size(0) {}
void add_class(peer_class_pool& pool, peer_class_t c);

View File

@ -175,7 +175,7 @@ namespace libtorrent
// internal
inline void nop(char*, void*, block_cache_reference) {}
struct peer_connection_hot_members
struct TORRENT_EXTRA_EXPORT peer_connection_hot_members
{
// if tor is set, this is an outgoing connection
peer_connection_hot_members(
@ -1274,8 +1274,11 @@ namespace libtorrent
m_need_uncork = true;
}
~cork() { if (m_need_uncork) m_pc.uncork_socket(); }
private:
peer_connection& m_pc;
bool m_need_uncork;
cork& operator=(cork const&);
};
}

View File

@ -45,7 +45,7 @@ namespace libtorrent
struct peer_info;
// TODO: make this interface smaller!
struct peer_connection_interface
struct TORRENT_EXTRA_EXPORT peer_connection_interface
{
virtual tcp::endpoint const& remote() const = 0;
virtual tcp::endpoint local_endpoint() const = 0;

View File

@ -53,7 +53,7 @@ namespace libtorrent
// in other torrents.
struct TORRENT_EXTRA_EXPORT resolve_links
{
struct link_t
struct TORRENT_EXTRA_EXPORT link_t
{
boost::shared_ptr<const torrent_info> ti;
std::string save_path;

View File

@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct resolver_interface
struct TORRENT_EXTRA_EXPORT resolver_interface
{
typedef boost::function<void(error_code const&, std::vector<address> const&)>
callback_t;

View File

@ -73,7 +73,7 @@ namespace libtorrent
: m_impl(impl)
{}
bool is_valid() const { return m_impl; }
bool is_valid() const { return m_impl != NULL; }
// TODO: 2 the ip filter should probably be saved here too

View File

@ -136,7 +136,7 @@ namespace libtorrent
sha1_hash& operator<<=(int n)
{
TORRENT_ASSERT(n >= 0);
const size_t num_words = size_t(n) / 32;
const int num_words = n / 32;
if (num_words >= number_size)
{
std::memset(m_number, 0, size);
@ -175,7 +175,7 @@ namespace libtorrent
sha1_hash& operator>>=(int n)
{
TORRENT_ASSERT(n >= 0);
const size_t num_words = size_t(n) / 32;
const int num_words = n / 32;
if (num_words >= number_size)
{
std::memset(m_number, 0, size_t(size));

View File

@ -625,7 +625,7 @@ namespace libtorrent
void add_piece(cached_piece_entry* p);
void remove_piece(cached_piece_entry* p);
bool has_piece(cached_piece_entry const* p) const;
int num_pieces() const { return m_cached_pieces.size(); }
int num_pieces() const { return int(m_cached_pieces.size()); }
boost::unordered_set<cached_piece_entry*> const& cached_pieces() const
{ return m_cached_pieces; }
private:

View File

@ -177,7 +177,7 @@ namespace libtorrent
std::vector<char> restart_piece;
};
struct torrent_hot_members
struct TORRENT_EXTRA_EXPORT torrent_hot_members
{
torrent_hot_members(aux::session_interface& ses
, add_torrent_params const& p, int block_size);
@ -1018,7 +1018,7 @@ namespace libtorrent
bool are_files_checked() const
{ return m_files_checked; }
bool valid_storage() const
{ return m_storage.get(); }
{ return m_storage.get() != NULL; }
// parses the info section from the given
// bencoded tree and moves the torrent
@ -1107,7 +1107,7 @@ namespace libtorrent
#endif
int num_time_critical_pieces() const
{ return m_time_critical_pieces.size(); }
{ return int(m_time_critical_pieces.size()); }
private:

View File

@ -45,7 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct torrent_peer_allocator_interface
struct TORRENT_EXTRA_EXPORT torrent_peer_allocator_interface
{
enum peer_type_t
{

View File

@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct udp_socket_observer
struct TORRENT_EXTRA_EXPORT udp_socket_observer
{
// return true if the packet was handled (it won't be
// propagated to the next observer)

View File

@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_UNCORK_INTERFACE_HPP
#define TORRENT_UNCORK_INTERFACE_HPP
#include "libtorrent/export.hpp"
namespace libtorrent
{
// the uncork interface is used by the disk_io_thread
@ -45,7 +47,7 @@ namespace libtorrent
// kernel per system call.
// uncorking refers to releasing the "cork" in the peers
// preventing them to issue sends
struct uncork_interface
struct TORRENT_EXTRA_EXPORT uncork_interface
{
virtual void do_delayed_uncork() = 0;
protected:

View File

@ -313,7 +313,7 @@ public:
m_connect_handler = handler;
do_connect(endpoint);
}
template <class Mutable_Buffers, class Handler>
void async_read_some(Mutable_Buffers const& buffers, Handler const& handler)
{
@ -329,7 +329,7 @@ public:
m_io_service.post(boost::bind<void>(handler, boost::asio::error::operation_not_supported, 0));
return;
}
int bytes_added = 0;
std::size_t bytes_added = 0;
for (typename Mutable_Buffers::const_iterator i = buffers.begin()
, end(buffers.end()); i != end; ++i)
{
@ -465,7 +465,7 @@ public:
return;
}
int bytes_added = 0;
std::size_t bytes_added = 0;
for (typename Const_Buffers::const_iterator i = buffers.begin()
, end(buffers.end()); i != end; ++i)
{

View File

@ -463,6 +463,8 @@ namespace libtorrent
void disk_buffer_pool::set_settings(aux::session_settings const& sett
, error_code& ec)
{
TORRENT_UNUSED(ec);
mutex::scoped_lock l(m_pool_mutex);
// 0 cache_buffer_chunk_size means 'automatic' (i.e.

View File

@ -309,10 +309,10 @@ namespace libtorrent
{
int bufs_size(file::iovec_t const* bufs, int num_bufs)
{
int size = 0;
std::size_t size = 0;
for (file::iovec_t const* i = bufs, *end(bufs + num_bufs); i < end; ++i)
size += i->iov_len;
return size;
return int(size);
}
#ifdef TORRENT_WINDOWS
@ -341,6 +341,8 @@ namespace libtorrent
ec.clear();
#ifdef TORRENT_WINDOWS
TORRENT_UNUSED(flags);
#if TORRENT_USE_WSTRING && defined TORRENT_WINDOWS
#define GetFileAttributesEx_ GetFileAttributesExW
std::wstring f = convert_to_wstring(inf);
@ -1546,7 +1548,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
}
else if (ret == FALSE)
{
int error = GetLastError();
// int error = GetLastError();
return true;
}
@ -1616,7 +1618,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
void gather_copy(file::iovec_t const* bufs, int num_bufs, char* dst)
{
int offset = 0;
std::size_t offset = 0;
for (int i = 0; i < num_bufs; ++i)
{
memcpy(dst + offset, bufs[i].iov_base, bufs[i].iov_len);
@ -1626,7 +1628,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
void scatter_copy(file::iovec_t const* bufs, int num_bufs, char const* src)
{
int offset = 0;
std::size_t offset = 0;
for (int i = 0; i < num_bufs; ++i)
{
memcpy(bufs[i].iov_base, src + offset, bufs[i].iov_len);

View File

@ -56,14 +56,14 @@ namespace libtorrent
if (!st.name.empty())
{
ret += "&dn=";
ret += escape_string(st.name.c_str(), st.name.length());
ret += escape_string(st.name.c_str(), int(st.name.length()));
}
std::vector<announce_entry> const& tr = handle.trackers();
for (std::vector<announce_entry>::const_iterator i = tr.begin(), end(tr.end()); i != end; ++i)
{
ret += "&tr=";
ret += escape_string(i->url.c_str(), i->url.length());
ret += escape_string(i->url.c_str(), int(i->url.length()));
}
std::set<std::string> seeds = handle.url_seeds();
@ -71,7 +71,7 @@ namespace libtorrent
, end(seeds.end()); i != end; ++i)
{
ret += "&ws=";
ret += escape_string(i->c_str(), i->length());
ret += escape_string(i->c_str(), int(i->length()));
}
return ret;