address coverity issues and build issue with non atomic 64 bit operations
This commit is contained in:
parent
4a304273fd
commit
8fdacf9534
|
@ -2142,7 +2142,15 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
int num_pieces = t->torrent_file().num_pieces();
|
||||
const int num_pieces = t->torrent_file().num_pieces();
|
||||
TORRENT_ASSERT(num_pieces > 0);
|
||||
if (num_pieces <= 0)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(peer_log_alert::info, "BITFIELD", "not sending bitfield, num_pieces == 0");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
int lazy_pieces[50];
|
||||
int num_lazy_pieces = 0;
|
||||
|
|
|
@ -2359,9 +2359,6 @@ namespace libtorrent
|
|||
int block_size = m_disk_cache.block_size();
|
||||
int blocks_in_piece = (piece_size + block_size - 1) / block_size;
|
||||
|
||||
file::iovec_t iov;
|
||||
int ret = 0;
|
||||
|
||||
// keep track of which blocks we have locked by incrementing
|
||||
// their refcounts. This is used to decrement only these blocks
|
||||
// later.
|
||||
|
@ -2374,8 +2371,6 @@ namespace libtorrent
|
|||
TORRENT_PIECE_ASSERT(ph->offset % block_size == 0, pe);
|
||||
for (int i = ph->offset / block_size; i < blocks_in_piece; ++i)
|
||||
{
|
||||
iov.iov_len = (std::min)(block_size, piece_size - ph->offset);
|
||||
|
||||
// is the block not in the cache?
|
||||
if (pe->blocks[i].buf == NULL) continue;
|
||||
|
||||
|
@ -2388,9 +2383,11 @@ namespace libtorrent
|
|||
|
||||
l.unlock();
|
||||
|
||||
int ret = 0;
|
||||
int next_locked_block = 0;
|
||||
for (int i = ph->offset / block_size; i < blocks_in_piece; ++i)
|
||||
{
|
||||
file::iovec_t iov;
|
||||
iov.iov_len = (std::min)(block_size, piece_size - ph->offset);
|
||||
|
||||
if (next_locked_block < num_locked_blocks
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace libtorrent {
|
|||
, boost::memory_order_relaxed);
|
||||
#else
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(c.m_mutex);
|
||||
mutex::scoped_lock l2(c.m_mutex);
|
||||
memcpy(m_stats_counter, c.m_stats_counter, sizeof(m_stats_counter));
|
||||
#endif
|
||||
return *this;
|
||||
|
|
|
@ -1192,11 +1192,14 @@ namespace aux {
|
|||
{
|
||||
#ifdef TORRENT_DEBUG
|
||||
// make it obvious that the return value is undefined
|
||||
ret.upload_limit = random();
|
||||
ret.download_limit = random();
|
||||
ret.upload_limit = 0xf0f0f0f;
|
||||
ret.download_limit = 0xf0f0f0f;
|
||||
ret.label.resize(20);
|
||||
url_random(&ret.label[0], &ret.label[0] + 20);
|
||||
ret.ignore_unchoke_slots = false;
|
||||
ret.connection_limit_factor = 0xf0f0f0f;
|
||||
ret.upload_priority = 0xf0f0f0f;
|
||||
ret.download_priority = 0xf0f0f0f;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
@ -2392,7 +2395,7 @@ retry:
|
|||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
session_log(" <== INCOMING CONNECTION FAILED, could "
|
||||
"not retrieve remote endpoint: %s"
|
||||
, print_endpoint(endp).c_str(), ec.message().c_str());
|
||||
, ec.message().c_str());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3084,13 +3084,13 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
|
||||
if (sample && acked_bytes && prev_bytes_in_flight)
|
||||
{
|
||||
// only use the minimum from the last 3 delay measurements
|
||||
delay = *std::min_element(m_delay_sample_hist, m_delay_sample_hist + num_delay_hist);
|
||||
|
||||
// it's impossible for delay to be more than the RTT, so make
|
||||
// sure to clamp it as a sanity check
|
||||
if (delay > min_rtt) delay = min_rtt;
|
||||
|
||||
// only use the minimum from the last 3 delay measurements
|
||||
delay = *std::min_element(m_delay_sample_hist, m_delay_sample_hist + num_delay_hist);
|
||||
|
||||
do_ledbat(acked_bytes, delay, prev_bytes_in_flight);
|
||||
m_send_delay = delay;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue