diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 7bf75c791..3095dbd4b 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -260,7 +260,7 @@ namespace libtorrent std::string const& collection) const TORRENT_OVERRIDE TORRENT_FINAL; #endif boost::weak_ptr 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 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; } diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index 4d6a8b9cd..64913cd6d 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -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 diff --git a/include/libtorrent/bandwidth_socket.hpp b/include/libtorrent/bandwidth_socket.hpp index ed4ba8154..80e8602b3 100644 --- a/include/libtorrent/bandwidth_socket.hpp +++ b/include/libtorrent/bandwidth_socket.hpp @@ -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; diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index a27aebdcf..1de991ceb 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -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 diff --git a/include/libtorrent/block_cache.hpp b/include/libtorrent/block_cache.hpp index dac2485ef..9b9e6afe6 100644 --- a/include/libtorrent/block_cache.hpp +++ b/include/libtorrent/block_cache.hpp @@ -360,12 +360,12 @@ namespace libtorrent // returns a range of all pieces. This migh be a very // long list, use carefully std::pair all_pieces() const; - int num_pieces() const { return m_pieces.size(); } + int num_pieces() const { return int(m_pieces.size()); } list_iterator 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 diff --git a/include/libtorrent/broadcast_socket.hpp b/include/libtorrent/broadcast_socket.hpp index 35bd81c18..d484c30ad 100644 --- a/include/libtorrent/broadcast_socket.hpp +++ b/include/libtorrent/broadcast_socket.hpp @@ -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: diff --git a/include/libtorrent/disk_buffer_holder.hpp b/include/libtorrent/disk_buffer_holder.hpp index 0aa37fe03..161f234cb 100644 --- a/include/libtorrent/disk_buffer_holder.hpp +++ b/include/libtorrent/disk_buffer_holder.hpp @@ -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; diff --git a/include/libtorrent/disk_interface.hpp b/include/libtorrent/disk_interface.hpp index ab0656703..0aea0a213 100644 --- a/include/libtorrent/disk_interface.hpp +++ b/include/libtorrent/disk_interface.hpp @@ -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 const& handler, void* requester diff --git a/include/libtorrent/disk_job_pool.hpp b/include/libtorrent/disk_job_pool.hpp index f6158eb2b..c67fbe002 100644 --- a/include/libtorrent/disk_job_pool.hpp +++ b/include/libtorrent/disk_job_pool.hpp @@ -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(); diff --git a/include/libtorrent/disk_observer.hpp b/include/libtorrent/disk_observer.hpp index 2e746e7e7..c91810c41 100644 --- a/include/libtorrent/disk_observer.hpp +++ b/include/libtorrent/disk_observer.hpp @@ -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 diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index 5c3181739..5603b5d52 100644 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -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) {} diff --git a/include/libtorrent/kademlia/dht_observer.hpp b/include/libtorrent/kademlia/dht_observer.hpp index ba9c9d389..6bf067183 100644 --- a/include/libtorrent/kademlia/dht_observer.hpp +++ b/include/libtorrent/kademlia/dht_observer.hpp @@ -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; diff --git a/include/libtorrent/peer_class.hpp b/include/libtorrent/peer_class.hpp index e985dcbee..946795fe0 100644 --- a/include/libtorrent/peer_class.hpp +++ b/include/libtorrent/peer_class.hpp @@ -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); diff --git a/include/libtorrent/peer_class_set.hpp b/include/libtorrent/peer_class_set.hpp index 55bbb173a..db4d0f8e5 100644 --- a/include/libtorrent/peer_class_set.hpp +++ b/include/libtorrent/peer_class_set.hpp @@ -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); diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 9532937ac..32cf2491f 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -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&); }; } diff --git a/include/libtorrent/peer_connection_interface.hpp b/include/libtorrent/peer_connection_interface.hpp index f2569695e..9bee7867e 100644 --- a/include/libtorrent/peer_connection_interface.hpp +++ b/include/libtorrent/peer_connection_interface.hpp @@ -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; diff --git a/include/libtorrent/resolve_links.hpp b/include/libtorrent/resolve_links.hpp index 9e4dec038..8484c8205 100644 --- a/include/libtorrent/resolve_links.hpp +++ b/include/libtorrent/resolve_links.hpp @@ -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 ti; std::string save_path; diff --git a/include/libtorrent/resolver_interface.hpp b/include/libtorrent/resolver_interface.hpp index 838128cf7..66ade6c9c 100644 --- a/include/libtorrent/resolver_interface.hpp +++ b/include/libtorrent/resolver_interface.hpp @@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -struct resolver_interface +struct TORRENT_EXTRA_EXPORT resolver_interface { typedef boost::function const&)> callback_t; diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index 4386eddce..5b4e544fd 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -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 diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index 41bf91521..731d34a5b 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -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)); diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 68aab65f6..36e860032 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -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 const& cached_pieces() const { return m_cached_pieces; } private: diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 8aa006403..271f16c84 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -177,7 +177,7 @@ namespace libtorrent std::vector 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: diff --git a/include/libtorrent/torrent_peer_allocator.hpp b/include/libtorrent/torrent_peer_allocator.hpp index a298d94b8..af0ca9249 100644 --- a/include/libtorrent/torrent_peer_allocator.hpp +++ b/include/libtorrent/torrent_peer_allocator.hpp @@ -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 { diff --git a/include/libtorrent/udp_socket.hpp b/include/libtorrent/udp_socket.hpp index cb3c47c2a..83442e970 100644 --- a/include/libtorrent/udp_socket.hpp +++ b/include/libtorrent/udp_socket.hpp @@ -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) diff --git a/include/libtorrent/uncork_interface.hpp b/include/libtorrent/uncork_interface.hpp index 7e2653d2c..ce01e10a7 100644 --- a/include/libtorrent/uncork_interface.hpp +++ b/include/libtorrent/uncork_interface.hpp @@ -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: diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index e248c4823..f98bd5254 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -313,7 +313,7 @@ public: m_connect_handler = handler; do_connect(endpoint); } - + template void async_read_some(Mutable_Buffers const& buffers, Handler const& handler) { @@ -329,7 +329,7 @@ public: m_io_service.post(boost::bind(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) { diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index 40c988748..aeff5ddb4 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -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. diff --git a/src/file.cpp b/src/file.cpp index ab445cbeb..695fcc71d 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -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); diff --git a/src/magnet_uri.cpp b/src/magnet_uri.cpp index 959ce69e8..1d01ec546 100644 --- a/src/magnet_uri.cpp +++ b/src/magnet_uri.cpp @@ -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 const& tr = handle.trackers(); for (std::vector::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 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;