forked from premiere/premiere-libtorrent
fix some cppcheck warnings
This commit is contained in:
parent
e80506d3b3
commit
3f87801142
|
@ -114,7 +114,7 @@ public:
|
|||
// if this assert trips, set_dst_name() is called wth an IP address rather
|
||||
// than a hostname. Instead, resolve the IP into an address and pass it to
|
||||
// async_connect instead
|
||||
TORRENT_ASSERT(!is_ip_address(host.c_str()));
|
||||
TORRENT_ASSERT(!is_ip_address(host));
|
||||
m_dst_name = host;
|
||||
if (m_dst_name.size() > 255)
|
||||
m_dst_name.resize(255);
|
||||
|
|
|
@ -393,8 +393,8 @@ namespace {
|
|||
alignment = piece_size;
|
||||
|
||||
// make sure the size is an even power of 2
|
||||
#ifndef NDEBUG
|
||||
for (int i = 0; i < 32; ++i)
|
||||
#if TORRENT_USE_ASSERTS
|
||||
for (int i = 0; i < 31; ++i)
|
||||
{
|
||||
if (piece_size & (1 << i))
|
||||
{
|
||||
|
@ -593,7 +593,7 @@ namespace {
|
|||
{
|
||||
entry& sympath_e = info["symlink path"];
|
||||
|
||||
std::string split = split_path(m_files.symlink(first));
|
||||
std::string const split = split_path(m_files.symlink(first));
|
||||
for (char const* e = split.c_str(); e != nullptr; e = next_path_element(e))
|
||||
sympath_e.list().emplace_back(e);
|
||||
}
|
||||
|
@ -614,12 +614,12 @@ namespace {
|
|||
entry& file_e = files.list().back();
|
||||
if (m_include_mtime && m_files.mtime(i)) file_e["mtime"] = m_files.mtime(i);
|
||||
file_e["length"] = m_files.file_size(i);
|
||||
entry& path_e = file_e["path"];
|
||||
|
||||
TORRENT_ASSERT(has_parent_path(m_files.file_path(i)));
|
||||
|
||||
{
|
||||
std::string split = split_path(m_files.file_path(i));
|
||||
entry& path_e = file_e["path"];
|
||||
std::string const split = split_path(m_files.file_path(i));
|
||||
TORRENT_ASSERT(split.c_str() == m_files.name());
|
||||
|
||||
for (char const* e = next_path_element(split.c_str());
|
||||
|
@ -642,7 +642,7 @@ namespace {
|
|||
{
|
||||
entry& sympath_e = file_e["symlink path"];
|
||||
|
||||
std::string split = split_path(m_files.symlink(i));
|
||||
std::string const split = split_path(m_files.symlink(i));
|
||||
for (char const* e = split.c_str(); e != nullptr; e = next_path_element(e))
|
||||
sympath_e.list().emplace_back(e);
|
||||
}
|
||||
|
|
|
@ -990,7 +990,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||
return std::vector<ip_route>();
|
||||
}
|
||||
|
||||
if (needed <= 0)
|
||||
if (needed == 0)
|
||||
{
|
||||
return std::vector<ip_route>();
|
||||
}
|
||||
|
|
|
@ -295,7 +295,7 @@ void http_connection::start(std::string const& hostname, int port
|
|||
m_read_timeout *= 4;
|
||||
|
||||
#if TORRENT_USE_I2P
|
||||
if (is_i2p && i2p_conn->proxy().type != settings_pack::i2p_proxy)
|
||||
if (i2p_conn->proxy().type != settings_pack::i2p_proxy)
|
||||
{
|
||||
m_timer.get_io_service().post(std::bind(&http_connection::callback
|
||||
, me, error_code(errors::no_i2p_router), span<char>{}));
|
||||
|
|
|
@ -359,9 +359,7 @@ namespace libtorrent {
|
|||
if (f) return f;
|
||||
|
||||
// look for mainline style id
|
||||
f = parse_mainline_style(p);
|
||||
if (f) return f;
|
||||
return f;
|
||||
return parse_mainline_style(p);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -84,7 +84,7 @@ bool verify_message_impl(bdecode_node const& message, span<key_desc_t const> des
|
|||
&& ret[i]
|
||||
&& k.type == bdecode_node::string_t)
|
||||
{
|
||||
bool const invalid = k.flags & key_desc_t::size_divisible
|
||||
bool const invalid = (k.flags & key_desc_t::size_divisible)
|
||||
? (ret[i].string_length() % k.size) != 0
|
||||
: ret[i].string_length() != k.size;
|
||||
|
||||
|
|
|
@ -451,7 +451,7 @@ void node::announce(sha1_hash const& info_hash, int listen_port, announce_flags_
|
|||
if (listen_port == 0 && m_observer != nullptr)
|
||||
{
|
||||
listen_port = m_observer->get_listen_port(
|
||||
flags & announce::ssl_torrent ? aux::transport::ssl : aux::transport::plaintext
|
||||
(flags & announce::ssl_torrent) ? aux::transport::ssl : aux::transport::plaintext
|
||||
, m_sock);
|
||||
}
|
||||
|
||||
|
@ -687,7 +687,6 @@ void node::send_single_refresh(udp::endpoint const& ep, int const bucket
|
|||
#endif
|
||||
entry e;
|
||||
e["y"] = "q";
|
||||
entry& a = e["a"];
|
||||
|
||||
if (m_table.is_full(bucket))
|
||||
{
|
||||
|
@ -700,7 +699,7 @@ void node::send_single_refresh(udp::endpoint const& ep, int const bucket
|
|||
// use get_peers instead of find_node. We'll get nodes in the response
|
||||
// either way.
|
||||
e["q"] = "get_peers";
|
||||
a["info_hash"] = target.to_string();
|
||||
e["a"]["info_hash"] = target.to_string();
|
||||
m_counters.inc_stats_counter(counters::dht_get_peers_out);
|
||||
}
|
||||
|
||||
|
|
|
@ -2312,8 +2312,8 @@ namespace libtorrent {
|
|||
{
|
||||
if (e->on_request(r)) return;
|
||||
}
|
||||
#endif
|
||||
if (is_disconnecting()) return;
|
||||
#endif
|
||||
|
||||
if (!t->valid_metadata())
|
||||
{
|
||||
|
@ -5309,7 +5309,7 @@ namespace libtorrent {
|
|||
, "piece: %d s: %x l: %x b: %p c: %s e: %s rtt: %d us"
|
||||
, static_cast<int>(r.piece), r.start, r.length
|
||||
, static_cast<void*>(buffer.get())
|
||||
, (flags & disk_interface::cache_hit ? "cache hit" : "cache miss")
|
||||
, ((flags & disk_interface::cache_hit) ? "cache hit" : "cache miss")
|
||||
, error.ec.message().c_str(), disk_rtt);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1266,8 +1266,6 @@ namespace libtorrent {
|
|||
TORRENT_ASSERT(m_num_connect_candidates <= int(m_peers.size()));
|
||||
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
int total_connections = 0;
|
||||
int nonempty_connections = 0;
|
||||
int connect_candidates = 0;
|
||||
|
||||
const_iterator prev = m_peers.end();
|
||||
|
@ -1282,7 +1280,6 @@ namespace libtorrent {
|
|||
torrent_peer const& p = **i;
|
||||
TORRENT_ASSERT(p.in_use);
|
||||
if (is_connect_candidate(p)) ++connect_candidates;
|
||||
++total_connections;
|
||||
if (!p.connection)
|
||||
{
|
||||
continue;
|
||||
|
@ -1294,7 +1291,6 @@ namespace libtorrent {
|
|||
}
|
||||
TORRENT_ASSERT(p.connection->peer_info_struct() == nullptr
|
||||
|| p.connection->peer_info_struct() == &p);
|
||||
++nonempty_connections;
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(m_num_connect_candidates == connect_candidates);
|
||||
|
|
|
@ -1265,7 +1265,6 @@ namespace libtorrent {
|
|||
// the piece list dirty, just update those pieces
|
||||
// instead
|
||||
TORRENT_ALLOCA(incremented, piece_index_t, size);
|
||||
int num_inc = 0;
|
||||
|
||||
if (!m_dirty)
|
||||
{
|
||||
|
@ -1275,6 +1274,7 @@ namespace libtorrent {
|
|||
// this only matters if we're not already dirty, in which case the fasted
|
||||
// thing to do is to just update the counters and be done
|
||||
piece_index_t index = piece_index_t(0);
|
||||
int num_inc = 0;
|
||||
for (auto i = bitmask.begin(), end(bitmask.end()); i != end; ++i, ++index)
|
||||
{
|
||||
if (!*i) continue;
|
||||
|
@ -1361,7 +1361,6 @@ namespace libtorrent {
|
|||
// the piece list dirty, just update those pieces
|
||||
// instead
|
||||
TORRENT_ALLOCA(decremented, piece_index_t, size);
|
||||
int num_dec = 0;
|
||||
|
||||
if (!m_dirty)
|
||||
{
|
||||
|
@ -1371,6 +1370,7 @@ namespace libtorrent {
|
|||
// this only matters if we're not already dirty, in which case the fasted
|
||||
// thing to do is to just update the counters and be done
|
||||
piece_index_t index = piece_index_t(0);
|
||||
int num_dec = 0;
|
||||
for (auto i = bitmask.begin(), end(bitmask.end()); i != end; ++i, ++index)
|
||||
{
|
||||
if (!*i) continue;
|
||||
|
|
|
@ -267,10 +267,10 @@ namespace libtorrent {
|
|||
// use if if it hasn't expired
|
||||
if (aux::time_now() < cc->second.expires)
|
||||
{
|
||||
if (0 == (tracker_req().kind & tracker_request::scrape_request))
|
||||
send_udp_announce();
|
||||
else if (0 != (tracker_req().kind & tracker_request::scrape_request))
|
||||
if (tracker_req().kind & tracker_request::scrape_request)
|
||||
send_udp_scrape();
|
||||
else
|
||||
send_udp_announce();
|
||||
return;
|
||||
}
|
||||
// if it expired, remove it from the cache
|
||||
|
|
Loading…
Reference in New Issue