fix gcc warnings

This commit is contained in:
Arvid Norberg 2015-05-18 01:30:32 +00:00
parent 71ee44ae5e
commit e7d369646d
14 changed files with 98 additions and 104 deletions

View File

@ -260,13 +260,20 @@ namespace libtorrent {
// when the alert queue is full. There are a few alerts which may not be discared,
// since they would break the user contract, such as save_resume_data_alert.
TORRENT_DEPRECATED
virtual bool discardable() const { return true; }
bool discardable() const { return discardable_impl(); }
TORRENT_DEPRECATED
severity_t severity() const { return warning; }
// returns a pointer to a copy of the alert.
virtual std::auto_ptr<alert> clone() const = 0;
TORRENT_DEPRECATED
std::auto_ptr<alert> clone() const { return clone_impl(); }
protected:
virtual bool discardable_impl() const { return true; }
virtual std::auto_ptr<alert> clone_impl() const = 0;
#endif
private:

View File

@ -143,10 +143,13 @@ namespace libtorrent
#ifndef TORRENT_NO_DEPRECATE
#define TORRENT_CLONE(name) \
virtual std::auto_ptr<alert> clone() const \
virtual std::auto_ptr<alert> clone_impl() const TORRENT_OVERRIDE \
{ return std::auto_ptr<alert>(new name(*this)); }
#define TORRENT_NOT_DISCARDABLE \
virtual bool discardable_impl() TORRENT_OVERRIDE { return false; }
#else
#define TORRENT_CLONE(name)
#define TORRENT_NOT_DISCARDABLE
#endif
#define TORRENT_DEFINE_ALERT_IMPL(name, seq, prio) \
@ -198,9 +201,7 @@ namespace libtorrent
TORRENT_DEFINE_ALERT_PRIO(torrent_removed_alert, 4)
static const int static_category = alert::status_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
sha1_hash info_hash;
};
@ -212,7 +213,7 @@ namespace libtorrent
// number of bytes that was read.
//
// If the operation fails, ec will indicat what went wrong.
struct TORRENT_EXPORT read_piece_alert: torrent_alert
struct TORRENT_EXPORT read_piece_alert: torrent_alert
{
// internal
read_piece_alert(aux::stack_allocator& alloc, torrent_handle const& h
@ -223,9 +224,7 @@ namespace libtorrent
static const int static_category = alert::storage_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
error_code ec;
boost::shared_array<char> buffer;
@ -263,9 +262,8 @@ namespace libtorrent
static const int static_category = alert::storage_notification;
virtual std::string message() const;
TORRENT_NOT_DISCARDABLE
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
std::string name;
#endif
@ -291,9 +289,7 @@ namespace libtorrent
static const int static_category = alert::storage_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// refers to the index of the file that was supposed to be renamed,
// ``error`` is the error code returned from the filesystem.
@ -328,7 +324,7 @@ namespace libtorrent
// is posted, there is a risk that the number of outstanding requests is too low
// and limits the download rate. You might want to increase the ``max_out_request_queue``
// setting.
outstanding_request_limit_reached,
outstanding_request_limit_reached,
// This warning is posted when the amount of TCP/IP overhead is greater than the
// upload rate limit. When this happens, the TCP/IP overhead is caused by a much
@ -354,7 +350,7 @@ namespace libtorrent
// send it all before the disk gets back to us.
// The number of bytes that we keep outstanding, requested from the disk, is calculated
// as follows::
//
//
// min(512, max(upload_rate * send_buffer_watermark_factor / 100, send_buffer_watermark))
//
// If you receive this alert, you migth want to either increase your ``send_buffer_watermark``
@ -967,9 +963,7 @@ namespace libtorrent
static const int static_category = alert::storage_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
sha1_hash info_hash;
};
@ -988,9 +982,7 @@ namespace libtorrent
| alert::error_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// tells you why it failed.
error_code error;
@ -1017,9 +1009,7 @@ namespace libtorrent
static const int static_category = alert::storage_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// points to the resume data.
boost::shared_ptr<entry> resume_data;
@ -1039,9 +1029,7 @@ namespace libtorrent
| alert::error_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// the error code from the resume_data failure
error_code error;
@ -1288,9 +1276,9 @@ namespace libtorrent
static const int static_category = alert::status_notification | alert::error_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
TORRENT_NOT_DISCARDABLE
#ifndef TORRENT_NO_DEPRECATE
// the interface libtorrent attempted to listen on
std::string interface;
#endif
@ -1331,9 +1319,7 @@ namespace libtorrent
static const int static_category = alert::status_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// the endpoint libtorrent ended up listening on. The address
// refers to the local interface and the port is the listen port.
@ -1774,9 +1760,7 @@ namespace libtorrent
static const int static_category = alert::status_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
error_code error;
};
@ -1832,9 +1816,7 @@ namespace libtorrent
static const int static_category = alert::status_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// a copy of the parameters used when adding the torrent, it can be used
// to identify which invocation to ``async_add_torrent()`` caused this alert.
@ -1858,9 +1840,7 @@ namespace libtorrent
static const int static_category = alert::status_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// contains the torrent status of all torrents that changed since last
// time this message was posted. Note that you can map a torrent status
@ -1893,9 +1873,8 @@ namespace libtorrent
static const int static_category = alert::stats_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// An array are a mix of *counters* and *gauges*, which meanings can be
// queries via the session_stats_metrics() function on the session. The
@ -1926,9 +1905,7 @@ namespace libtorrent
static const int static_category = alert::status_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// ``old_ih`` and ``new_ih`` are the previous and new info-hash for the torrent, respectively.
sha1_hash old_ih;
@ -1996,9 +1973,7 @@ namespace libtorrent
| alert::dht_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// the target hash of the immutable item. This must
// match the sha-1 hash of the bencoded form of ``item``.
@ -2024,9 +1999,8 @@ namespace libtorrent
static const int static_category = alert::error_notification
| alert::dht_notification;
virtual std::string message() const;
#ifndef TORRENT_NO_DEPRECATE
virtual bool discardable() const { return false; }
#endif
TORRENT_NOT_DISCARDABLE
// the public key that was looked up
boost::array<char, 32> key;

View File

@ -100,7 +100,7 @@ namespace libtorrent
TORRENT_ASSERT(index < size());
return (m_buf[index / 32] & htonl((0x80000000 >> (index & 31)))) != 0;
}
// set bit at ``index`` to 0 (clear_bit) or 1 (set_bit).
void clear_bit(int index)
{
@ -159,6 +159,11 @@ namespace libtorrent
// returns a pointer to the internal buffer of the bitfield.
char const* data() const { return reinterpret_cast<char const*>(m_buf); }
#ifndef TORRENT_NO_DEPRECATE
TORRENT_DEPRECATED
char const* bytes() const { return data(); }
#endif
// copy operator
bitfield& operator=(bitfield const& rhs)
{

View File

@ -72,7 +72,7 @@ namespace libtorrent
char const* get_secret() const { return m_dh_shared_secret; }
sha1_hash const& get_hash_xor_mask() const { return m_xor_mask; }
private:
int get_local_key_size() const
@ -126,7 +126,7 @@ namespace libtorrent
// Input keys must be 20 bytes
void set_incoming_key(unsigned char const* key, int len) TORRENT_OVERRIDE;
void set_outgoing_key(unsigned char const* key, int len) TORRENT_OVERRIDE;
int encrypt(std::vector<boost::asio::mutable_buffer>& buf) TORRENT_OVERRIDE;
void decrypt(std::vector<boost::asio::mutable_buffer>& buf
, int& consume

View File

@ -151,7 +151,7 @@ namespace libtorrent
{
return m_v4_outstanding
#if TORRENT_USE_IPV6
+ m_v6_outstanding
+ m_v6_outstanding
#endif
;
}

View File

@ -242,13 +242,14 @@ namespace libtorrent
&& !defined TORRENT_MINGW
if (i->interface_address.is_v6() &&
i->interface_address.to_v6().is_link_local()) {
i->interface_address.to_v6().is_link_local())
{
address_v6 addr6 = i->interface_address.to_v6();
addr6.scope_id(if_nametoindex(i->name));
open_multicast_socket(ios, addr6, loopback, ec);
address_v4 const& mask = i->netmask.is_v4() ?
i->netmask.to_v4() : address_v4();
address_v4 const& mask = i->netmask.is_v4()
? i->netmask.to_v4() : address_v4();
open_unicast_socket(ios, addr6, mask);
continue;
}
@ -324,11 +325,13 @@ namespace libtorrent
void broadcast_socket::send(char const* buffer, int size, error_code& ec, int flags)
{
bool all_fail = true;
error_code e;
for (std::list<socket_entry>::iterator i = m_unicast_sockets.begin()
, end(m_unicast_sockets.end()); i != end; ++i)
{
if (!i->socket) continue;
error_code e;
i->socket->send_to(asio::buffer(buffer, size), m_multicast_endpoint, 0, e);
// if the user specified the broadcast flag, send one to the broadcast
@ -337,41 +340,34 @@ namespace libtorrent
i->socket->send_to(asio::buffer(buffer, size)
, udp::endpoint(i->broadcast_address(), m_multicast_endpoint.port()), 0, e);
#ifdef TORRENT_DEBUG
// fprintf(stderr, " sending on unicast %s to: %s\n", print_address(i->socket->local_endpoint().address()).c_str()
// , print_endpoint(m_multicast_endpoint).c_str());
#endif
if (e)
{
#ifdef TORRENT_DEBUG
// fprintf(stderr, " ERROR: %s\n", e.message().c_str());
#endif
i->socket->close(e);
i->socket.reset();
}
else
{
all_fail = false;
}
}
for (std::list<socket_entry>::iterator i = m_sockets.begin()
, end(m_sockets.end()); i != end; ++i)
{
if (!i->socket) continue;
error_code e;
i->socket->send_to(asio::buffer(buffer, size), m_multicast_endpoint, 0, e);
#ifdef TORRENT_DEBUG
// extern std::string print_address(address const& addr);
// extern std::string print_endpoint(udp::endpoint const& ep);
// fprintf(stderr, " sending on multicast %s to: %s\n", print_address(i->socket->local_endpoint().address()).c_str()
// , print_endpoint(m_multicast_endpoint).c_str());
#endif
if (e)
{
#ifdef TORRENT_DEBUG
// fprintf(stderr, " ERROR: %s\n", e.message().c_str());
#endif
i->socket->close(e);
i->socket.reset();
}
else
{
all_fail = false;
}
}
if (all_fail) ec = e;
}
void broadcast_socket::on_receive(socket_entry* s, error_code const& ec

View File

@ -96,7 +96,7 @@ namespace libtorrent
}
url.replace(pos, 8, "scrape");
}
#if TORRENT_USE_I2P
bool i2p = is_i2p_url(url);
#else
@ -113,7 +113,7 @@ namespace libtorrent
url += "&";
else
url += "?";
if (tracker_req().kind == tracker_request::announce_request)
{
const char* event_string[] = {"completed", "started", "stopped", "paused"};
@ -251,15 +251,18 @@ namespace libtorrent
tracker_connection::close();
}
void http_tracker_connection::on_filter(http_connection& c, std::vector<tcp::endpoint>& endpoints)
// endpoints is an in-out parameter
void http_tracker_connection::on_filter(http_connection& c
, std::vector<tcp::endpoint>& endpoints)
{
TORRENT_UNUSED(c);
if (!tracker_req().filter) return;
// remove endpoints that are filtered by the IP filter
for (std::vector<tcp::endpoint>::iterator i = endpoints.begin();
i != endpoints.end();)
{
if (tracker_req().filter->access(i->address()) == ip_filter::blocked)
if (tracker_req().filter->access(i->address()) == ip_filter::blocked)
i = endpoints.erase(i);
else
++i;
@ -295,7 +298,7 @@ namespace libtorrent
fail(ec);
return;
}
if (!parser.header_finished())
{
fail(asio::error::eof);
@ -308,13 +311,13 @@ namespace libtorrent
, parser.status_code(), parser.message().c_str());
return;
}
if (ec && ec != asio::error::eof)
{
fail(ec, parser.status_code());
return;
}
received_bytes(size + parser.body_start());
// handle tracker response
@ -576,7 +579,7 @@ namespace libtorrent
resp.external_ip = detail::read_v6_address(p);
#endif
}
return resp;
}
}

View File

@ -122,14 +122,6 @@ namespace libtorrent { namespace dht
namespace {
node_id extract_node_id(bdecode_node e)
{
if (!e || e.type() != bdecode_node::dict_t) return (node_id::min)();
bdecode_node nid = e.dict_find_string("node-id");
if (!nid || nid.string_length() != 20) return (node_id::min)();
return node_id(node_id(nid.string_ptr()));
}
node_id extract_node_id(entry const* e)
{
if (e == 0 || e->type() != entry::dictionary_t) return (node_id::min)();

View File

@ -324,7 +324,10 @@ namespace libtorrent
, int& produce
, int& packet_size)
{
// these are out-parameters that are not set
TORRENT_UNUSED(consume);
TORRENT_UNUSED(packet_size);
if (!m_decrypt) return;
int bytes_processed = 0;
@ -338,7 +341,7 @@ namespace libtorrent
TORRENT_ASSERT(pos);
bytes_processed += len;
rc4_encrypt((unsigned char*)pos, len, &m_rc4_incoming);
rc4_encrypt(reinterpret_cast<unsigned char*>(pos), len, &m_rc4_incoming);
}
buf.clear();
produce = bytes_processed;

View File

@ -248,6 +248,8 @@ void udp_socket::on_writable(error_code const& ec, udp::socket* s)
#endif
m_v4_write_subscribed = false;
if (ec == asio::error::operation_aborted) return;
call_writable_handler();
}

View File

@ -326,6 +326,7 @@ namespace libtorrent
bool udp_tracker_connection::on_receive_hostname(error_code const& e
, char const* hostname, char const* buf, int size)
{
TORRENT_UNUSED(hostname);
// just ignore the hostname this came from, pretend that
// it's from the same endpoint we sent it to (i.e. the same
// port). We have so many other ways of confirming this packet
@ -371,7 +372,7 @@ namespace libtorrent
#endif
return false;
}
if (e) fail(e);
#ifndef TORRENT_DISABLE_LOGGING
@ -449,7 +450,7 @@ namespace libtorrent
m_man.update_transaction_id(shared_from_this(), new_tid);
m_transaction_id = new_tid;
}
bool udp_tracker_connection::on_connect_response(char const* buf, int size)
{
// ignore packets smaller than 16 bytes

View File

@ -69,7 +69,6 @@ namespace upnp_errors
static error_code ec;
// TODO: 3 listen_interface is not used. It's meant to bind the broadcast socket
upnp::upnp(io_service& ios
, address const& listen_interface, std::string const& user_agent
, portmap_callback_t const& cb, log_callback_t const& lcb
@ -90,6 +89,12 @@ upnp::upnp(io_service& ios
, m_last_if_update(min_time())
{
TORRENT_ASSERT(cb);
// TODO: 3 listen_interface is not used. It's meant to bind the broadcast
// socket. it would probably have to be changed to a vector of interfaces to
// bind to though, since the broadcast socket opens one socket per local
// interface by default
TORRENT_UNUSED(listen_interface);
}
void upnp::start(void* state)

View File

@ -166,6 +166,9 @@ namespace libtorrent
void utp_socket_manager::send_packet(udp::endpoint const& ep, char const* p
, int len, error_code& ec, int flags)
{
#if !defined TORRENT_HAS_DONT_FRAGMENT && !defined TORRENT_DEBUG_MTU
TORRENT_UNUSED(flags);
#endif
if (!m_sock.is_open())
{
ec = asio::error::operation_aborted;
@ -253,6 +256,9 @@ namespace libtorrent
bool utp_socket_manager::incoming_packet(error_code const& ec, udp::endpoint const& ep
, char const* p, int size)
{
// TODO: 2 we may want to take ec into account here. possibly close
// connections quicker
TORRENT_UNUSED(ec);
// UTP_LOGV("incoming packet size:%d\n", size);
if (size < int(sizeof(utp_header))) return false;
@ -264,7 +270,7 @@ namespace libtorrent
if (ph->get_version() != 1) return false;
const time_point receive_time = clock_type::now();
// parse out connection ID and look for existing
// connections. If found, forward to the utp_stream.
boost::uint16_t id = ph->connection_id;
@ -363,7 +369,7 @@ namespace libtorrent
void utp_socket_manager::socket_drained()
{
// flush all deferred acks
std::vector<utp_socket_impl*> deferred_acks;
m_deferred_acks.swap(deferred_acks);
for (std::vector<utp_socket_impl*>::iterator i = deferred_acks.begin()
@ -405,7 +411,7 @@ namespace libtorrent
if (m_last_socket == i->second) m_last_socket = 0;
m_utp_sockets.erase(i);
}
void utp_socket_manager::set_sock_buf(int size)
{
if (size < m_sock_buf_size) return;

View File

@ -3438,7 +3438,7 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
}
}
void utp_stream::bind(endpoint_type const& ep, error_code& ec) { }
void utp_stream::bind(endpoint_type const&, error_code&) { }
void utp_stream::cancel_handlers(error_code const& ec)
{