more warning fixes and cleanup

This commit is contained in:
Arvid Norberg 2015-04-18 22:00:27 +00:00
parent 60d1b8fa7c
commit 51e86ca2d5
16 changed files with 122 additions and 61 deletions

View File

@ -1822,7 +1822,7 @@ namespace libtorrent
add_torrent_alert(aux::stack_allocator& alloc, torrent_handle h
, add_torrent_params const& p, error_code ec);
TORRENT_DEFINE_ALERT_PRIO(add_torrent_alert, 67);
TORRENT_DEFINE_ALERT_PRIO(add_torrent_alert, 67)
static const int static_category = alert::status_notification;
virtual std::string message() const;
@ -1845,9 +1845,8 @@ namespace libtorrent
// filtering, since it's only manually posted anyway.
struct TORRENT_EXPORT state_update_alert : alert
{
state_update_alert(aux::stack_allocator& alloc, std::vector<torrent_status> st)
: status(st)
{}
state_update_alert(aux::stack_allocator& alloc
, std::vector<torrent_status> st);
TORRENT_DEFINE_ALERT_PRIO(state_update_alert, 68)
@ -1868,7 +1867,7 @@ namespace libtorrent
struct TORRENT_EXPORT mmap_cache_alert : alert
{
mmap_cache_alert(aux::stack_allocator& alloc
, error_code const& ec): error(ec) {}
, error_code const& ec);
TORRENT_DEFINE_ALERT(mmap_cache_alert, 69)
static const int static_category = alert::error_notification;
@ -2093,11 +2092,7 @@ namespace libtorrent
// internal
dht_outgoing_get_peers_alert(aux::stack_allocator& alloc
, sha1_hash const& ih, sha1_hash const& obfih
, udp::endpoint ep)
: info_hash(ih)
, obfuscated_info_hash(obfih)
, ip(ep)
{}
, udp::endpoint ep);
TORRENT_DEFINE_ALERT(dht_outgoing_get_peers_alert, 78)
@ -2187,10 +2182,7 @@ namespace libtorrent
struct TORRENT_EXPORT lsd_error_alert : alert
{
// internal
lsd_error_alert(aux::stack_allocator& alloc, error_code const& ec)
: alert()
, error(ec)
{}
lsd_error_alert(aux::stack_allocator& alloc, error_code const& ec);
TORRENT_DEFINE_ALERT(lsd_error_alert, 82)
@ -2264,11 +2256,7 @@ namespace libtorrent
// internal
dht_stats_alert(aux::stack_allocator& alloc
, std::vector<dht_routing_bucket> const& table
, std::vector<dht_lookup> const& requests)
: alert()
, active_requests(requests)
, routing_table(table)
{}
, std::vector<dht_lookup> const& requests);
TORRENT_DEFINE_ALERT(dht_stats_alert, 83)

View File

@ -38,10 +38,15 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/address.hpp"
#include "libtorrent/error_code.hpp"
#include "aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/function/function3.hpp>
#include <list>
#include "aux_/disable_warnings_pop.hpp"
namespace libtorrent
{

View File

@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_DISK_IO_THREAD
#define TORRENT_DISK_IO_THREAD
#include "libtorrent/config.hpp"
#include "libtorrent/storage.hpp"
#include "libtorrent/allocator.hpp"
#include "libtorrent/io_service.hpp"
@ -43,6 +44,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/file_pool.hpp"
#include "libtorrent/disk_interface.hpp"
#include "libtorrent/performance_counters.hpp"
#include "libtorrent/aux_/session_settings.hpp"
#include "libtorrent/thread.hpp"
#include "aux_/disable_warnings_push.hpp"
#include <boost/function/function0.hpp>
#include <boost/noncopyable.hpp>
@ -50,14 +55,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/optional.hpp>
#include <boost/shared_ptr.hpp>
#include <deque>
#include "libtorrent/config.hpp"
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
#include <boost/pool/pool.hpp>
#endif
#include "libtorrent/aux_/session_settings.hpp"
#include "libtorrent/thread.hpp"
#include <boost/atomic.hpp>
#include "aux_/disable_warnings_pop.hpp"
namespace libtorrent
{
class alert;

View File

@ -33,9 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef FIND_DATA_050323_HPP
#define FIND_DATA_050323_HPP
#include <vector>
#include <map>
#include <libtorrent/kademlia/traversal_algorithm.hpp>
#include <libtorrent/kademlia/node_id.hpp>
#include <libtorrent/kademlia/routing_table.hpp>
@ -43,10 +40,17 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/kademlia/observer.hpp>
#include <libtorrent/kademlia/msg.hpp>
#include "aux_/disable_warnings_push.hpp"
#include <vector>
#include <map>
#include <boost/optional.hpp>
#include <boost/function/function1.hpp>
#include <boost/function/function2.hpp>
#include "aux_/disable_warnings_pop.hpp"
namespace libtorrent { namespace dht
{

View File

@ -33,12 +33,17 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef OBSERVER_HPP
#define OBSERVER_HPP
#include <libtorrent/time.hpp>
#include <libtorrent/address.hpp>
#include "aux_/disable_warnings_push.hpp"
#include <boost/pool/pool.hpp>
#include <boost/detail/atomic_count.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/cstdint.hpp>
#include <libtorrent/time.hpp>
#include <libtorrent/address.hpp>
#include "aux_/disable_warnings_pop.hpp"
namespace libtorrent {
namespace dht {

View File

@ -40,10 +40,14 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/error_code.hpp"
#include "libtorrent/deadline_timer.hpp"
#include "aux_/disable_warnings_push.hpp"
#include <boost/function/function1.hpp>
#include <boost/function/function4.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "aux_/disable_warnings_pop.hpp"
namespace libtorrent
{

View File

@ -764,7 +764,8 @@ namespace libtorrent
virtual void on_sent(error_code const& error
, std::size_t bytes_transferred) = 0;
virtual int hit_send_barrier(std::vector<asio::mutable_buffer>& iovec) { return INT_MAX; }
virtual int hit_send_barrier(std::vector<asio::mutable_buffer>&)
{ return INT_MAX; }
bool allocate_disk_receive_buffer(int disk_buffer_size);

View File

@ -461,10 +461,10 @@ namespace libtorrent
// functor that compares indices on downloading_pieces
struct has_index
{
has_index(int i): index(i) { TORRENT_ASSERT(i >= 0); }
has_index(int i): index(boost::uint32_t(i)) { TORRENT_ASSERT(i >= 0); }
bool operator()(const downloading_piece& p) const
{ return p.index == index; }
int index;
boost::uint32_t index;
};
int blocks_in_last_piece() const

View File

@ -38,7 +38,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/address.hpp"
#include "libtorrent/error_code.hpp"
#include "aux_/disable_warnings_push.hpp"
#include <boost/function/function1.hpp>
#include "aux_/disable_warnings_pop.hpp"
namespace libtorrent {

View File

@ -200,8 +200,7 @@ namespace libtorrent
// used as the peer-id
peer_fingerprint,
max_string_setting_internal,
num_string_settings = max_string_setting_internal - string_type_base
max_string_setting_internal
};
enum bool_types
@ -650,8 +649,7 @@ namespace libtorrent
// unlikely to matter anyway
auto_sequential,
max_bool_setting_internal,
num_bool_settings = max_bool_setting_internal - bool_type_base
max_bool_setting_internal
};
enum int_types
@ -1512,8 +1510,13 @@ namespace libtorrent
// .. _i2p: http://www.i2p2.de
i2p_port,
max_int_setting_internal,
max_int_setting_internal
};
enum settings_counts_t
{
num_string_settings = max_string_setting_internal - string_type_base,
num_bool_settings = max_bool_setting_internal - bool_type_base,
num_int_settings = max_int_setting_internal - int_type_base
};

View File

@ -107,13 +107,13 @@ namespace libtorrent
explicit sha1_hash(std::string const& s)
{
TORRENT_ASSERT(s.size() >= 20);
int sl = int(s.size()) < size ? int(s.size()) : size;
size_t sl = s.size() < size_t(size) ? s.size() : size_t(size);
std::memcpy(m_number, s.c_str(), sl);
}
void assign(std::string const& s)
{
TORRENT_ASSERT(s.size() >= 20);
int sl = int(s.size()) < size ? int(s.size()) : size;
size_t sl = s.size() < size_t(size) ? s.size() : size_t(size);
std::memcpy(m_number, s.c_str(), sl);
}
void assign(char const* str) { std::memcpy(m_number, str, size); }
@ -133,7 +133,7 @@ namespace libtorrent
sha1_hash& operator<<=(int n)
{
TORRENT_ASSERT(n >= 0);
int num_words = n / 32;
const size_t num_words = size_t(n) / 32;
if (num_words >= number_size)
{
std::memset(m_number, 0, size);
@ -172,10 +172,10 @@ namespace libtorrent
sha1_hash& operator>>=(int n)
{
TORRENT_ASSERT(n >= 0);
int num_words = n / 32;
const size_t num_words = size_t(n) / 32;
if (num_words >= number_size)
{
std::memset(m_number, 0, size);
std::memset(m_number, 0, size_t(size));
return *this;
}
if (num_words > 0)
@ -305,7 +305,10 @@ namespace libtorrent
// return a copy of the 20 bytes representing the sha1-hash as a std::string.
// It's still a binary string with 20 binary characters.
std::string to_string() const
{ return std::string(reinterpret_cast<char const*>(&m_number[0]), size); }
{
return std::string(reinterpret_cast<char const*>(&m_number[0])
, size_t(size));
}
private:

View File

@ -526,7 +526,7 @@ namespace libtorrent
, int offset, int flags, storage_error& ec);
bool verify_resume_data(bdecode_node const&
, std::vector<std::string> const* links
, std::vector<std::string> const*
, storage_error&) { return false; }
void write_resume_data(entry&, storage_error&) const {}

View File

@ -47,7 +47,7 @@ namespace libtorrent
inline N* postinc(N*& e)
{
N* ret = e;
e = (N*)ret->next;
e = static_cast<N*>(ret->next);
return ret;
}

View File

@ -36,8 +36,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/torrent_peer.hpp"
#include "aux_/disable_warnings_push.hpp"
#include <boost/pool/pool.hpp>
#include "aux_/disable_warnings_pop.hpp"
namespace libtorrent
{

View File

@ -846,7 +846,7 @@ namespace libtorrent {
}
udp_error_alert::udp_error_alert(
aux::stack_allocator& alloc
aux::stack_allocator&
, udp::endpoint const& ep
, error_code const& ec)
: endpoint(ep)
@ -859,7 +859,7 @@ namespace libtorrent {
return "UDP error: " + convert_from_native(error.message()) + " from: " + endpoint.address().to_string(ec);
}
external_ip_alert::external_ip_alert(aux::stack_allocator& alloc
external_ip_alert::external_ip_alert(aux::stack_allocator&
, address const& ip)
: external_address(ip)
{}
@ -870,7 +870,7 @@ namespace libtorrent {
return "external IP received: " + external_address.to_string(ec);
}
listen_succeeded_alert::listen_succeeded_alert(aux::stack_allocator& alloc
listen_succeeded_alert::listen_succeeded_alert(aux::stack_allocator&
, tcp::endpoint const& ep, socket_type_t t)
: endpoint(ep)
, sock_type(t)
@ -884,7 +884,7 @@ namespace libtorrent {
return ret;
}
portmap_error_alert::portmap_error_alert(aux::stack_allocator& alloc
portmap_error_alert::portmap_error_alert(aux::stack_allocator&
, int i, int t, error_code const& e)
: mapping(i), map_type(t), error(e)
{
@ -899,7 +899,7 @@ namespace libtorrent {
+ ": " + convert_from_native(error.message());
}
portmap_alert::portmap_alert(aux::stack_allocator& alloc, int i, int port, int t)
portmap_alert::portmap_alert(aux::stack_allocator&, int i, int port, int t)
: mapping(i), external_port(port), map_type(t)
{}
@ -993,7 +993,7 @@ namespace libtorrent {
return ret;
}
dht_announce_alert::dht_announce_alert(aux::stack_allocator& alloc
dht_announce_alert::dht_announce_alert(aux::stack_allocator&
, address const& i, int p
, sha1_hash const& ih)
: ip(i)
@ -1012,7 +1012,7 @@ namespace libtorrent {
return msg;
}
dht_get_peers_alert::dht_get_peers_alert(aux::stack_allocator& alloc
dht_get_peers_alert::dht_get_peers_alert(aux::stack_allocator&
, sha1_hash const& ih)
: info_hash(ih)
{}
@ -1134,7 +1134,7 @@ namespace libtorrent {
return std::string("trackerid received: ") + tracker_id();
}
dht_bootstrap_alert::dht_bootstrap_alert(aux::stack_allocator& alloc)
dht_bootstrap_alert::dht_bootstrap_alert(aux::stack_allocator&)
{}
std::string dht_bootstrap_alert::message() const
@ -1143,7 +1143,7 @@ namespace libtorrent {
}
#ifndef TORRENT_NO_DEPRECATE
rss_alert::rss_alert(aux::stack_allocator& alloc, feed_handle h
rss_alert::rss_alert(aux::stack_allocator&, feed_handle h
, std::string const& u, int s, error_code const& ec)
: handle(h), url(u), state(s), error(ec)
{}
@ -1208,7 +1208,7 @@ namespace libtorrent {
return torrent_alert::message() + " needs SSL certificate";
}
incoming_connection_alert::incoming_connection_alert(aux::stack_allocator& alloc, int t
incoming_connection_alert::incoming_connection_alert(aux::stack_allocator&, int t
, tcp::endpoint const& i)
: socket_type(t)
, ip(i)
@ -1268,6 +1268,11 @@ namespace libtorrent {
return msg;
}
state_update_alert::state_update_alert(aux::stack_allocator&
, std::vector<torrent_status> st)
: status(st)
{}
std::string state_update_alert::message() const
{
char msg[600];
@ -1275,6 +1280,10 @@ namespace libtorrent {
return msg;
}
mmap_cache_alert::mmap_cache_alert(aux::stack_allocator&
, error_code const& ec): error(ec)
{}
std::string mmap_cache_alert::message() const
{
char msg[600];
@ -1327,7 +1336,7 @@ namespace libtorrent {
"get_interface",
};
if (op < 0 || op >= sizeof(names)/sizeof(names[0]))
if (op < 0 || op >= int(sizeof(names)/sizeof(names[0])))
return "unknown operation";
return names[op];
@ -1350,7 +1359,7 @@ namespace libtorrent {
}
#ifndef TORRENT_NO_DEPRECATE
rss_item_alert::rss_item_alert(aux::stack_allocator& alloc, feed_handle h
rss_item_alert::rss_item_alert(aux::stack_allocator&, feed_handle h
, feed_item const& item)
: handle(h)
, item(item)
@ -1393,7 +1402,8 @@ namespace libtorrent {
return msg;
}
dht_error_alert::dht_error_alert(aux::stack_allocator& alloc, int op, error_code const& ec)
dht_error_alert::dht_error_alert(aux::stack_allocator&, int op
, error_code const& ec)
: error(ec), operation(op_t(op))
{}
@ -1417,7 +1427,7 @@ namespace libtorrent {
return msg;
}
dht_immutable_item_alert::dht_immutable_item_alert(aux::stack_allocator& alloc
dht_immutable_item_alert::dht_immutable_item_alert(aux::stack_allocator&
, sha1_hash const& t, entry const& i)
: target(t), item(i)
{}
@ -1431,7 +1441,9 @@ namespace libtorrent {
return msg;
}
dht_mutable_item_alert::dht_mutable_item_alert(aux::stack_allocator& alloc
// TODO: 2 the salt here is allocated on the heap. It would be nice to
// allocate in in the stack_allocator
dht_mutable_item_alert::dht_mutable_item_alert(aux::stack_allocator&
, boost::array<char, 32> k
, boost::array<char, 64> sig
, boost::uint64_t sequence
@ -1451,12 +1463,12 @@ namespace libtorrent {
return msg;
}
dht_put_alert::dht_put_alert(aux::stack_allocator& alloc, sha1_hash const& t)
dht_put_alert::dht_put_alert(aux::stack_allocator&, sha1_hash const& t)
: target(t)
, seq(0)
{}
dht_put_alert::dht_put_alert(aux::stack_allocator& alloc
dht_put_alert::dht_put_alert(aux::stack_allocator&
, boost::array<char, 32> key
, boost::array<char, 64> sig
, std::string s
@ -1479,7 +1491,7 @@ namespace libtorrent {
return msg;
}
i2p_alert::i2p_alert(aux::stack_allocator& alloc, error_code const& ec)
i2p_alert::i2p_alert(aux::stack_allocator&, error_code const& ec)
: error(ec)
{}
@ -1491,6 +1503,14 @@ namespace libtorrent {
return msg;
}
dht_outgoing_get_peers_alert::dht_outgoing_get_peers_alert(aux::stack_allocator&
, sha1_hash const& ih, sha1_hash const& obfih
, udp::endpoint ep)
: info_hash(ih)
, obfuscated_info_hash(obfih)
, ip(ep)
{}
std::string dht_outgoing_get_peers_alert::message() const
{
char msg[600];
@ -1556,6 +1576,11 @@ namespace libtorrent {
return torrent_alert::message() + " [" + print_endpoint(ip) + "] " + msg();
}
lsd_error_alert::lsd_error_alert(aux::stack_allocator&, error_code const& ec)
: alert()
, error(ec)
{}
std::string lsd_error_alert::message() const
{
return "Local Service Discovery error: " + error.message();
@ -1574,6 +1599,14 @@ namespace libtorrent {
return msg;
}
dht_stats_alert::dht_stats_alert(aux::stack_allocator&
, std::vector<dht_routing_bucket> const& table
, std::vector<dht_lookup> const& requests)
: alert()
, active_requests(requests)
, routing_table(table)
{}
std::string dht_stats_alert::message() const
{
char buf[2048];

View File

@ -1590,6 +1590,8 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
// defined in storage.cpp
int bufs_size(file::iovec_t const* bufs, int num_bufs);
namespace {
void gather_copy(file::iovec_t const* bufs, int num_bufs, char* dst)
{
int offset = 0;
@ -1741,6 +1743,8 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
#endif
}
} // anonymous namespace
// this has to be thread safe and atomic. i.e. on posix systems it has to be
// turned into a series of pread() calls
boost::int64_t file::readv(boost::int64_t file_offset, iovec_t const* bufs, int num_bufs