make single-argument constructors explicit (#1194)

make single-argument constructors explicit
This commit is contained in:
Arvid Norberg 2016-10-08 14:07:11 -04:00 committed by GitHub
parent 7bfb97ba44
commit 20f65946f2
53 changed files with 114 additions and 145 deletions

View File

@ -77,7 +77,7 @@ namespace libtorrent
// The constructor can be used to initialize the storage constructor,
// which determines the storage mechanism for the downloaded or seeding
// data for the torrent. For more information, see the ``storage`` field.
add_torrent_params(storage_constructor_type sc = default_storage_constructor)
explicit add_torrent_params(storage_constructor_type sc = default_storage_constructor)
: version(LIBTORRENT_VERSION_NUM)
, storage_mode(storage_mode_sparse)
, storage(sc)

View File

@ -1674,7 +1674,7 @@ namespace libtorrent
struct TORRENT_EXPORT dht_bootstrap_alert final : alert
{
// internal
dht_bootstrap_alert(aux::stack_allocator& alloc);
explicit dht_bootstrap_alert(aux::stack_allocator& alloc);
TORRENT_DEFINE_ALERT(dht_bootstrap_alert, 62)

View File

@ -47,7 +47,7 @@ namespace libtorrent
struct TORRENT_EXPORT announce_entry
{
// constructs a tracker announce entry with ``u`` as the URL.
announce_entry(std::string u);
explicit announce_entry(std::string u);
announce_entry();
~announce_entry();
announce_entry(announce_entry const&) = default;

View File

@ -47,7 +47,7 @@ namespace libtorrent { namespace aux {
struct bind_to_device
{
bind_to_device(char const* device): m_value(device) {}
explicit bind_to_device(char const* device): m_value(device) {}
template<class Protocol>
int level(Protocol const&) const { return SOL_SOCKET; }
template<class Protocol>
@ -66,7 +66,7 @@ namespace libtorrent { namespace aux {
struct bind_to_device
{
bind_to_device(char const* device): m_value(if_nametoindex(device)) {}
explicit bind_to_device(char const* device): m_value(if_nametoindex(device)) {}
template<class Protocol>
int level(Protocol const&) const { return IPPROTO_IP; }
template<class Protocol>
@ -85,7 +85,7 @@ namespace libtorrent { namespace aux {
struct bind_to_device
{
bind_to_device(char const* device): m_value(device) {}
explicit bind_to_device(char const* device): m_value(device) {}
template<class Protocol>
int level(Protocol const&) const { return SOL_SOCKET; }
template<class Protocol>

View File

@ -40,7 +40,7 @@ namespace libtorrent { namespace aux {
{
has_block(has_block const&) = default;
has_block(piece_block const& b): block(b) {}
explicit has_block(piece_block const& b): block(b) {}
bool operator()(pending_block const& pb) const
{ return pb.block == block; }
private:

View File

@ -53,8 +53,8 @@ namespace aux {
// construct the proxy_settings object from the settings
// this constructor is implemented in session_impl.cpp
proxy_settings(settings_pack const& sett);
proxy_settings(aux::session_settings const& sett);
explicit proxy_settings(settings_pack const& sett);
explicit proxy_settings(aux::session_settings const& sett);
// the name or IP of the proxy server. ``port`` is the port number the
// proxy listens to. If required, ``username`` and ``password`` can be

View File

@ -216,7 +216,7 @@ namespace libtorrent
typedef std::set<std::shared_ptr<peer_connection>> connection_map;
typedef std::unordered_map<sha1_hash, std::shared_ptr<torrent>> torrent_map;
session_impl(io_service& ios);
explicit session_impl(io_service& ios);
virtual ~session_impl();
void start_session(settings_pack pack);
@ -1238,7 +1238,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_LOGGING
struct tracker_logger : request_callback
{
tracker_logger(session_interface& ses);
explicit tracker_logger(session_interface& ses);
void tracker_warning(tracker_request const& req
, std::string const& str);
void tracker_response(tracker_request const&

View File

@ -47,7 +47,7 @@ namespace libtorrent {
struct TORRENT_EXTRA_EXPORT bandwidth_manager
{
bandwidth_manager(int channel);
explicit bandwidth_manager(int channel);
void close();
@ -57,7 +57,7 @@ struct TORRENT_EXTRA_EXPORT bandwidth_manager
int queue_size() const;
std::int64_t queued_bytes() const;
// non prioritized means that, if there's a line for bandwidth,
// others will cut in front of the non-prioritized peers.
// this is used by web seeds

View File

@ -57,7 +57,7 @@ namespace libtorrent
// from the specified buffer, and ``bits`` number of bits (rounded up to
// the nearest byte boundary).
bitfield() = default;
bitfield(int bits) { resize(bits); }
explicit bitfield(int bits) { resize(bits); }
bitfield(int bits, bool val) { resize(bits, val); }
bitfield(char const* b, int bits) { assign(b, bits); }
bitfield(bitfield const& rhs) { assign(rhs.data(), rhs.size()); }

View File

@ -73,7 +73,7 @@ namespace libtorrent
struct piece_log_t
{
piece_log_t(int j, int b= -1): job(j), block(b) {}
explicit piece_log_t(int j, int b= -1): job(j), block(b) {}
int job;
int block;

View File

@ -60,7 +60,7 @@ namespace libtorrent
class TORRENT_EXTRA_EXPORT broadcast_socket
{
public:
broadcast_socket(udp::endpoint const& multicast_endpoint);
explicit broadcast_socket(udp::endpoint const& multicast_endpoint);
~broadcast_socket() { close(); }
void open(receive_handler_t const& handler, io_service& ios
@ -77,7 +77,7 @@ namespace libtorrent
struct socket_entry
{
socket_entry(std::shared_ptr<udp::socket> const& s)
explicit socket_entry(std::shared_ptr<udp::socket> const& s)
: socket(s), broadcast(false) { std::memset(buffer, 0, sizeof(buffer)); }
socket_entry(std::shared_ptr<udp::socket> const& s
, address_v4 const& mask): socket(s), netmask(mask), broadcast(false)

View File

@ -62,7 +62,7 @@ class buffer
public:
// allocate an uninitialized buffer of the specified size
buffer(std::size_t size = 0)
explicit buffer(std::size_t size = 0)
{
TORRENT_ASSERT(size < std::size_t((std::numeric_limits<std::int32_t>::max)()));

View File

@ -39,7 +39,7 @@ namespace libtorrent
struct copy_ptr
{
copy_ptr(): m_ptr(0) {}
copy_ptr(T* t): m_ptr(t) {}
explicit copy_ptr(T* t): m_ptr(t) {}
copy_ptr(copy_ptr const& p): m_ptr(p.m_ptr ? new T(*p.m_ptr) : 0) {}
void reset(T* t = 0) { delete m_ptr; m_ptr = t; }
copy_ptr& operator=(copy_ptr const& p)

View File

@ -171,7 +171,7 @@ namespace libtorrent
explicit create_torrent(file_storage& fs, int piece_size = 0
, int pad_file_limit = -1, int flags = optimize_alignment
, int alignment = -1);
create_torrent(torrent_info const& ti);
explicit create_torrent(torrent_info const& ti);
// internal
~create_torrent();

View File

@ -109,14 +109,14 @@ namespace libtorrent
// as a key, sorting would become a problem (e.g. to compare a string
// to a list). The definition doesn't mention such a limit though.
#if __cplusplus <= 201103
typedef std::map<std::string, entry> dictionary_type;
using dictionary_type = std::map<std::string, entry>;
#else
typedef std::map<std::string, entry, aux::strview_less> dictionary_type;
using dictionary_type = std::map<std::string, entry, aux::strview_less>;
#endif
typedef std::string string_type;
typedef std::vector<entry> list_type;
typedef std::int64_t integer_type;
typedef std::vector<char> preformatted_type;
using string_type = std::string;
using list_type = std::vector<entry>;
using integer_type = std::int64_t;
using preformatted_type = std::vector<char>;
// the types an entry can have
enum data_type
@ -135,13 +135,13 @@ namespace libtorrent
// constructors directly from a specific type.
// The content of the argument is copied into the
// newly constructed entry
entry(dictionary_type);
entry(span<char const>);
entry(dictionary_type); // NOLINT
entry(span<char const>); // NOLINT
template <typename U, typename Cond = typename std::enable_if<
std::is_same<U, entry::string_type>::value
|| std::is_same<U, string_view>::value
|| std::is_same<U, char const*>::value>::type>
entry(U v)
entry(U v) // NOLINT
: m_type(undefined_t)
{
#if TORRENT_USE_ASSERTS
@ -150,13 +150,13 @@ namespace libtorrent
new(&data) string_type(std::move(v));
m_type = string_t;
}
entry(list_type);
entry(integer_type);
entry(preformatted_type);
entry(list_type); // NOLINT
entry(integer_type); // NOLINT
entry(preformatted_type); // NOLINT
// construct an empty entry of the specified type.
// see data_type enum.
entry(data_type t);
entry(data_type t); // NOLINT
// hidden
entry(entry const& e);

View File

@ -500,7 +500,7 @@ namespace libtorrent
struct TORRENT_EXPORT storage_error
{
storage_error(): file(-1), operation(0) {}
storage_error(error_code e): ec(e), file(-1), operation(0) {}
explicit storage_error(error_code e): ec(e), file(-1), operation(0) {}
operator bool() const { return ec.value() != 0; }

View File

@ -209,7 +209,7 @@ namespace libtorrent
struct file_handle
{
file_handle();
file_handle(file* f);
explicit file_handle(file* f);
file_handle(file_handle const& fh);
~file_handle();
file* operator->();

View File

@ -84,7 +84,7 @@ namespace libtorrent
{
// ``size`` specifies the number of allowed files handles
// to hold open at any given time.
file_pool(int size = 40);
explicit file_pool(int size = 40);
~file_pool();
// return an open file handle to file at ``file_index`` in the

View File

@ -89,7 +89,7 @@ namespace libtorrent
// this is the same as default constructing followed by a call to
// ``update(data, len)``.
hasher(char const* data, int len);
hasher(span<char const> data);
explicit hasher(span<char const> data);
hasher(hasher const&);
hasher& operator=(hasher const&);

View File

@ -158,7 +158,7 @@ namespace libtorrent {
void (*move)(uintptr_t* dst, uintptr_t* src);
};
const static int header_size = (sizeof(header_t) + sizeof(uintptr_t)
static int const header_size = (sizeof(header_t) + sizeof(uintptr_t)
- 1) / sizeof(uintptr_t);
void grow_capacity(int const size)

View File

@ -58,7 +58,7 @@ namespace libtorrent
{
public:
enum flags_t { dont_parse_chunks = 1 };
http_parser(int flags = 0);
explicit http_parser(int flags = 0);
~http_parser();
std::string const& header(char const* key) const
{

View File

@ -167,7 +167,7 @@ private:
class i2p_connection
{
public:
i2p_connection(io_service& ios);
explicit i2p_connection(io_service& ios);
~i2p_connection();
aux::proxy_settings proxy() const;

View File

@ -35,7 +35,7 @@ namespace libtorrent
template<class T>
struct invariant_checker_impl : invariant_checker
{
invariant_checker_impl(T const& self_)
explicit invariant_checker_impl(T const& self_)
: self(self_)
{
TORRENT_TRY

View File

@ -145,8 +145,8 @@ namespace detail
TORRENT_ASSERT(!m_access_list.empty());
TORRENT_ASSERT(first < last || first == last);
typename range_t::iterator i = m_access_list.upper_bound(first);
typename range_t::iterator j = m_access_list.upper_bound(last);
auto i = m_access_list.upper_bound(first);
auto j = m_access_list.upper_bound(last);
if (i != m_access_list.begin()) --i;
@ -198,7 +198,7 @@ namespace detail
std::uint32_t access(Addr const& addr) const
{
TORRENT_ASSERT(!m_access_list.empty());
typename range_t::const_iterator i = m_access_list.upper_bound(addr);
auto i = m_access_list.upper_bound(addr);
if (i != m_access_list.begin()) --i;
TORRENT_ASSERT(i != m_access_list.end());
TORRENT_ASSERT(i->start <= addr && (std::next(i) == m_access_list.end()
@ -234,20 +234,17 @@ namespace detail
struct range
{
range(Addr addr, int a = 0): start(addr), access(a) {}
bool operator<(range const& r) const
{ return start < r.start; }
bool operator<(Addr const& a) const
{ return start < a; }
range(Addr addr, int a = 0): start(addr), access(a) {} // NOLINT
bool operator<(range const& r) const { return start < r.start; }
bool operator<(Addr const& a) const { return start < a; }
Addr start;
// the end of the range is implicit
// and given by the next entry in the set
std::uint32_t access;
};
typedef std::set<range> range_t;
using range_t = std::set<range>;
range_t m_access_list;
};
}

View File

@ -77,13 +77,13 @@ class TORRENT_EXTRA_EXPORT item
public:
item() : m_seq(0), m_mutable(false) {}
item(public_key const& pk, span<char const> salt);
item(entry v);
explicit item(entry v);
item(entry v
, span<char const> salt
, sequence_number seq
, public_key const& pk
, secret_key const& sk);
item(bdecode_node const& v);
explicit item(bdecode_node const& v);
void assign(entry v);
void assign(entry v, span<char const> salt

View File

@ -46,7 +46,7 @@ struct TORRENT_EXTRA_EXPORT node_entry
{
node_entry(node_id const& id_, udp::endpoint const& ep, int roundtriptime = 0xffff
, bool pinged = false);
node_entry(udp::endpoint const& ep);
explicit node_entry(udp::endpoint const& ep);
node_entry();
void update_rtt(int new_rtt);

View File

@ -57,7 +57,7 @@ namespace libtorrent
void prev() { m_current = m_current->prev; }
private:
list_iterator(T* cur)
explicit list_iterator(T* cur)
: m_current(cur) {}
// the current element
T* m_current;

View File

@ -86,7 +86,7 @@ namespace libtorrent
{
friend struct peer_class_pool;
peer_class(std::string const& l)
explicit peer_class(std::string const& l)
: ignore_unchoke_slots(false)
, connection_limit_factor(100)
, label(l)

View File

@ -92,7 +92,7 @@ namespace libtorrent
struct pending_block
{
pending_block(piece_block const& b)
pending_block(piece_block const& b) // NOLINT
: block(b), send_buffer_offset(not_in_buffer), not_wanted(false)
, timed_out(false), busy(false)
{}
@ -277,7 +277,7 @@ namespace libtorrent
num_channels
};
peer_connection(peer_connection_args const& pack);
explicit peer_connection(peer_connection_args const& pack);
// this function is called after it has been constructed and properly
// reference counted. It is safe to call self() in this function
@ -1216,7 +1216,7 @@ namespace libtorrent
struct cork
{
cork(peer_connection& p): m_pc(p), m_need_uncork(false)
explicit cork(peer_connection& p): m_pc(p)
{
if (m_pc.is_corked()) return;
m_pc.cork_socket();
@ -1225,7 +1225,7 @@ namespace libtorrent
~cork() { if (m_need_uncork) m_pc.uncork_socket(); }
private:
peer_connection& m_pc;
bool m_need_uncork;
bool m_need_uncork = false;
cork& operator=(cork const&);
};

View File

@ -51,7 +51,7 @@ struct crypto_plugin;
struct TORRENT_EXPORT peer_connection_handle
{
peer_connection_handle(std::weak_ptr<peer_connection> impl)
explicit peer_connection_handle(std::weak_ptr<peer_connection> impl)
: m_connection(impl)
{}

View File

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

View File

@ -167,7 +167,7 @@ private:
// tracks the state of the bittorrent protocol.
struct crypto_receive_buffer
{
crypto_receive_buffer(receive_buffer& next)
explicit crypto_receive_buffer(receive_buffer& next)
: m_connection_buffer(next)
{}

View File

@ -57,7 +57,7 @@ namespace libtorrent
int file_idx;
};
resolve_links(std::shared_ptr<torrent_info> ti);
explicit resolve_links(std::shared_ptr<torrent_info> ti);
// check to see if any files are shared with this torrent
void match(std::shared_ptr<const torrent_info> const& ti

View File

@ -55,7 +55,7 @@ namespace libtorrent
struct TORRENT_EXTRA_EXPORT resolver final : resolver_interface
{
resolver(io_service& ios);
explicit resolver(io_service& ios);
virtual void async_resolve(std::string const& host, int flags
, callback_t const& h) override;

View File

@ -133,7 +133,7 @@ namespace libtorrent
// (ut_metadata, ut_pex and smart_ban). The default values in the
// settings is to start the default features like upnp, nat-pmp,
// and dht for example.
session_params(settings_pack sp = settings_pack());
explicit session_params(settings_pack sp = settings_pack());
// This constructor helps to configure the set of initial plugins
// to be added to the session before it's started.
session_params(settings_pack sp
@ -180,7 +180,7 @@ namespace libtorrent
// In order to avoid a race condition between starting the session and
// configuring it, you can pass in a session_params object. Its settings
// will take effect before the session starts up.
session(session_params params = session_params())
explicit session(session_params params = session_params())
: session_handle(nullptr)
{
TORRENT_CFG();

View File

@ -69,7 +69,7 @@ namespace libtorrent
{
session_handle() : m_impl(nullptr) {}
session_handle(aux::session_impl* impl)
explicit session_handle(aux::session_impl* impl)
: m_impl(impl)
{}

View File

@ -94,7 +94,7 @@ namespace libtorrent
struct v6_protection_level
{
v6_protection_level(int level): m_value(level) {}
explicit v6_protection_level(int level): m_value(level) {}
template<class Protocol>
int level(Protocol const&) const { return IPPROTO_IPV6; }
template<class Protocol>
@ -108,7 +108,7 @@ namespace libtorrent
struct exclusive_address_use
{
exclusive_address_use(int enable): m_value(enable) {}
explicit exclusive_address_use(int enable): m_value(enable) {}
template<class Protocol>
int level(Protocol const&) const { return SOL_SOCKET; }
template<class Protocol>
@ -124,7 +124,7 @@ namespace libtorrent
#ifdef IPV6_TCLASS
struct traffic_class
{
traffic_class(char val): m_value(val) {}
explicit traffic_class(char val): m_value(val) {}
template<class Protocol>
int level(Protocol const&) const { return IPPROTO_IPV6; }
template<class Protocol>
@ -140,11 +140,11 @@ namespace libtorrent
struct type_of_service
{
#ifdef _WIN32
typedef DWORD tos_t;
using tos_t = DWORD;
#else
typedef int tos_t;
using tos_t = int;
#endif
type_of_service(char val): m_value(val) {}
explicit type_of_service(char val): m_value(val) {}
template<class Protocol>
int level(Protocol const&) const { return IPPROTO_IP; }
template<class Protocol>
@ -163,7 +163,7 @@ namespace libtorrent
#ifdef TORRENT_HAS_DONT_FRAGMENT
struct dont_fragment
{
dont_fragment(bool val)
explicit dont_fragment(bool val)
#ifdef IP_PMTUDISCOVER_DO
: m_value(val ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT) {}
#else

View File

@ -46,23 +46,23 @@ namespace libtorrent
span() : m_ptr(nullptr), m_len(0) {}
template <typename U>
span(span<U> const& v)
span(span<U> const& v) // NOLINT
: m_ptr(v.data()), m_len(v.size()) {}
span(T& p) : m_ptr(&p), m_len(1) {}
span(T* p, size_t const l) : m_ptr(p), m_len(l) {}
span(T& p) : m_ptr(&p), m_len(1) {} // NOLINT
span(T* p, size_t const l) : m_ptr(p), m_len(l) {} // NOLINT
template <typename U, size_t N>
span(std::array<U, N>& arr)
span(std::array<U, N>& arr) // NOLINT
: m_ptr(arr.data()), m_len(arr.size()) {}
template <typename U, size_t N>
span(U (&arr)[N])
span(U (&arr)[N]) // NOLINT
: m_ptr(&arr[0]), m_len(N) {}
// anything with a .data() member function is considered a container
template <typename Cont, typename = decltype(std::declval<Cont>().data())>
span(Cont& c)
span(Cont& c) // NOLINT
: m_ptr(c.data()), m_len(c.size()) {}
size_t size() const { return m_len; }

View File

@ -78,7 +78,7 @@ namespace libtorrent
struct stat_cache_t
{
stat_cache_t(std::int64_t s): file_size(s) {}
stat_cache_t(std::int64_t s): file_size(s) {} // NOLINT
// the size of the file. Negative values have special meaning. -1 means
// not-in-cache (i.e. there's no data for this file in the cache).

View File

@ -388,7 +388,7 @@ namespace libtorrent
// an empty vector. Any file whose index is not represented by the vector
// (because the vector is too short) are assumed to have priority 1.
// this is used to treat files with priority 0 slightly differently.
default_storage(storage_params const& params);
explicit default_storage(storage_params const& params);
// hidden
~default_storage();

View File

@ -61,7 +61,7 @@ namespace libtorrent
void next() { m_current = m_current->next; }
private:
tailqueue_iterator(T* cur)
explicit tailqueue_iterator(T* cur)
: m_current(cur) {}
// the current element
T* m_current;

View File

@ -126,7 +126,7 @@ namespace libtorrent
// this is the internal representation of web seeds
struct web_seed_t : web_seed_entry
{
web_seed_t(web_seed_entry const& wse);
explicit web_seed_t(web_seed_entry const& wse);
web_seed_t(std::string const& url_, web_seed_entry::type_t type_
, std::string const& auth_ = std::string()
, web_seed_entry::headers_t const& extra_headers_ = web_seed_entry::headers_t());

View File

@ -1293,7 +1293,7 @@ namespace libtorrent
template<typename Ret, typename Fun, typename... Args>
Ret sync_call_ret(Ret def, Fun f, Args&&... a) const;
torrent_handle(std::weak_ptr<torrent> const& t)
explicit torrent_handle(std::weak_ptr<torrent> const& t)
{ if (!t.expired()) m_torrent = t; }
std::weak_ptr<torrent> m_torrent;

View File

@ -383,7 +383,7 @@ namespace libtorrent
// ------- start deprecation -------
// these functions will be removed in a future version
TORRENT_DEPRECATED
torrent_info(entry const& torrent_file);
explicit torrent_info(entry const& torrent_file);
// ------- end deprecation -------
#endif

View File

@ -250,7 +250,7 @@ namespace libtorrent
: std::enable_shared_from_this<timeout_handler>
, boost::noncopyable
{
timeout_handler(io_service& str);
explicit timeout_handler(io_service& str);
void set_timeout(int completion_timeout, int read_timeout);
void restart_read_timeout();

View File

@ -50,7 +50,7 @@ namespace libtorrent
class TORRENT_EXTRA_EXPORT udp_socket : single_threaded
{
public:
udp_socket(io_service& ios);
explicit udp_socket(io_service& ios);
enum flags_t {
peer_connection = 1

View File

@ -40,16 +40,8 @@ namespace libtorrent
{
struct union_address
{
union_address()
{
*this = address();
}
union_address(address const& a)
{
*this = a;
}
union_address() { *this = address(); }
explicit union_address(address const& a) { *this = a; }
union_address& operator=(address const& a)
{
#if TORRENT_USE_IPV6
@ -106,20 +98,9 @@ namespace libtorrent
struct union_endpoint
{
union_endpoint(tcp::endpoint const& ep)
{
*this = ep;
}
union_endpoint(udp::endpoint const& ep)
{
*this = ep;
}
union_endpoint()
{
*this = tcp::endpoint();
}
explicit union_endpoint(tcp::endpoint const& ep) { *this = ep; }
explicit union_endpoint(udp::endpoint const& ep) { *this = ep; }
union_endpoint() { *this = tcp::endpoint(); }
union_endpoint& operator=(udp::endpoint const& ep)
{
@ -128,10 +109,7 @@ namespace libtorrent
return *this;
}
operator udp::endpoint() const
{
return udp::endpoint(addr, port);
}
operator udp::endpoint() const { return udp::endpoint(addr, port); }
union_endpoint& operator=(tcp::endpoint const& ep)
{
@ -140,15 +118,8 @@ namespace libtorrent
return *this;
}
libtorrent::address address() const
{
return addr;
}
operator tcp::endpoint() const
{
return tcp::endpoint(addr, port);
}
libtorrent::address address() const { return addr; }
operator tcp::endpoint() const { return tcp::endpoint(addr, port); }
union_address addr;
std::uint16_t port;

View File

@ -2521,7 +2521,7 @@ namespace libtorrent
// if we're disconnecting, we shouldn't add pieces
if (!in_req_queue && !m_disconnecting)
{
for (std::vector<pending_block>::iterator i = m_request_queue.begin()
for (auto i = m_request_queue.begin()
, end(m_request_queue.end()); i != end; ++i)
{
if (i->block != b) continue;

View File

@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <ctime>
#include <algorithm>
#include <cctype>
#include <algorithm>
#include <cstdio> // for snprintf
#include <cinttypes> // for PRId64 et.al.
#include <functional>
@ -82,7 +81,6 @@ const rlim_t rlim_infinity = RLIM_INFINITY;
#include "libtorrent/kademlia/node_entry.hpp"
#endif
#include "libtorrent/enum_net.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/utf8.hpp"
#include "libtorrent/upnp.hpp"
#include "libtorrent/natpmp.hpp"
@ -382,7 +380,8 @@ namespace aux {
SSL_CTX *torrent_context = t->ssl_ctx()->native_handle();
SSL_set_SSL_CTX(s, torrent_context);
SSL_set_verify(s, SSL_CTX_get_verify_mode(torrent_context), SSL_CTX_get_verify_callback(torrent_context));
SSL_set_verify(s, SSL_CTX_get_verify_mode(torrent_context)
, SSL_CTX_get_verify_callback(torrent_context));
return SSL_TLSEXT_ERR_OK;
}
@ -592,11 +591,13 @@ namespace aux {
#endif
m_io_service.post([this]{ this->wrap(&session_impl::on_tick, error_code()); });
int const lsd_announce_interval
= m_settings.get_int(settings_pack::local_service_announce_interval);
int const delay = std::max(lsd_announce_interval
/ std::max(static_cast<int>(m_torrents.size()), 1), 1);
error_code ec;
ADD_OUTSTANDING_ASYNC("session_impl::on_lsd_announce");
int const delay = std::max(m_settings.get_int(settings_pack::local_service_announce_interval)
/ std::max(int(m_torrents.size()), 1), 1);
m_lsd_announce_timer.expires_from_now(seconds(delay), ec);
ADD_OUTSTANDING_ASYNC("session_impl::on_lsd_announce");
m_lsd_announce_timer.async_wait([this](error_code const& e) {
this->wrap(&session_impl::on_lsd_announce, e); } );
TORRENT_ASSERT(!ec);

View File

@ -294,8 +294,9 @@ namespace libtorrent
int tier = 0;
auto tier_iter = p.tracker_tiers.begin();
for (announce_entry e : p.trackers)
for (auto const& url : p.trackers)
{
announce_entry e(url);
if (tier_iter != p.tracker_tiers.end())
tier = *tier_iter++;

View File

@ -1347,9 +1347,8 @@ namespace libtorrent
if (ec) return false;
m_info_hash = p.info_hash;
for (std::vector<std::string>::iterator i = p.trackers.begin()
, end(p.trackers.end()); i != end; ++i)
m_urls.push_back(*i);
for (auto const& url : p.trackers)
m_urls.push_back(announce_entry(url));
return true;
}

View File

@ -1741,7 +1741,7 @@ void test_bootstrap(address(&rand_addr)())
udp::endpoint found_node(rand_addr(), 2235);
std::vector<node_entry> nodes;
nodes.push_back(found_node);
nodes.push_back(node_entry{found_node});
g_sent_packets.clear();
if (initial_node.address().is_v4())
send_dht_response(t.dht_node, response, initial_node, msg_args().nodes(nodes));
@ -1843,7 +1843,7 @@ void test_short_nodes(address(&rand_addr)())
udp::endpoint found_node(rand_addr(), 2235);
std::vector<node_entry> nodes;
nodes.push_back(found_node);
nodes.push_back(node_entry{found_node});
g_sent_packets.clear();
msg_args args;
// chop one byte off of the nodes string
@ -1900,7 +1900,7 @@ void test_get_peers(address(&rand_addr)())
dht::node_id const target = to_hash("1234876923549721020394873245098347598635");
udp::endpoint const initial_node(rand_addr(), 1234);
t.dht_node.m_table.add_node(initial_node);
t.dht_node.m_table.add_node(node_entry{initial_node});
t.dht_node.announce(target, 1234, false, get_peers_cb);
@ -1933,7 +1933,7 @@ void test_get_peers(address(&rand_addr)())
udp::endpoint next_node(rand_addr(), 2235);
std::vector<node_entry> nodes;
nodes.push_back(next_node);
nodes.push_back(node_entry{next_node});
g_sent_packets.clear();
if (initial_node.address().is_v4())
@ -2032,7 +2032,7 @@ void test_mutable_get(address(&rand_addr)(), bool const with_salt)
g_sent_packets.clear();
udp::endpoint const initial_node(rand_addr(), 1234);
t.dht_node.m_table.add_node(initial_node);
t.dht_node.m_table.add_node(node_entry{initial_node});
g_put_item.assign(items[0].ent, salt, seq, pk, sk);
t.dht_node.put_item(pk, std::string()
@ -2129,7 +2129,7 @@ TORRENT_TEST(immutable_get)
g_sent_packets.clear();
udp::endpoint initial_node(addr4("4.4.4.4"), 1234);
t.dht_node.m_table.add_node(initial_node);
t.dht_node.m_table.add_node(node_entry{initial_node});
t.dht_node.get_item(items[0].target, get_immutable_item_cb);
@ -2960,7 +2960,7 @@ TORRENT_TEST(read_only_node)
bdecode_node parsed[7];
char error_string[200];
udp::endpoint initial_node(addr("4.4.4.4"), 1234);
node.m_table.add_node(initial_node);
node.m_table.add_node(node_entry{initial_node});
bdecode_node request;
sha1_hash target = generate_next();

View File

@ -352,7 +352,7 @@ void test_remove(std::string const& test_path, bool unbuffered)
TEST_EQUAL(st.file_size, 8);
s->delete_files(session::delete_files, se);
if (se) print_error("delete_files", 0, se.ec);
if (se) print_error("delete_files", 0, se);
if (se)
{