fix some warnings

This commit is contained in:
arvidn 2015-08-01 23:57:11 -04:00
parent 990aabe36f
commit 655a3ae019
32 changed files with 182 additions and 141 deletions

View File

@ -97,7 +97,9 @@ namespace libtorrent
struct TORRENT_EXPORT invalid_encoding: std::exception struct TORRENT_EXPORT invalid_encoding: std::exception
{ {
// hidden // hidden
virtual const char* what() const throw() { return "invalid bencoding"; } virtual const char* what() const TORRENT_EXCEPTION_THROW_SPECIFIER
TORRENT_OVERRIDE TORRENT_FINAL
{ return "invalid bencoding"; }
}; };
#endif #endif
@ -338,7 +340,7 @@ namespace libtorrent
// ---------------------------------------------- // ----------------------------------------------
// string // string
default: default:
if (is_digit((unsigned char)*in)) if (is_digit(boost::uint8_t(*in)))
{ {
std::string len_s = read_until(in, end, ':', err); std::string len_s = read_until(in, end, ':', err);
if (err) if (err)

View File

@ -172,6 +172,10 @@ namespace libtorrent
{ {
cached_piece_entry(); cached_piece_entry();
~cached_piece_entry(); ~cached_piece_entry();
#if __cplusplus >= 201103L
cached_piece_entry(cached_piece_entry const& st) = default;
cached_piece_entry& operator=(cached_piece_entry const& st) = default;
#endif
bool ok_to_evict(bool ignore_hash = false) const bool ok_to_evict(bool ignore_hash = false) const
{ {

View File

@ -59,7 +59,7 @@ namespace libtorrent
{ set_bits(&k[0], bits, N); } { set_bits(&k[0], bits, N); }
std::string to_string() const std::string to_string() const
{ return std::string((char const*)&bits[0], N); } { return std::string(reinterpret_cast<char const*>(&bits[0]), N); }
void from_string(char const* str) void from_string(char const* str)
{ memcpy(bits, str, N); } { memcpy(bits, str, N); }

View File

@ -407,8 +407,7 @@ int snprintf(char* buf, int len, char const* fmt, ...)
#endif #endif
// at the highest warning level, clang actually warns about functions // at the highest warning level, clang actually warns about functions
// that could be marked noreturn. There seems to be versions of GCC // that could be marked noreturn.
// that declare being
#if defined __clang__ || defined __GNUC__ #if defined __clang__ || defined __GNUC__
#define TORRENT_NO_RETURN __attribute((noreturn)) #define TORRENT_NO_RETURN __attribute((noreturn))
#else #else

View File

@ -128,7 +128,7 @@ public:
// not pinged. If the bucket the node falls into is full, // not pinged. If the bucket the node falls into is full,
// the node will be ignored. // the node will be ignored.
void heard_about(node_id const& id, udp::endpoint const& ep); void heard_about(node_id const& id, udp::endpoint const& ep);
node_entry const* next_refresh(); node_entry const* next_refresh();
enum enum
@ -143,7 +143,7 @@ public:
, int options, int count = 0); , int options, int count = 0);
void remove_node(node_entry* n void remove_node(node_entry* n
, table_t::iterator bucket) ; , table_t::iterator bucket) ;
int bucket_size(int bucket) const int bucket_size(int bucket) const
{ {
int num_buckets = m_buckets.size(); int num_buckets = m_buckets.size();
@ -151,7 +151,7 @@ public:
if (bucket < num_buckets) bucket = num_buckets - 1; if (bucket < num_buckets) bucket = num_buckets - 1;
table_t::const_iterator i = m_buckets.begin(); table_t::const_iterator i = m_buckets.begin();
std::advance(i, bucket); std::advance(i, bucket);
return (int)i->live_nodes.size(); return int(i->live_nodes.size());
} }
void for_each_node(void (*)(void*, node_entry const&) void for_each_node(void (*)(void*, node_entry const&)

View File

@ -151,7 +151,7 @@ namespace libtorrent
// tells you which specific type this lazy entry has. // tells you which specific type this lazy entry has.
// See entry_type_t. The type determines which subset of // See entry_type_t. The type determines which subset of
// member functions are valid to use. // member functions are valid to use.
entry_type_t type() const { return (entry_type_t)m_type; } entry_type_t type() const { return entry_type_t(m_type); }
// start points to the first decimal digit // start points to the first decimal digit
// length is the number of digits // length is the number of digits

View File

@ -108,8 +108,8 @@ namespace libtorrent
private: private:
struct barrier struct barrier
{ {
barrier(boost::shared_ptr<crypto_plugin> plugin, int next) barrier(boost::shared_ptr<crypto_plugin> plugin, int n)
: enc_handler(plugin), next(next) {} : enc_handler(plugin), next(n) {}
boost::shared_ptr<crypto_plugin> enc_handler; boost::shared_ptr<crypto_plugin> enc_handler;
// number of bytes to next barrier // number of bytes to next barrier
int next; int next;

View File

@ -90,10 +90,10 @@ namespace libtorrent
{ {
friend struct peer_class_pool; friend struct peer_class_pool;
peer_class(std::string const& label) peer_class(std::string const& l)
: ignore_unchoke_slots(false) : ignore_unchoke_slots(false)
, connection_limit_factor(100) , connection_limit_factor(100)
, label(label) , label(l)
, references(1) , references(1)
{ {
priority[0] = 1; priority[0] = 1;

View File

@ -33,11 +33,16 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_RESOLVER_INTERFACE_HPP_INCLUDE #ifndef TORRENT_RESOLVER_INTERFACE_HPP_INCLUDE
#define TORRENT_RESOLVER_INTERFACE_HPP_INCLUDE #define TORRENT_RESOLVER_INTERFACE_HPP_INCLUDE
#include <boost/function.hpp>
#include <vector> #include <vector>
#include "libtorrent/error_code.hpp" #include "libtorrent/error_code.hpp"
#include "libtorrent/address.hpp" #include "libtorrent/address.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/function.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent namespace libtorrent
{ {

View File

@ -51,6 +51,10 @@ namespace libtorrent
struct TORRENT_EXPORT feed_item struct TORRENT_EXPORT feed_item
{ {
feed_item(); feed_item();
#if __cplusplus >= 201103L
feed_item(feed_item const& st) = default;
feed_item & operator=(feed_item const& st) = default;
#endif
~feed_item(); ~feed_item();
// these are self explanatory and may be empty if the feed does not specify // these are self explanatory and may be empty if the feed does not specify

View File

@ -125,6 +125,10 @@ namespace libtorrent
// implementation object. // implementation object.
session_proxy() {} session_proxy() {}
~session_proxy(); ~session_proxy();
#if __cplusplus >= 201103L
session_proxy(session_proxy const& st) = default;
session_proxy& operator=(session_proxy const& st) = default;
#endif
private: private:
session_proxy( session_proxy(
boost::shared_ptr<io_service> ios boost::shared_ptr<io_service> ios

View File

@ -118,6 +118,9 @@ namespace libtorrent
} }
void assign(char const* str) { std::memcpy(m_number, str, size); } void assign(char const* str) { std::memcpy(m_number, str, size); }
char const* data() const { return reinterpret_cast<char const*>(&m_number[0]); }
char* data() { return reinterpret_cast<char*>(&m_number[0]); }
// set the sha1-hash to all zeroes. // set the sha1-hash to all zeroes.
void clear() { std::memset(m_number, 0, size); } void clear() { std::memset(m_number, 0, size); }

View File

@ -282,13 +282,13 @@ namespace libtorrent
template <class S> S* get() template <class S> S* get()
{ {
if (m_type != socket_type_int_impl<S>::value) return 0; if (m_type != socket_type_int_impl<S>::value) return 0;
return (S*)m_data; return reinterpret_cast<S*>(m_data);
} }
template <class S> S const* get() const template <class S> S const* get() const
{ {
if (m_type != socket_type_int_impl<S>::value) return 0; if (m_type != socket_type_int_impl<S>::value) return 0;
return (S const*)m_data; return reinterpret_cast<S const*>(m_data);
} }
private: private:

View File

@ -604,7 +604,7 @@ namespace libtorrent
// if there is a fence up, returns true and adds the job // if there is a fence up, returns true and adds the job
// to the queue of blocked jobs // to the queue of blocked jobs
bool is_blocked(disk_io_job* j); bool is_blocked(disk_io_job* j);
// the number of blocked jobs // the number of blocked jobs
int num_blocked() const; int num_blocked() const;
@ -638,7 +638,7 @@ namespace libtorrent
{ {
void add_piece(cached_piece_entry* p); void add_piece(cached_piece_entry* p);
void remove_piece(cached_piece_entry* p); void remove_piece(cached_piece_entry* p);
bool has_piece(cached_piece_entry* p) const; bool has_piece(cached_piece_entry const* p) const;
int num_pieces() const { return m_cached_pieces.size(); } int num_pieces() const { return m_cached_pieces.size(); }
boost::unordered_set<cached_piece_entry*> const& cached_pieces() const boost::unordered_set<cached_piece_entry*> const& cached_pieces() const
{ return m_cached_pieces; } { return m_cached_pieces; }

View File

@ -310,7 +310,7 @@ namespace libtorrent
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
bool has_peer(peer_connection const* p) const bool has_peer(peer_connection const* p) const
{ return sorted_find(m_connections, (peer_connection*)p) != m_connections.end(); } { return sorted_find(m_connections, p) != m_connections.end(); }
bool is_single_thread() const { return single_threaded::is_single_thread(); } bool is_single_thread() const { return single_threaded::is_single_thread(); }
#endif #endif
@ -393,7 +393,9 @@ namespace libtorrent
void on_disk_read_complete(disk_io_job const* j, peer_request r void on_disk_read_complete(disk_io_job const* j, peer_request r
, boost::shared_ptr<read_piece_struct> rp); , boost::shared_ptr<read_piece_struct> rp);
storage_mode_t storage_mode() const { return (storage_mode_t)m_storage_mode; } storage_mode_t storage_mode() const
{ return storage_mode_t(m_storage_mode); }
storage_interface* get_storage() storage_interface* get_storage()
{ {
if (!m_storage) return 0; if (!m_storage) return 0;
@ -410,7 +412,7 @@ namespace libtorrent
void new_external_ip(); void new_external_ip();
torrent_status::state_t state() const torrent_status::state_t state() const
{ return (torrent_status::state_t)m_state; } { return torrent_status::state_t(m_state); }
void set_state(torrent_status::state_t s); void set_state(torrent_status::state_t s);
aux::session_settings const& settings() const; aux::session_settings const& settings() const;
@ -589,7 +591,7 @@ namespace libtorrent
void set_download_limit(int limit); void set_download_limit(int limit);
int download_limit() const; int download_limit() const;
peer_class_t peer_class() const { return (peer_class_t)m_peer_class; } peer_class_t peer_class() const { return peer_class_t(m_peer_class); }
void set_max_uploads(int limit, bool state_update = true); void set_max_uploads(int limit, bool state_update = true);
int max_uploads() const { return m_max_uploads; } int max_uploads() const { return m_max_uploads; }
@ -598,13 +600,13 @@ namespace libtorrent
// -------------------------------------------- // --------------------------------------------
// PEER MANAGEMENT // PEER MANAGEMENT
// add or remove a url that will be attempted for // add or remove a url that will be attempted for
// finding the file(s) in this torrent. // finding the file(s) in this torrent.
void add_web_seed(std::string const& url, web_seed_t::type_t type); void add_web_seed(std::string const& url, web_seed_t::type_t type);
void add_web_seed(std::string const& url, web_seed_t::type_t type void add_web_seed(std::string const& url, web_seed_t::type_t type
, std::string const& auth, web_seed_t::headers_t const& extra_headers); , std::string const& auth, web_seed_t::headers_t const& extra_headers);
void remove_web_seed(std::string const& url, web_seed_t::type_t type); void remove_web_seed(std::string const& url, web_seed_t::type_t type);
void disconnect_web_seed(peer_connection* p); void disconnect_web_seed(peer_connection* p);
@ -660,7 +662,7 @@ namespace libtorrent
std::pair<peer_list::iterator, peer_list::iterator> find_peers(address const& a); std::pair<peer_list::iterator, peer_list::iterator> find_peers(address const& a);
// the number of peers that belong to this torrent // the number of peers that belong to this torrent
int num_peers() const { return (int)m_connections.size(); } int num_peers() const { return int(m_connections.size()); }
int num_seeds() const; int num_seeds() const;
int num_downloaders() const; int num_downloaders() const;

View File

@ -82,7 +82,7 @@ namespace libtorrent
// for compatibility with 0.14 // for compatibility with 0.14
typedef libtorrent_exception duplicate_torrent; typedef libtorrent_exception duplicate_torrent;
typedef libtorrent_exception invalid_handle; typedef libtorrent_exception invalid_handle;
void throw_invalid_handle(); void throw_invalid_handle() TORRENT_NO_RETURN;
#endif #endif
// holds the state of a block in a piece. Who we requested // holds the state of a block in a piece. Who we requested
@ -252,6 +252,10 @@ namespace libtorrent
torrent_handle(torrent_handle const& t) torrent_handle(torrent_handle const& t)
{ if (!t.m_torrent.expired()) m_torrent = t.m_torrent; } { if (!t.m_torrent.expired()) m_torrent = t.m_torrent; }
#if __cplusplus >= 201103L
torrent_handle& operator=(torrent_handle const& st) = default;
#endif
// flags for add_piece(). // flags for add_piece().
enum flags_t { overwrite_existing = 1 }; enum flags_t { overwrite_existing = 1 };

View File

@ -574,7 +574,7 @@ namespace libtorrent
if (is_merkle_torrent()) if (is_merkle_torrent())
{ {
TORRENT_ASSERT(index < int(m_merkle_tree.size() - m_merkle_first_leaf)); TORRENT_ASSERT(index < int(m_merkle_tree.size() - m_merkle_first_leaf));
return (const char*)&m_merkle_tree[m_merkle_first_leaf + index][0]; return m_merkle_tree[m_merkle_first_leaf + index].data();
} }
else else
{ {

View File

@ -50,10 +50,11 @@ namespace libtorrent {
} }
template <class T> template <class T>
typename std::vector<T>::const_iterator sorted_find(std::vector<T> const& container typename std::vector<T*>::const_iterator sorted_find(std::vector<T*> const& container
, T v) , T const* v)
{ {
return sorted_find(const_cast<std::vector<T>&>(container), v); return sorted_find(const_cast<std::vector<T*>&>(container)
, const_cast<T*>(v));
} }
template<class T> template<class T>

View File

@ -68,7 +68,7 @@ namespace libtorrent {
else if (h.is_valid()) else if (h.is_valid())
{ {
char msg[41]; char msg[41];
to_hex((char const*)&h.native_handle()->info_hash()[0], 20, msg); to_hex(h.native_handle()->info_hash().data(), 20, msg);
m_name_idx = alloc.copy_string(msg); m_name_idx = alloc.copy_string(msg);
} }
else else
@ -485,12 +485,12 @@ namespace libtorrent {
invalid_request_alert::invalid_request_alert(aux::stack_allocator& alloc invalid_request_alert::invalid_request_alert(aux::stack_allocator& alloc
, torrent_handle const& h, tcp::endpoint const& ep , torrent_handle const& h, tcp::endpoint const& ep
, peer_id const& peer_id, peer_request const& r , peer_id const& peer_id, peer_request const& r
, bool we_have, bool peer_interested, bool withheld) , bool _have, bool _peer_interested, bool _withheld)
: peer_alert(alloc, h, ep, peer_id) : peer_alert(alloc, h, ep, peer_id)
, request(r) , request(r)
, we_have(we_have) , we_have(_have)
, peer_interested(peer_interested) , peer_interested(_peer_interested)
, withheld(withheld) , withheld(_withheld)
{} {}
std::string invalid_request_alert::message() const std::string invalid_request_alert::message() const
@ -650,12 +650,12 @@ namespace libtorrent {
aux::stack_allocator& alloc aux::stack_allocator& alloc
, torrent_handle const& h , torrent_handle const& h
, error_code const& e , error_code const& e
, std::string const& file , std::string const& f
, char const* op) , char const* op)
: torrent_alert(alloc, h) : torrent_alert(alloc, h)
, error(e) , error(e)
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
, file(file) , file(f)
#endif #endif
, operation(op) , operation(op)
, m_file_idx(alloc.copy_string(file)) , m_file_idx(alloc.copy_string(file))
@ -937,12 +937,12 @@ namespace libtorrent {
aux::stack_allocator& alloc aux::stack_allocator& alloc
, torrent_handle const& h , torrent_handle const& h
, error_code const& ec , error_code const& ec
, std::string const& file , std::string const& f
, char const* op) , char const* op)
: torrent_alert(alloc, h) : torrent_alert(alloc, h)
, error(ec) , error(ec)
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
, file(file) , file(f)
#endif #endif
, operation(op) , operation(op)
, m_path_idx(alloc.copy_string(file)) , m_path_idx(alloc.copy_string(file))
@ -1005,7 +1005,7 @@ namespace libtorrent {
{ {
error_code ec; error_code ec;
char ih_hex[41]; char ih_hex[41];
to_hex((const char*)&info_hash[0], 20, ih_hex); to_hex(info_hash.data(), 20, ih_hex);
char msg[200]; char msg[200];
snprintf(msg, sizeof(msg), "incoming dht announce: %s:%u (%s)" snprintf(msg, sizeof(msg), "incoming dht announce: %s:%u (%s)"
, ip.to_string(ec).c_str(), port, ih_hex); , ip.to_string(ec).c_str(), port, ih_hex);
@ -1020,7 +1020,7 @@ namespace libtorrent {
std::string dht_get_peers_alert::message() const std::string dht_get_peers_alert::message() const
{ {
char ih_hex[41]; char ih_hex[41];
to_hex((const char*)&info_hash[0], 20, ih_hex); to_hex(info_hash.data(), 20, ih_hex);
char msg[200]; char msg[200];
snprintf(msg, sizeof(msg), "incoming dht get_peers: %s", ih_hex); snprintf(msg, sizeof(msg), "incoming dht get_peers: %s", ih_hex);
return msg; return msg;
@ -1253,7 +1253,7 @@ namespace libtorrent {
if (params.ti) torrent_name = params.ti->name().c_str(); if (params.ti) torrent_name = params.ti->name().c_str();
else if (!params.name.empty()) torrent_name = params.name.c_str(); else if (!params.name.empty()) torrent_name = params.name.c_str();
else if (!params.url.empty()) torrent_name = params.url.c_str(); else if (!params.url.empty()) torrent_name = params.url.c_str();
else to_hex((const char*)&params.info_hash[0], 20, info_hash); else to_hex(params.info_hash.data(), 20, info_hash);
if (error) if (error)
{ {
@ -1305,12 +1305,12 @@ namespace libtorrent {
std::string peer_error_alert::message() const std::string peer_error_alert::message() const
{ {
char msg[200]; char buf[200];
snprintf(msg, sizeof(msg), "%s peer error [%s] [%s]: %s" snprintf(buf, sizeof(buf), "%s peer error [%s] [%s]: %s"
, peer_alert::message().c_str() , peer_alert::message().c_str()
, operation_name(operation), error.category().name() , operation_name(operation), error.category().name()
, convert_from_native(error.message()).c_str()); , convert_from_native(error.message()).c_str());
return msg; return buf;
} }
char const* operation_name(int op) char const* operation_name(int op)
@ -1360,9 +1360,9 @@ namespace libtorrent {
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
rss_item_alert::rss_item_alert(aux::stack_allocator&, feed_handle h rss_item_alert::rss_item_alert(aux::stack_allocator&, feed_handle h
, feed_item const& item) , feed_item const& i)
: handle(h) : handle(h)
, item(item) , item(i)
{} {}
std::string rss_item_alert::message() const std::string rss_item_alert::message() const
@ -1392,14 +1392,14 @@ namespace libtorrent {
std::string peer_disconnected_alert::message() const std::string peer_disconnected_alert::message() const
{ {
char msg[600]; char buf[600];
snprintf(msg, sizeof(msg), "%s disconnecting (%s) [%s] [%s]: %s (reason: %d)" snprintf(buf, sizeof(buf), "%s disconnecting (%s) [%s] [%s]: %s (reason: %d)"
, peer_alert::message().c_str() , peer_alert::message().c_str()
, socket_type_str[socket_type] , socket_type_str[socket_type]
, operation_name(operation), error.category().name() , operation_name(operation), error.category().name()
, convert_from_native(error.message()).c_str() , convert_from_native(error.message()).c_str()
, int(reason)); , int(reason));
return msg; return buf;
} }
dht_error_alert::dht_error_alert(aux::stack_allocator&, int op dht_error_alert::dht_error_alert(aux::stack_allocator&, int op
@ -1667,12 +1667,12 @@ namespace libtorrent {
file_error_alert::file_error_alert(aux::stack_allocator& alloc file_error_alert::file_error_alert(aux::stack_allocator& alloc
, error_code const& ec , error_code const& ec
, std::string const& file , std::string const& f
, char const* op , char const* op
, torrent_handle const& h) , torrent_handle const& h)
: torrent_alert(alloc, h) : torrent_alert(alloc, h)
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
, file(file) , file(f)
#endif #endif
, error(ec) , error(ec)
, operation(op) , operation(op)
@ -1780,8 +1780,8 @@ namespace libtorrent {
dht_get_peers_reply_alert::dht_get_peers_reply_alert(aux::stack_allocator& alloc dht_get_peers_reply_alert::dht_get_peers_reply_alert(aux::stack_allocator& alloc
, sha1_hash const& ih , sha1_hash const& ih
, std::vector<tcp::endpoint> const& peers) , std::vector<tcp::endpoint> const& peers)
: m_alloc(alloc) : info_hash(ih)
, info_hash(ih) , m_alloc(alloc)
, m_num_peers(peers.size()) , m_num_peers(peers.size())
{ {
std::size_t total_size = m_num_peers; // num bytes for sizes std::size_t total_size = m_num_peers; // num bytes for sizes
@ -1796,7 +1796,7 @@ namespace libtorrent {
tcp::endpoint endp = peers[i]; tcp::endpoint endp = peers[i];
std::size_t size = endp.size(); std::size_t size = endp.size();
detail::write_uint8((boost::uint8_t)size, ptr); detail::write_uint8(size, ptr);
memcpy(ptr, endp.data(), size); memcpy(ptr, endp.data(), size);
ptr += size; ptr += size;
} }
@ -1805,7 +1805,7 @@ namespace libtorrent {
std::string dht_get_peers_reply_alert::message() const std::string dht_get_peers_reply_alert::message() const
{ {
char ih_hex[41]; char ih_hex[41];
to_hex((const char*)&info_hash[0], 20, ih_hex); to_hex(info_hash.data(), 20, ih_hex);
char msg[200]; char msg[200];
snprintf(msg, sizeof(msg), "incoming dht get_peers reply: %s, peers %d", ih_hex, m_num_peers); snprintf(msg, sizeof(msg), "incoming dht get_peers reply: %s, peers %d", ih_hex, m_num_peers);
return msg; return msg;

View File

@ -364,7 +364,8 @@ int block_cache::try_read(disk_io_job* j, bool expect_no_fail)
// we're not allowed to add dirty blocks // we're not allowed to add dirty blocks
// for a deleted storage! // for a deleted storage!
TORRENT_ASSERT(std::find(m_deleted_storages.begin(), m_deleted_storages.end() TORRENT_ASSERT(std::find(m_deleted_storages.begin(), m_deleted_storages.end()
, std::make_pair(j->storage->files()->name(), (void const*)j->storage->files())) , std::make_pair(j->storage->files()->name()
, reinterpret_cast<void const*>(j->storage->files())))
== m_deleted_storages.end()); == m_deleted_storages.end());
#endif #endif
@ -641,8 +642,9 @@ cached_piece_entry* block_cache::allocate_piece(disk_io_job const* j, int cache_
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
void block_cache::mark_deleted(file_storage const& fs) void block_cache::mark_deleted(file_storage const& fs)
{ {
m_deleted_storages.push_back(std::make_pair(fs.name(), (void const*)&fs)); m_deleted_storages.push_back(std::make_pair(fs.name()
if(m_deleted_storages.size() > 100) , reinterpret_cast<void const*>(&fs)));
if (m_deleted_storages.size() > 100)
m_deleted_storages.erase(m_deleted_storages.begin()); m_deleted_storages.erase(m_deleted_storages.begin());
} }
#endif #endif
@ -1226,11 +1228,11 @@ void block_cache::insert_blocks(cached_piece_entry* pe, int block, file::iovec_t
// either free the block or insert it. Never replace a block // either free the block or insert it. Never replace a block
if (pe->blocks[block].buf) if (pe->blocks[block].buf)
{ {
free_buffer((char*)iov[i].iov_base); free_buffer(static_cast<char*>(iov[i].iov_base));
} }
else else
{ {
pe->blocks[block].buf = (char*)iov[i].iov_base; pe->blocks[block].buf = static_cast<char*>(iov[i].iov_base);
TORRENT_PIECE_ASSERT(iov[i].iov_base != NULL, pe); TORRENT_PIECE_ASSERT(iov[i].iov_base != NULL, pe);
TORRENT_PIECE_ASSERT(pe->blocks[block].dirty == false, pe); TORRENT_PIECE_ASSERT(pe->blocks[block].dirty == false, pe);
@ -1245,7 +1247,7 @@ void block_cache::insert_blocks(cached_piece_entry* pe, int block, file::iovec_t
} }
else else
{ {
#if TORRENT_USE_PURGABLE_CONTROL && TORRENT_DISABLE_POOL_ALLOCATOR #if TORRENT_USE_PURGABLE_CONTROL && defined TORRENT_DISABLE_POOL_ALLOCATOR
// volatile read blocks are group 0, regular reads are group 1 // volatile read blocks are group 0, regular reads are group 1
int state = VM_PURGABLE_VOLATILE | ((j->flags & disk_io_job::volatile_read) ? VM_VOLATILE_GROUP_0 : VM_VOLATILE_GROUP_1); int state = VM_PURGABLE_VOLATILE | ((j->flags & disk_io_job::volatile_read) ? VM_VOLATILE_GROUP_0 : VM_VOLATILE_GROUP_1);
kern_return_t ret = vm_purgable_control( kern_return_t ret = vm_purgable_control(
@ -1269,7 +1271,7 @@ void block_cache::insert_blocks(cached_piece_entry* pe, int block, file::iovec_t
} }
} }
#if TORRENT_USE_PURGABLE_CONTROL && TORRENT_DISABLE_POOL_ALLOCATOR #if TORRENT_USE_PURGABLE_CONTROL && defined TORRENT_DISABLE_POOL_ALLOCATOR
TORRENT_ASSERT(pe->blocks[block].buf != NULL TORRENT_ASSERT(pe->blocks[block].buf != NULL
|| (flags & blocks_inc_refcount) == 0); || (flags & blocks_inc_refcount) == 0);
#else #else
@ -1291,7 +1293,7 @@ bool block_cache::inc_block_refcount(cached_piece_entry* pe, int block, int reas
TORRENT_PIECE_ASSERT(pe->blocks[block].refcount < cached_block_entry::max_refcount, pe); TORRENT_PIECE_ASSERT(pe->blocks[block].refcount < cached_block_entry::max_refcount, pe);
if (pe->blocks[block].refcount == 0) if (pe->blocks[block].refcount == 0)
{ {
#if TORRENT_USE_PURGABLE_CONTROL && TORRENT_DISABLE_POOL_ALLOCATOR #if TORRENT_USE_PURGABLE_CONTROL && defined TORRENT_DISABLE_POOL_ALLOCATOR
// we're adding the first refcount to this block, first make sure // we're adding the first refcount to this block, first make sure
// its still here. It's only volatile if it's not dirty and has refcount == 0 // its still here. It's only volatile if it's not dirty and has refcount == 0
if (!pe->blocks[block].dirty) if (!pe->blocks[block].dirty)
@ -1356,7 +1358,7 @@ void block_cache::dec_block_refcount(cached_piece_entry* pe, int block, int reas
TORRENT_PIECE_ASSERT(m_pinned_blocks > 0, pe); TORRENT_PIECE_ASSERT(m_pinned_blocks > 0, pe);
--m_pinned_blocks; --m_pinned_blocks;
#if TORRENT_USE_PURGABLE_CONTROL && TORRENT_DISABLE_POOL_ALLOCATOR #if TORRENT_USE_PURGABLE_CONTROL && defined TORRENT_DISABLE_POOL_ALLOCATOR
// we're removing the last refcount to this block, first make sure // we're removing the last refcount to this block, first make sure
// its still here. It's only volatile if it's not dirty and has refcount == 0 // its still here. It's only volatile if it's not dirty and has refcount == 0
if (!pe->blocks[block].dirty) if (!pe->blocks[block].dirty)
@ -1564,7 +1566,7 @@ void block_cache::check_invariant() const
for (list_iterator p = m_lru[i].iterate(); p.get(); p.next()) for (list_iterator p = m_lru[i].iterate(); p.get(); p.next())
{ {
cached_piece_entry* pe = (cached_piece_entry*)p.get(); cached_piece_entry* pe = static_cast<cached_piece_entry*>(p.get());
TORRENT_PIECE_ASSERT(pe->cache_state == i, pe); TORRENT_PIECE_ASSERT(pe->cache_state == i, pe);
if (pe->num_dirty > 0) if (pe->num_dirty > 0)
TORRENT_PIECE_ASSERT(i == cached_piece_entry::write_lru, pe); TORRENT_PIECE_ASSERT(i == cached_piece_entry::write_lru, pe);
@ -1573,7 +1575,7 @@ void block_cache::check_invariant() const
// TORRENT_ASSERT(pe->num_dirty > 0); // TORRENT_ASSERT(pe->num_dirty > 0);
for (tailqueue_iterator j = pe->jobs.iterate(); j.get(); j.next()) for (tailqueue_iterator j = pe->jobs.iterate(); j.get(); j.next())
{ {
disk_io_job* job = (disk_io_job*)j.get(); disk_io_job const* job = static_cast<disk_io_job const*>(j.get());
TORRENT_PIECE_ASSERT(job->piece == pe->piece, pe); TORRENT_PIECE_ASSERT(job->piece == pe->piece, pe);
TORRENT_PIECE_ASSERT(job->in_use, pe); TORRENT_PIECE_ASSERT(job->in_use, pe);
TORRENT_PIECE_ASSERT(!job->callback_called, pe); TORRENT_PIECE_ASSERT(!job->callback_called, pe);
@ -1615,7 +1617,7 @@ void block_cache::check_invariant() const
{ {
cached_piece_entry const& p = *i; cached_piece_entry const& p = *i;
TORRENT_PIECE_ASSERT(p.blocks, &p); TORRENT_PIECE_ASSERT(p.blocks, &p);
TORRENT_PIECE_ASSERT(p.storage, &p); TORRENT_PIECE_ASSERT(p.storage, &p);
int num_blocks = 0; int num_blocks = 0;
int num_dirty = 0; int num_dirty = 0;
@ -1822,7 +1824,7 @@ bool block_cache::maybe_free_piece(cached_piece_entry* pe)
cached_piece_entry* block_cache::find_piece(block_cache_reference const& ref) cached_piece_entry* block_cache::find_piece(block_cache_reference const& ref)
{ {
return find_piece((piece_manager*)ref.storage, ref.piece); return find_piece(static_cast<piece_manager*>(ref.storage), ref.piece);
} }
cached_piece_entry* block_cache::find_piece(disk_io_job const* j) cached_piece_entry* block_cache::find_piece(disk_io_job const* j)
@ -1843,7 +1845,7 @@ cached_piece_entry* block_cache::find_piece(piece_manager* st, int piece)
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
for (tailqueue_iterator j = i->jobs.iterate(); j.get(); j.next()) for (tailqueue_iterator j = i->jobs.iterate(); j.get(); j.next())
{ {
disk_io_job* job = (disk_io_job*)j.get(); disk_io_job const* job = static_cast<disk_io_job const*>(j.get());
TORRENT_PIECE_ASSERT(job->piece == piece, &*i); TORRENT_PIECE_ASSERT(job->piece == piece, &*i);
} }
#endif #endif

View File

@ -515,7 +515,7 @@ namespace libtorrent
// stream key obfuscated hash [ hash('req2',SKEY) xor hash('req3',S) ] // stream key obfuscated hash [ hash('req2',SKEY) xor hash('req3',S) ]
h.reset(); h.reset();
h.update("req2",4); h.update("req2",4);
h.update((const char*)info_hash.begin(), 20); h.update(info_hash.data(), 20);
sha1_hash streamkey_hash = h.final(); sha1_hash streamkey_hash = h.final();
h.reset(); h.reset();
@ -619,7 +619,8 @@ namespace libtorrent
detail::write_uint16(handshake_len, write_buf); // len(IA) detail::write_uint16(handshake_len, write_buf); // len(IA)
} }
void bt_peer_connection::init_pe_rc4_handler(char const* secret, sha1_hash const& stream_key) void bt_peer_connection::init_pe_rc4_handler(char const* secret
, sha1_hash const& stream_key)
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
@ -635,7 +636,7 @@ namespace libtorrent
if (is_outgoing()) h.update(keyA, 4); else h.update(keyB, 4); if (is_outgoing()) h.update(keyA, 4); else h.update(keyB, 4);
h.update(secret, dh_key_len); h.update(secret, dh_key_len);
h.update((char const*)stream_key.begin(), 20); h.update(stream_key.data(), 20);
const sha1_hash local_key = h.final(); const sha1_hash local_key = h.final();
h.reset(); h.reset();
@ -646,7 +647,7 @@ namespace libtorrent
if (is_outgoing()) h.update(keyB, 4); else h.update(keyA, 4); if (is_outgoing()) h.update(keyB, 4); else h.update(keyA, 4);
h.update(secret, dh_key_len); h.update(secret, dh_key_len);
h.update((char const*)stream_key.begin(), 20); h.update(stream_key.data(), 20);
const sha1_hash remote_key = h.final(); const sha1_hash remote_key = h.final();
TORRENT_ASSERT(!m_rc4.get()); TORRENT_ASSERT(!m_rc4.get());
@ -739,10 +740,10 @@ namespace libtorrent
{ {
// if we're encrypting this buffer, we need to make a copy // if we're encrypting this buffer, we need to make a copy
// since we'll mutate it // since we'll mutate it
char* buf = (char*)malloc(size); char* buf = static_cast<char*>(malloc(size));
memcpy(buf, buffer, size); memcpy(buf, buffer, size);
append_send_buffer(buf, size, &regular_c_free, NULL); append_send_buffer(buf, size, &regular_c_free, NULL);
destructor((char*)buffer, userdata, ref); destructor(const_cast<char*>(buffer), userdata, ref);
} }
else else
#endif #endif
@ -830,7 +831,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
{ {
char hex_pid[41]; char hex_pid[41];
to_hex((char const*)&m_our_peer_id[0], 20, hex_pid); to_hex(m_our_peer_id.data(), 20, hex_pid);
hex_pid[40] = 0; hex_pid[40] = 0;
peer_log(peer_log_alert::outgoing, "HANDSHAKE" peer_log(peer_log_alert::outgoing, "HANDSHAKE"
, "sent peer_id: %s client: %s" , "sent peer_id: %s client: %s"
@ -3371,7 +3372,7 @@ namespace libtorrent
} }
#endif #endif
peer_id pid; peer_id pid;
std::copy(recv_buffer.begin, recv_buffer.begin + 20, (char*)pid.begin()); std::copy(recv_buffer.begin, recv_buffer.begin + 20, pid.data());
if (t->settings().get_bool(settings_pack::allow_multiple_connections_per_ip)) if (t->settings().get_bool(settings_pack::allow_multiple_connections_per_ip))
{ {

View File

@ -151,7 +151,7 @@ namespace libtorrent
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
m_type_queried = true; m_type_queried = true;
#endif #endif
return (entry::data_type)m_type; return entry::data_type(m_type);
} }
entry::~entry() { destruct(); } entry::~entry() { destruct(); }
@ -542,13 +542,13 @@ namespace libtorrent
if (m_type == undefined_t) if (m_type == undefined_t)
{ {
construct((data_type)e.m_type); construct(data_type(e.m_type));
clear_that = true; clear_that = true;
} }
if (e.m_type == undefined_t) if (e.m_type == undefined_t)
{ {
e.construct((data_type)m_type); e.construct(data_type(m_type));
clear_this = true; clear_this = true;
} }

View File

@ -54,7 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
#if TORRENT_USE_ICONV #if TORRENT_USE_ICONV
#include <iconv.h> #include <iconv.h>
#include <locale.h> #include <locale.h>
#endif #endif
#include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/aux_/disable_warnings_pop.hpp"
@ -161,14 +161,14 @@ namespace libtorrent
else else
{ {
ret += '%'; ret += '%';
ret += hex_chars[((unsigned char)*str) >> 4]; ret += hex_chars[boost::uint8_t(*str) >> 4];
ret += hex_chars[((unsigned char)*str) & 15]; ret += hex_chars[boost::uint8_t(*str) & 15];
} }
++str; ++str;
} }
return ret; return ret;
} }
std::string escape_string(const char* str, int len) std::string escape_string(const char* str, int len)
{ {
return escape_string_impl(str, len, 11); return escape_string_impl(str, len, 11);
@ -189,7 +189,7 @@ namespace libtorrent
} }
return false; return false;
} }
void convert_path_to_posix(std::string& path) void convert_path_to_posix(std::string& path)
{ {
for (std::string::iterator i = path.begin() for (std::string::iterator i = path.begin()

View File

@ -34,8 +34,14 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/string_util.hpp" // for allocate_string_copy #include "libtorrent/string_util.hpp" // for allocate_string_copy
#include "libtorrent/file.hpp" #include "libtorrent/file.hpp"
#include "libtorrent/utf8.hpp" #include "libtorrent/utf8.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/crc.hpp> #include <boost/crc.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <cstdio> #include <cstdio>
#include <algorithm> #include <algorithm>
@ -224,7 +230,7 @@ namespace libtorrent
internal_file_entry::~internal_file_entry() internal_file_entry::~internal_file_entry()
{ {
if (name_len == name_is_owned) free((void*)name); if (name_len == name_is_owned) free(const_cast<char*>(name));
} }
internal_file_entry::internal_file_entry(internal_file_entry const& fe) internal_file_entry::internal_file_entry(internal_file_entry const& fe)

View File

@ -81,8 +81,8 @@ namespace libtorrent
std::string ret; std::string ret;
for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) for (std::string::const_iterator i = s.begin(); i != s.end(); ++i)
{ {
ret += hex_chars[((unsigned char)*i) >> 4]; ret += hex_chars[boost::uint8_t(*i) >> 4];
ret += hex_chars[((unsigned char)*i) & 0xf]; ret += hex_chars[boost::uint8_t(*i) & 0xf];
} }
return ret; return ret;
} }
@ -91,8 +91,8 @@ namespace libtorrent
{ {
for (char const* end = in + len; in < end; ++in) for (char const* end = in + len; in < end; ++in)
{ {
*out++ = hex_chars[((unsigned char)*in) >> 4]; *out++ = hex_chars[boost::uint8_t(*in) >> 4];
*out++ = hex_chars[((unsigned char)*in) & 0xf]; *out++ = hex_chars[boost::uint8_t(*in) & 0xf];
} }
*out = '\0'; *out = '\0';
} }

View File

@ -898,7 +898,7 @@ routing_table::add_node_status_t routing_table::add_node_impl(node_entry e)
return node_added; return node_added;
} }
if ((int)rb.size() >= m_bucket_size) if (int(rb.size()) >= m_bucket_size)
{ {
// if the replacement bucket is full, remove the oldest entry // if the replacement bucket is full, remove the oldest entry
// but prefer nodes that haven't been pinged, since they are // but prefer nodes that haven't been pinged, since they are
@ -1174,7 +1174,7 @@ void routing_table::find_node(node_id const& target
{ {
--j; --j;
bucket_t& b = j->live_nodes; bucket_t& b = j->live_nodes;
if (options & include_failed) if (options & include_failed)
{ {
std::copy(b.begin(), b.end(), std::back_inserter(l)); std::copy(b.begin(), b.end(), std::back_inserter(l));

View File

@ -164,7 +164,11 @@ namespace libtorrent
stack.push_back(ent); stack.push_back(ent);
break; break;
} }
default: break; case lazy_entry::int_t:
case lazy_entry::string_t:
case lazy_entry::none_t:
default:
break;
} }
--item_limit; --item_limit;

View File

@ -606,21 +606,21 @@ namespace libtorrent
if (addr.is_v4()) if (addr.is_v4())
{ {
address_v4::bytes_type bytes = addr.to_v4().to_bytes(); address_v4::bytes_type bytes = addr.to_v4().to_bytes();
x.assign((char*)&bytes[0], bytes.size()); x.assign(reinterpret_cast<char*>(bytes.data()), bytes.size());
} }
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
else else
{ {
address_v6::bytes_type bytes = addr.to_v6().to_bytes(); address_v6::bytes_type bytes = addr.to_v6().to_bytes();
x.assign((char*)&bytes[0], bytes.size()); x.assign(reinterpret_cast<char*>(bytes.data()), bytes.size());
} }
#endif #endif
x.append((char*)&t->torrent_file().info_hash()[0], 20); x.append(t->torrent_file().info_hash().data(), 20);
sha1_hash hash = hasher(x.c_str(), x.size()).final(); sha1_hash hash = hasher(x.c_str(), x.size()).final();
for (;;) for (;;)
{ {
char* p = (char*)&hash[0]; char* p = hash.data();
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
{ {
int piece = detail::read_uint32(p) % num_pieces; int piece = detail::read_uint32(p) % num_pieces;
@ -642,7 +642,7 @@ namespace libtorrent
|| int(m_accept_fast.size()) == num_pieces) return; || int(m_accept_fast.size()) == num_pieces) return;
} }
} }
hash = hasher((char*)&hash[0], 20).final(); hash = hasher(hash.data(), 20).final();
} }
} }
@ -878,7 +878,7 @@ namespace libtorrent
if (!peer_info_struct() || peer_info_struct()->fast_reconnects > 1) if (!peer_info_struct() || peer_info_struct()->fast_reconnects > 1)
return; return;
m_fast_reconnect = r; m_fast_reconnect = r;
peer_info_struct()->last_connected = (boost::uint16_t)m_ses.session_time(); peer_info_struct()->last_connected = boost::uint16_t(m_ses.session_time());
int rewind = m_settings.get_int(settings_pack::min_reconnect_time) int rewind = m_settings.get_int(settings_pack::min_reconnect_time)
* m_settings.get_int(settings_pack::max_failcount); * m_settings.get_int(settings_pack::max_failcount);
if (peer_info_struct()->last_connected < rewind) peer_info_struct()->last_connected = 0; if (peer_info_struct()->last_connected < rewind) peer_info_struct()->last_connected = 0;
@ -3295,7 +3295,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
if (has_peer_choked() || !is_interesting()) return false; if (has_peer_choked() || !is_interesting()) return false;
if ((int)m_download_queue.size() + (int)m_request_queue.size() if (int(m_download_queue.size()) + int(m_request_queue.size())
> m_desired_queue_size * 2) return false; > m_desired_queue_size * 2) return false;
if (on_parole()) return false; if (on_parole()) return false;
if (m_disconnecting) return false; if (m_disconnecting) return false;
@ -3747,7 +3747,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); boost::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
@ -3769,13 +3769,13 @@ namespace libtorrent
|| t->state() == torrent_status::allocating) || t->state() == torrent_status::allocating)
return; return;
if ((int)m_download_queue.size() >= m_desired_queue_size if (int(m_download_queue.size()) >= m_desired_queue_size
|| t->upload_mode()) return; || t->upload_mode()) return;
bool empty_download_queue = m_download_queue.empty(); bool empty_download_queue = m_download_queue.empty();
while (!m_request_queue.empty() while (!m_request_queue.empty()
&& ((int)m_download_queue.size() < m_desired_queue_size && (int(m_download_queue.size()) < m_desired_queue_size
|| m_queued_time_critical > 0)) || m_queued_time_critical > 0))
{ {
pending_block block = m_request_queue.front(); pending_block block = m_request_queue.front();
@ -3984,7 +3984,7 @@ namespace libtorrent
if (m_disconnecting) return; if (m_disconnecting) return;
m_socket->set_close_reason(error_to_close_reason(ec)); m_socket->set_close_reason(error_to_close_reason(ec));
close_reason_t close_reason = (close_reason_t)m_socket->get_close_reason(); close_reason_t close_reason = close_reason_t(m_socket->get_close_reason());
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (close_reason != 0) if (close_reason != 0)
{ {
@ -4406,7 +4406,7 @@ namespace libtorrent
p.used_receive_buffer = m_recv_buffer.pos(); p.used_receive_buffer = m_recv_buffer.pos();
p.write_state = m_channel_state[upload_channel]; p.write_state = m_channel_state[upload_channel];
p.read_state = m_channel_state[download_channel]; p.read_state = m_channel_state[download_channel];
// pieces may be empty if we don't have metadata yet // pieces may be empty if we don't have metadata yet
if (p.pieces.size() == 0) if (p.pieces.size() == 0)
{ {
@ -4418,7 +4418,7 @@ namespace libtorrent
#if TORRENT_NO_FPU #if TORRENT_NO_FPU
p.progress = 0.f; p.progress = 0.f;
#else #else
p.progress = (float)p.pieces.count() / (float)p.pieces.size(); p.progress = float(p.pieces.count()) / float(p.pieces.size());
#endif #endif
p.progress_ppm = boost::uint64_t(p.pieces.count()) * 1000000 / p.pieces.size(); p.progress_ppm = boost::uint64_t(p.pieces.count()) * 1000000 / p.pieces.size();
} }
@ -5055,7 +5055,7 @@ namespace libtorrent
peer_request& r = m_requests[i]; peer_request& r = m_requests[i];
TORRENT_ASSERT(r.piece >= 0); TORRENT_ASSERT(r.piece >= 0);
TORRENT_ASSERT(r.piece < (int)m_have_piece.size()); TORRENT_ASSERT(r.piece < int(m_have_piece.size()));
// TORRENT_ASSERT(t->have_piece(r.piece)); // TORRENT_ASSERT(t->have_piece(r.piece));
TORRENT_ASSERT(r.start + r.length <= t->torrent_file().piece_size(r.piece)); TORRENT_ASSERT(r.start + r.length <= t->torrent_file().piece_size(r.piece));
TORRENT_ASSERT(r.length > 0 && r.start >= 0); TORRENT_ASSERT(r.length > 0 && r.start >= 0);
@ -6768,7 +6768,7 @@ namespace libtorrent
// if m_num_pieces == 0, we probably don't have the // if m_num_pieces == 0, we probably don't have the
// metadata yet. // metadata yet.
boost::shared_ptr<torrent> t = m_torrent.lock(); boost::shared_ptr<torrent> t = m_torrent.lock();
return m_num_pieces == (int)m_have_piece.size() return m_num_pieces == int(m_have_piece.size())
&& m_num_pieces > 0 && t && t->valid_metadata(); && m_num_pieces > 0 && t && t->valid_metadata();
} }

View File

@ -492,7 +492,7 @@ namespace libtorrent
} }
if (t != 0) if (t != 0)
TORRENT_ASSERT((int)m_piece_map.size() == t->torrent_file().num_pieces()); TORRENT_ASSERT(int(m_piece_map.size()) == t->torrent_file().num_pieces());
for (int j = 0; j < piece_pos::num_download_categories; ++j) for (int j = 0; j < piece_pos::num_download_categories; ++j)
{ {
@ -1606,7 +1606,7 @@ namespace libtorrent
{ {
TORRENT_PIECE_PICKER_INVARIANT_CHECK; TORRENT_PIECE_PICKER_INVARIANT_CHECK;
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < (int)m_piece_map.size()); TORRENT_ASSERT(index < int(m_piece_map.size()));
piece_pos& p = m_piece_map[index]; piece_pos& p = m_piece_map[index];
@ -1672,7 +1672,7 @@ namespace libtorrent
TORRENT_PIECE_PICKER_INVARIANT_CHECK; TORRENT_PIECE_PICKER_INVARIANT_CHECK;
#endif #endif
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < (int)m_piece_map.size()); TORRENT_ASSERT(index < int(m_piece_map.size()));
#ifdef TORRENT_PICKER_LOG #ifdef TORRENT_PICKER_LOG
std::cerr << "[" << this << "] " << "piece_picker::we_have(" std::cerr << "[" << this << "] " << "piece_picker::we_have("
@ -1752,7 +1752,7 @@ namespace libtorrent
TORRENT_ASSERT(new_piece_priority >= 0); TORRENT_ASSERT(new_piece_priority >= 0);
TORRENT_ASSERT(new_piece_priority < priority_levels); TORRENT_ASSERT(new_piece_priority < priority_levels);
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < (int)m_piece_map.size()); TORRENT_ASSERT(index < int(m_piece_map.size()));
piece_pos& p = m_piece_map[index]; piece_pos& p = m_piece_map[index];
@ -1855,7 +1855,7 @@ namespace libtorrent
int piece_picker::piece_priority(int index) const int piece_picker::piece_priority(int index) const
{ {
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < (int)m_piece_map.size()); TORRENT_ASSERT(index < int(m_piece_map.size()));
return m_piece_map[index].piece_priority; return m_piece_map[index].piece_priority;
} }
@ -2530,8 +2530,8 @@ get_out:
int piece_picker::blocks_in_piece(int index) const int piece_picker::blocks_in_piece(int index) const
{ {
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < (int)m_piece_map.size() || m_piece_map.empty()); TORRENT_ASSERT(index < int(m_piece_map.size()) || m_piece_map.empty());
if (index+1 == (int)m_piece_map.size()) if (index + 1 == int(m_piece_map.size()))
return m_blocks_in_last_piece; return m_blocks_in_last_piece;
else else
return m_blocks_per_piece; return m_blocks_per_piece;
@ -2852,7 +2852,7 @@ get_out:
bool piece_picker::is_piece_finished(int index) const bool piece_picker::is_piece_finished(int index) const
{ {
TORRENT_ASSERT(index < (int)m_piece_map.size()); TORRENT_ASSERT(index < int(m_piece_map.size()));
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
piece_pos const& p = m_piece_map[index]; piece_pos const& p = m_piece_map[index];
@ -2867,7 +2867,7 @@ get_out:
} }
std::vector<downloading_piece>::const_iterator i = find_dl_piece(state, index); std::vector<downloading_piece>::const_iterator i = find_dl_piece(state, index);
TORRENT_ASSERT(i != m_downloads[state].end()); TORRENT_ASSERT(i != m_downloads[state].end());
TORRENT_ASSERT((int)i->finished <= m_blocks_per_piece); TORRENT_ASSERT(int(i->finished) <= m_blocks_per_piece);
int max_blocks = blocks_in_piece(index); int max_blocks = blocks_in_piece(index);
if (int(i->finished) + int(i->writing) < max_blocks) return false; if (int(i->finished) + int(i->writing) < max_blocks) return false;
TORRENT_ASSERT(int(i->finished) + int(i->writing) == max_blocks); TORRENT_ASSERT(int(i->finished) + int(i->writing) == max_blocks);
@ -2887,7 +2887,7 @@ get_out:
bool piece_picker::has_piece_passed(int index) const bool piece_picker::has_piece_passed(int index) const
{ {
TORRENT_ASSERT(index < (int)m_piece_map.size()); TORRENT_ASSERT(index < int(m_piece_map.size()));
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
piece_pos const& p = m_piece_map[index]; piece_pos const& p = m_piece_map[index];
@ -3621,7 +3621,7 @@ get_out:
void piece_picker::get_downloaders(std::vector<void*>& d, int index) const void piece_picker::get_downloaders(std::vector<void*>& d, int index) const
{ {
TORRENT_ASSERT(index >= 0 && index <= (int)m_piece_map.size()); TORRENT_ASSERT(index >= 0 && index <= int(m_piece_map.size()));
d.clear(); d.clear();
int state = m_piece_map[index].download_queue(); int state = m_piece_map[index].download_queue();
@ -3751,7 +3751,7 @@ get_out:
for (std::vector<downloading_piece>::const_iterator i = m_downloads[k].begin(); for (std::vector<downloading_piece>::const_iterator i = m_downloads[k].begin();
i != m_downloads[k].end(); ++i) i != m_downloads[k].end(); ++i)
{ {
counter += (int)i->finished; counter += int(i->finished);
} }
} }
return counter; return counter;

View File

@ -76,7 +76,7 @@ struct feed_state
{ {
case atom: return string_equal_no_case(tag, "entry"); case atom: return string_equal_no_case(tag, "entry");
case rss2: return string_equal_no_case(tag, "item"); case rss2: return string_equal_no_case(tag, "item");
default: return false; case none: return false;
} }
} }
@ -86,7 +86,7 @@ struct feed_state
{ {
case atom: case atom:
case rss2: return string_equal_no_case(tag, "title"); case rss2: return string_equal_no_case(tag, "title");
default: return false; case none: return false;
} }
} }
@ -96,7 +96,7 @@ struct feed_state
{ {
case atom: case atom:
case rss2: return string_equal_no_case(tag, "link"); case rss2: return string_equal_no_case(tag, "link");
default: return false; case none: return false;
} }
} }
@ -107,7 +107,7 @@ struct feed_state
case atom: return string_equal_no_case(tag, "summary"); case atom: return string_equal_no_case(tag, "summary");
case rss2: return string_equal_no_case(tag, "description") case rss2: return string_equal_no_case(tag, "description")
|| string_equal_no_case(tag, "media:text"); || string_equal_no_case(tag, "media:text");
default: return false; case none: return false;
} }
} }
@ -117,7 +117,7 @@ struct feed_state
{ {
case atom: return string_equal_no_case(tag, "id"); case atom: return string_equal_no_case(tag, "id");
case rss2: return string_equal_no_case(tag, "guid"); case rss2: return string_equal_no_case(tag, "guid");
default: return false; case none: return false;
} }
} }
@ -127,7 +127,7 @@ struct feed_state
{ {
case atom: return false; case atom: return false;
case rss2: return string_equal_no_case(tag, "comments"); case rss2: return string_equal_no_case(tag, "comments");
default: return false; case none: return false;
} }
} }
@ -137,14 +137,14 @@ struct feed_state
{ {
case atom: return false; case atom: return false;
case rss2: return string_equal_no_case(tag, "category"); case rss2: return string_equal_no_case(tag, "category");
default: return false; case none: return false;
} }
} }
bool is_size(char const* tag) const bool is_size(char const* tag) const
{ {
return string_equal_no_case(tag, "size") return string_equal_no_case(tag, "size")
|| string_equal_no_case(tag, "contentlength"); || string_equal_no_case(tag, "contentlength");
} }
bool is_hash(char const* tag) const bool is_hash(char const* tag) const
@ -262,7 +262,7 @@ void parse_feed(feed_state& f, int token, char const* name, char const* val)
f.current_item.size = strtoll(name, 0, 10); f.current_item.size = strtoll(name, 0, 10);
else if (f.is_hash(f.current_tag.c_str()) && strlen(name) == 40) else if (f.is_hash(f.current_tag.c_str()) && strlen(name) == 40)
{ {
if (!from_hex(name, 40, (char*)&f.current_item.info_hash[0])) if (!from_hex(name, 40, f.current_item.info_hash.data()))
{ {
// hex parsing failed // hex parsing failed
f.current_item.info_hash.clear(); f.current_item.info_hash.clear();

View File

@ -414,7 +414,7 @@ namespace libtorrent
// close files that were opened in write mode // close files that were opened in write mode
m_pool.release(this); m_pool.release(this);
#if TORRENT_DEBUG_FILE_LEAKS #if defined TORRENT_DEBUG_FILE_LEAKS
print_open_files("release files", m_files.name().c_str()); print_open_files("release files", m_files.name().c_str());
#endif #endif
} }
@ -492,7 +492,7 @@ namespace libtorrent
// valid. // valid.
if (exists(old_name, ec.ec)) if (exists(old_name, ec.ec))
{ {
#if TORRENT_DEBUG_FILE_LEAKS #if defined TORRENT_DEBUG_FILE_LEAKS
print_open_files("release files", m_files.name().c_str()); print_open_files("release files", m_files.name().c_str());
#endif #endif
@ -547,7 +547,7 @@ namespace libtorrent
// make sure we don't have the files open // make sure we don't have the files open
m_pool.release(this); m_pool.release(this);
#if TORRENT_DEBUG_FILE_LEAKS #if defined TORRENT_DEBUG_FILE_LEAKS
print_open_files("release files", m_files.name().c_str()); print_open_files("release files", m_files.name().c_str());
#endif #endif
} }
@ -573,7 +573,7 @@ namespace libtorrent
// case // case
if (!m_pool.assert_idle_files(this)) if (!m_pool.assert_idle_files(this))
{ {
#if TORRENT_DEBUG_FILE_LEAKS #if defined TORRENT_DEBUG_FILE_LEAKS
print_open_files("delete-files idle assert failed", m_files.name().c_str()); print_open_files("delete-files idle assert failed", m_files.name().c_str());
#endif #endif
TORRENT_ASSERT(false); TORRENT_ASSERT(false);
@ -583,7 +583,7 @@ namespace libtorrent
// make sure we don't have the files open // make sure we don't have the files open
m_pool.release(this); m_pool.release(this);
#if TORRENT_DEBUG_FILE_LEAKS #if defined TORRENT_DEBUG_FILE_LEAKS
print_open_files("release files", m_files.name().c_str()); print_open_files("release files", m_files.name().c_str());
#endif #endif
@ -633,7 +633,7 @@ namespace libtorrent
DFLOG(stderr, "[%p] delete_files result: %s\n", this, ec.ec.message().c_str()); DFLOG(stderr, "[%p] delete_files result: %s\n", this, ec.ec.message().c_str());
#if TORRENT_DEBUG_FILE_LEAKS #if defined TORRENT_DEBUG_FILE_LEAKS
print_open_files("delete-files done", m_files.name().c_str()); print_open_files("delete-files done", m_files.name().c_str());
#endif #endif
} }
@ -1003,7 +1003,7 @@ namespace libtorrent
m_pool.release(this); m_pool.release(this);
#if TORRENT_DEBUG_FILE_LEAKS #if defined TORRENT_DEBUG_FILE_LEAKS
print_open_files("release files", m_files.name().c_str()); print_open_files("release files", m_files.name().c_str());
#endif #endif
@ -1431,9 +1431,9 @@ namespace libtorrent
#endif #endif
} }
bool storage_piece_set::has_piece(cached_piece_entry* p) const bool storage_piece_set::has_piece(cached_piece_entry const* p) const
{ {
return m_cached_pieces.count(p) > 0; return m_cached_pieces.count(const_cast<cached_piece_entry*>(p)) > 0;
} }
void storage_piece_set::remove_piece(cached_piece_entry* p) void storage_piece_set::remove_piece(cached_piece_entry* p)

View File

@ -6947,7 +6947,7 @@ namespace libtorrent
if (!m_source_feed_url.empty()) ret["feed"] = m_source_feed_url; if (!m_source_feed_url.empty()) ret["feed"] = m_source_feed_url;
const sha1_hash& info_hash = torrent_file().info_hash(); const sha1_hash& info_hash = torrent_file().info_hash();
ret["info-hash"] = std::string((char*)info_hash.begin(), (char*)info_hash.end()); ret["info-hash"] = info_hash.to_string();
if (valid_metadata()) if (valid_metadata())
{ {