apply modernization transforms to headers too. nullptr, explicit constructors, = default (#903)

This commit is contained in:
Arvid Norberg 2016-07-10 14:27:42 -04:00 committed by GitHub
parent c3432aedd9
commit 8c03718117
29 changed files with 49 additions and 49 deletions

View File

@ -354,7 +354,7 @@ std::string print_endpoint(libtorrent::tcp::endpoint const& ep)
struct torrent_entry struct torrent_entry
{ {
torrent_entry(libtorrent::torrent_handle h) : handle(std::move(h)) {} explicit torrent_entry(libtorrent::torrent_handle h) : handle(std::move(h)) {}
libtorrent::torrent_handle handle; libtorrent::torrent_handle handle;
libtorrent::torrent_status status; libtorrent::torrent_status status;
}; };

View File

@ -302,7 +302,7 @@ dht_network::dht_network(sim::simulation& sim, int num_nodes, std::uint32_t flag
} }
} }
dht_network::~dht_network() {} dht_network::~dht_network() = default;
void print_routing_table(std::vector<lt::dht_routing_bucket> const& rt) void print_routing_table(std::vector<lt::dht_routing_bucket> const& rt)
{ {

View File

@ -102,7 +102,7 @@ namespace libtorrent
struct stack_frame struct stack_frame
{ {
stack_frame(int const t): token(t), state(0) {} explicit stack_frame(int const t): token(t), state(0) {}
// this is an index into m_tokens // this is an index into m_tokens
std::uint32_t token:31; std::uint32_t token:31;
// this is used for dictionaries to indicate whether we're // this is used for dictionaries to indicate whether we're
@ -752,7 +752,7 @@ namespace libtorrent
switch (t) switch (t)
{ {
case 'd': case 'd':
stack[sp++] = int(ret.m_tokens.size()); stack[sp++] = stack_frame(int(ret.m_tokens.size()));
// we push it into the stack so that we know where to fill // we push it into the stack so that we know where to fill
// in the next_node field once we pop this node off the stack. // in the next_node field once we pop this node off the stack.
// i.e. get to the node following the dictionary in the buffer // i.e. get to the node following the dictionary in the buffer
@ -761,7 +761,7 @@ namespace libtorrent
++start; ++start;
break; break;
case 'l': case 'l':
stack[sp++] = int(ret.m_tokens.size()); stack[sp++] = stack_frame(int(ret.m_tokens.size()));
// we push it into the stack so that we know where to fill // we push it into the stack so that we know where to fill
// in the next_node field once we pop this node off the stack. // in the next_node field once we pop this node off the stack.
// i.e. get to the node following the list in the buffer // i.e. get to the node following the list in the buffer

View File

@ -328,7 +328,7 @@ void http_connection::start(std::string const& hostname, int port
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
if (m_ssl) if (m_ssl)
{ {
if (m_ssl_ctx == 0) if (m_ssl_ctx == nullptr)
{ {
m_ssl_ctx = new (std::nothrow) ssl::context( m_ssl_ctx = new (std::nothrow) ssl::context(
m_timer.get_io_service(), ssl::context::sslv23_client); m_timer.get_io_service(), ssl::context::sslv23_client);

View File

@ -89,7 +89,7 @@ namespace
struct count_peers struct count_peers
{ {
int* count; int* count;
count_peers(int* c): count(c) {} explicit count_peers(int* c): count(c) {}
void operator()(std::pair<libtorrent::sha1_hash void operator()(std::pair<libtorrent::sha1_hash
, torrent_entry> const& t) , torrent_entry> const& t)
{ {
@ -147,7 +147,7 @@ namespace
// less important to keep // less important to keep
struct immutable_item_comparator struct immutable_item_comparator
{ {
immutable_item_comparator(std::vector<node_id> const& node_ids) : m_node_ids(node_ids) {} explicit immutable_item_comparator(std::vector<node_id> const& node_ids) : m_node_ids(node_ids) {}
immutable_item_comparator(immutable_item_comparator const&) = default; immutable_item_comparator(immutable_item_comparator const&) = default;
bool operator() (std::pair<node_id, dht_immutable_item> const& lhs bool operator() (std::pair<node_id, dht_immutable_item> const& lhs
@ -193,7 +193,7 @@ namespace
public: public:
dht_default_storage(dht_settings const& settings) explicit dht_default_storage(dht_settings const& settings)
: m_settings(settings) : m_settings(settings)
{ {
m_counters.reset(); m_counters.reset();

View File

@ -353,7 +353,7 @@ namespace libtorrent { namespace dht
struct get_immutable_item_ctx struct get_immutable_item_ctx
{ {
get_immutable_item_ctx(int traversals) explicit get_immutable_item_ctx(int traversals)
: active_traversals(traversals) : active_traversals(traversals)
, item_posted(false) , item_posted(false)
{} {}
@ -379,7 +379,7 @@ namespace libtorrent { namespace dht
struct get_mutable_item_ctx struct get_mutable_item_ctx
{ {
get_mutable_item_ctx(int traversals) : active_traversals(traversals) {} explicit get_mutable_item_ctx(int traversals) : active_traversals(traversals) {}
int active_traversals; int active_traversals;
item it; item it;
}; };
@ -404,7 +404,7 @@ namespace libtorrent { namespace dht
struct put_item_ctx struct put_item_ctx
{ {
put_item_ctx(int traversals) explicit put_item_ctx(int traversals)
: active_traversals(traversals) : active_traversals(traversals)
, response_count(0) , response_count(0)
{} {}

View File

@ -73,7 +73,7 @@ namespace libtorrent { namespace
struct lt_tracker_plugin : torrent_plugin struct lt_tracker_plugin : torrent_plugin
{ {
lt_tracker_plugin(torrent& t) explicit lt_tracker_plugin(torrent& t)
: m_torrent(t) : m_torrent(t)
, m_updates(0) , m_updates(0)
, m_2_minutes(110) , m_2_minutes(110)

View File

@ -99,7 +99,7 @@ namespace libtorrent { namespace
struct metadata_plugin final struct metadata_plugin final
: torrent_plugin : torrent_plugin
{ {
metadata_plugin(torrent& t) explicit metadata_plugin(torrent& t)
: m_torrent(t) : m_torrent(t)
, m_metadata_progress(0) , m_metadata_progress(0)
, m_metadata_size(0) , m_metadata_size(0)

View File

@ -2568,7 +2568,7 @@ namespace libtorrent
#if TORRENT_USE_INVARIANT_CHECKS #if TORRENT_USE_INVARIANT_CHECKS
struct check_postcondition struct check_postcondition
{ {
check_postcondition(boost::shared_ptr<torrent> const& t_ explicit check_postcondition(boost::shared_ptr<torrent> const& t_
, bool init_check = true): t(t_) { if (init_check) check(); } , bool init_check = true): t(t_) { if (init_check) check(); }
~check_postcondition() { check(); } ~check_postcondition() { check(); }

View File

@ -71,7 +71,7 @@ namespace
struct match_peer_endpoint struct match_peer_endpoint
{ {
match_peer_endpoint(tcp::endpoint const& ep) explicit match_peer_endpoint(tcp::endpoint const& ep)
: m_ep(ep) : m_ep(ep)
{} {}
@ -87,7 +87,7 @@ namespace
#if TORRENT_USE_INVARIANT_CHECKS #if TORRENT_USE_INVARIANT_CHECKS
struct match_peer_connection struct match_peer_connection
{ {
match_peer_connection(peer_connection_interface const& c) : m_conn(c) {} explicit match_peer_connection(peer_connection_interface const& c) : m_conn(c) {}
bool operator()(torrent_peer const* p) const bool operator()(torrent_peer const* p) const
{ {
@ -102,7 +102,7 @@ namespace
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
struct match_peer_connection_or_endpoint struct match_peer_connection_or_endpoint
{ {
match_peer_connection_or_endpoint(peer_connection_interface const& c) : m_conn(c) {} explicit match_peer_connection_or_endpoint(peer_connection_interface const& c) : m_conn(c) {}
bool operator()(torrent_peer const* p) const bool operator()(torrent_peer const* p) const
{ {

View File

@ -403,7 +403,7 @@ namespace libtorrent
, std::shared_ptr<std::thread> t , std::shared_ptr<std::thread> t
, boost::shared_ptr<aux::session_impl> impl) , boost::shared_ptr<aux::session_impl> impl)
: m_io_service(std::move(ios)) : m_io_service(std::move(ios))
, m_thread(t) , m_thread(std::move(t))
, m_impl(impl) , m_impl(impl)
{} {}
session_proxy::session_proxy(session_proxy const&) = default; session_proxy::session_proxy(session_proxy const&) = default;

View File

@ -776,7 +776,7 @@ namespace aux {
struct session_plugin_wrapper : plugin struct session_plugin_wrapper : plugin
{ {
session_plugin_wrapper(ext_function_t const& f) : m_f(f) {} explicit session_plugin_wrapper(ext_function_t const& f) : m_f(f) {}
boost::shared_ptr<torrent_plugin> new_torrent(torrent_handle const& t, void* user) override boost::shared_ptr<torrent_plugin> new_torrent(torrent_handle const& t, void* user) override
{ return m_f(t, user); } { return m_f(t, user); }
@ -3736,7 +3736,7 @@ namespace aux {
struct opt_unchoke_candidate struct opt_unchoke_candidate
{ {
opt_unchoke_candidate(boost::shared_ptr<peer_connection> const* tp) explicit opt_unchoke_candidate(boost::shared_ptr<peer_connection> const* tp)
: peer(tp) : peer(tp)
{} {}
@ -3752,7 +3752,7 @@ namespace aux {
struct last_optimistic_unchoke_cmp struct last_optimistic_unchoke_cmp
{ {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
last_optimistic_unchoke_cmp(std::vector<boost::shared_ptr<plugin>>& ps) explicit last_optimistic_unchoke_cmp(std::vector<boost::shared_ptr<plugin>>& ps)
: plugins(ps) : plugins(ps)
{} {}

View File

@ -76,7 +76,7 @@ namespace
: torrent_plugin : torrent_plugin
, boost::enable_shared_from_this<smart_ban_plugin> , boost::enable_shared_from_this<smart_ban_plugin>
{ {
smart_ban_plugin(torrent& t) explicit smart_ban_plugin(torrent& t)
: m_torrent(t) : m_torrent(t)
, m_salt(random()) , m_salt(random())
{} {}

View File

@ -100,8 +100,8 @@ namespace libtorrent
ctx = SSL_get_SSL_CTX(ssl); \ ctx = SSL_get_SSL_CTX(ssl); \
break; break;
SSL* ssl = 0; SSL* ssl = nullptr;
SSL_CTX* ctx = 0; SSL_CTX* ctx = nullptr;
switch(s.type()) switch(s.type())
{ {
@ -115,8 +115,8 @@ namespace libtorrent
#if OPENSSL_VERSION_NUMBER >= 0x90812f #if OPENSSL_VERSION_NUMBER >= 0x90812f
if (ctx) if (ctx)
{ {
aux::openssl_set_tlsext_servername_callback(ctx, 0); aux::openssl_set_tlsext_servername_callback(ctx, nullptr);
aux::openssl_set_tlsext_servername_arg(ctx, 0); aux::openssl_set_tlsext_servername_arg(ctx, nullptr);
} }
#endif // OPENSSL_VERSION_NUMBER #endif // OPENSSL_VERSION_NUMBER

View File

@ -1488,7 +1488,7 @@ namespace libtorrent
// Go through the alternate names in the certificate looking for matching DNS entries // Go through the alternate names in the certificate looking for matching DNS entries
GENERAL_NAMES* gens = static_cast<GENERAL_NAMES*>( GENERAL_NAMES* gens = static_cast<GENERAL_NAMES*>(
X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0)); X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr));
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
std::string names; std::string names;
@ -1525,7 +1525,7 @@ namespace libtorrent
// use the "most specific" common name, which is the last one in the list. // use the "most specific" common name, which is the last one in the list.
X509_NAME* name = X509_get_subject_name(cert); X509_NAME* name = X509_get_subject_name(cert);
int i = -1; int i = -1;
ASN1_STRING* common_name = 0; ASN1_STRING* common_name = nullptr;
while ((i = X509_NAME_get_index_by_NID(name, NID_commonName, i)) >= 0) while ((i = X509_NAME_get_index_by_NID(name, NID_commonName, i)) >= 0)
{ {
X509_NAME_ENTRY* name_entry = X509_NAME_get_entry(name, i); X509_NAME_ENTRY* name_entry = X509_NAME_get_entry(name, i);
@ -1637,7 +1637,7 @@ namespace libtorrent
// parse the certificate into OpenSSL's internal // parse the certificate into OpenSSL's internal
// representation // representation
X509* certificate = PEM_read_bio_X509_AUX(bp, 0, 0, 0); X509* certificate = PEM_read_bio_X509_AUX(bp, nullptr, nullptr, nullptr);
BIO_free(bp); BIO_free(bp);
@ -7100,7 +7100,7 @@ namespace libtorrent
ssl_conn = s->get<ssl_stream<t> >()->native_handle(); \ ssl_conn = s->get<ssl_stream<t> >()->native_handle(); \
break; break;
SSL* ssl_conn = 0; SSL* ssl_conn = nullptr;
switch (s->type()) switch (s->type())
{ {
@ -7112,7 +7112,7 @@ namespace libtorrent
#undef SSL #undef SSL
if (ssl_conn == 0) if (ssl_conn == nullptr)
{ {
// don't allow non SSL peers on SSL torrents // don't allow non SSL peers on SSL torrents
p->disconnect(errors::requires_ssl_connection, op_bittorrent); p->disconnect(errors::requires_ssl_connection, op_bittorrent);

View File

@ -1539,7 +1539,7 @@ namespace libtorrent
{ {
struct filter_web_seed_type struct filter_web_seed_type
{ {
filter_web_seed_type(web_seed_entry::type_t t_) : t(t_) {} explicit filter_web_seed_type(web_seed_entry::type_t t_) : t(t_) {}
void operator() (web_seed_entry const& w) void operator() (web_seed_entry const& w)
{ if (w.type == t) urls.push_back(w.url); } { if (w.type == t) urls.push_back(w.url); }
std::vector<std::string> urls; std::vector<std::string> urls;

View File

@ -74,7 +74,7 @@ using namespace std::placeholders;
// the common case cheaper by not allocating this space unconditionally // the common case cheaper by not allocating this space unconditionally
struct socks5 : boost::enable_shared_from_this<socks5> struct socks5 : boost::enable_shared_from_this<socks5>
{ {
socks5(io_service& ios) explicit socks5(io_service& ios)
: m_socks5_sock(ios) : m_socks5_sock(ios)
, m_resolver(ios) , m_resolver(ios)
, m_timer(ios) , m_timer(ios)

View File

@ -95,7 +95,7 @@ namespace libtorrent { namespace
struct ut_metadata_plugin final struct ut_metadata_plugin final
: torrent_plugin : torrent_plugin
{ {
ut_metadata_plugin(torrent& t) explicit ut_metadata_plugin(torrent& t)
: m_torrent(t) : m_torrent(t)
// , m_metadata_progress(0) // , m_metadata_progress(0)
, m_metadata_size(0) , m_metadata_size(0)

View File

@ -88,7 +88,7 @@ namespace libtorrent { namespace
// to evenly spread it out across all torrents // to evenly spread it out across all torrents
// the more torrents we have, the longer we can // the more torrents we have, the longer we can
// delay the rebuilding // delay the rebuilding
ut_pex_plugin(torrent& t) explicit ut_pex_plugin(torrent& t)
: m_torrent(t) : m_torrent(t)
, m_last_msg(min_time()) , m_last_msg(min_time())
, m_peers_in_message(0) {} , m_peers_in_message(0) {}

View File

@ -1723,7 +1723,7 @@ void utp_socket_impl::remove_sack_header(packet* p)
struct holder struct holder
{ {
holder(char* buf = nullptr): m_buf(buf) {} explicit holder(char* buf = nullptr): m_buf(buf) {}
~holder() { free(m_buf); } ~holder() { free(m_buf); }
void reset(char* buf) void reset(char* buf)

View File

@ -156,7 +156,7 @@ int plugin_alerts[3] = { 0, 0, 0 };
struct test_plugin : libtorrent::plugin struct test_plugin : libtorrent::plugin
{ {
test_plugin(int index) : m_index(index) {} explicit test_plugin(int index) : m_index(index) {}
void on_alert(alert const* a) override void on_alert(alert const* a) override
{ {
++plugin_alerts[m_index]; ++plugin_alerts[m_index];

View File

@ -69,7 +69,7 @@ struct D
struct E struct E
{ {
E(char const* msg) : string_member(msg) {} explicit E(char const* msg) : string_member(msg) {}
std::string string_member; std::string string_member;
}; };
@ -77,7 +77,7 @@ int D::instances = 0;
struct F struct F
{ {
F(int f_) explicit F(int f_)
: self(this) : self(this)
, f(f_) , f(f_)
, constructed(true) , constructed(true)

View File

@ -37,7 +37,7 @@ using namespace libtorrent;
struct test_node : list_node<test_node> struct test_node : list_node<test_node>
{ {
test_node(int v) : val(v) {} explicit test_node(int v) : val(v) {}
int val; int val;
}; };

View File

@ -113,7 +113,7 @@ struct mock_peer_connection
struct mock_torrent struct mock_torrent
{ {
mock_torrent(torrent_state* st) : m_p(nullptr), m_state(st) {} explicit mock_torrent(torrent_state* st) : m_p(nullptr), m_state(st) {}
virtual ~mock_torrent() = default; virtual ~mock_torrent() = default;
bool connect_to_peer(torrent_peer* peerinfo, bool ignore_limit = false) bool connect_to_peer(torrent_peer* peerinfo, bool ignore_limit = false)

View File

@ -196,7 +196,7 @@ void test_ssl(int test_idx, bool use_utp)
ssl_peer_disconnects = 0; ssl_peer_disconnects = 0;
peer_errors = 0; peer_errors = 0;
std::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0 std::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, nullptr
, true, false, false, "_ssl", 16 * 1024, &t, false, &addp, true); , true, false, false, "_ssl", 16 * 1024, &t, false, &addp, true);
if (test.seed_has_cert) if (test.seed_has_cert)

View File

@ -1022,7 +1022,7 @@ file_storage make_fs()
struct test_fileop : fileop struct test_fileop : fileop
{ {
test_fileop(int stripe_size) : m_stripe_size(stripe_size) {} explicit test_fileop(int stripe_size) : m_stripe_size(stripe_size) {}
int file_op(int const file_index, std::int64_t const file_offset, int const size int file_op(int const file_index, std::int64_t const file_offset, int const size
, file::iovec_t const* bufs, storage_error& ec) override , file::iovec_t const* bufs, storage_error& ec) override
@ -1061,7 +1061,7 @@ struct test_fileop : fileop
struct test_read_fileop : fileop struct test_read_fileop : fileop
{ {
// EOF after size bytes read // EOF after size bytes read
test_read_fileop(int size) : m_size(size), m_counter(0) {} explicit test_read_fileop(int size) : m_size(size), m_counter(0) {}
int file_op(int const file_index, std::int64_t const file_offset, int const size int file_op(int const file_index, std::int64_t const file_offset, int const size
, file::iovec_t const* bufs, storage_error& ec) override , file::iovec_t const* bufs, storage_error& ec) override
@ -1091,7 +1091,7 @@ struct test_read_fileop : fileop
struct test_error_fileop : fileop struct test_error_fileop : fileop
{ {
// EOF after size bytes read // EOF after size bytes read
test_error_fileop(int error_file) explicit test_error_fileop(int error_file)
: m_error_file(error_file) {} : m_error_file(error_file) {}
int file_op(int const file_index, std::int64_t const file_offset, int const size int file_op(int const file_index, std::int64_t const file_offset, int const size

View File

@ -37,7 +37,7 @@ using namespace libtorrent;
struct test_node : tailqueue_node<test_node> struct test_node : tailqueue_node<test_node>
{ {
test_node(char n) : name(n) {} explicit test_node(char n) : name(n) {}
char name; char name;
}; };

View File

@ -312,7 +312,7 @@ struct test_plugin : libtorrent::torrent_plugin {};
struct plugin_creator struct plugin_creator
{ {
plugin_creator(int& c) : m_called(c) {} explicit plugin_creator(int& c) : m_called(c) {}
boost::shared_ptr<libtorrent::torrent_plugin> boost::shared_ptr<libtorrent::torrent_plugin>
operator()(torrent_handle const&, void*) operator()(torrent_handle const&, void*)

View File

@ -71,7 +71,7 @@ bool on_alert(alert const* a)
// simulate a full disk // simulate a full disk
struct test_storage : default_storage struct test_storage : default_storage
{ {
test_storage(storage_params const& params) explicit test_storage(storage_params const& params)
: default_storage(params) : default_storage(params)
, m_written(0) , m_written(0)
, m_limit(16 * 1024 * 2) , m_limit(16 * 1024 * 2)