diff --git a/include/libtorrent/alert_manager.hpp b/include/libtorrent/alert_manager.hpp index 6aefdece5..587c42d39 100644 --- a/include/libtorrent/alert_manager.hpp +++ b/include/libtorrent/alert_manager.hpp @@ -57,7 +57,7 @@ namespace libtorrent { class TORRENT_EXTRA_EXPORT alert_manager { public: - alert_manager(int queue_limit + explicit alert_manager(int queue_limit , alert_category_t alert_mask = alert::error_notification); alert_manager(alert_manager const&) = delete; diff --git a/src/block_cache.cpp b/src/block_cache.cpp index 3196f0315..185b5a4e0 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -322,8 +322,8 @@ cached_piece_entry::cached_piece_entry() cached_piece_entry::~cached_piece_entry() { TORRENT_ASSERT(piece_refcount == 0); - TORRENT_ASSERT(jobs.size() == 0); - TORRENT_ASSERT(read_jobs.size() == 0); + TORRENT_ASSERT(jobs.empty()); + TORRENT_ASSERT(read_jobs.empty()); #if TORRENT_USE_ASSERTS if (blocks) { @@ -766,7 +766,7 @@ cached_piece_entry* block_cache::add_dirty_block(disk_io_job* j) // (since these blocks now are part of the read cache) the refcounts of the // blocks are also decremented by this function. They are expected to have been // incremented by the caller. -bool block_cache::blocks_flushed(cached_piece_entry* pe, int const* flushed, int num_flushed) +bool block_cache::blocks_flushed(cached_piece_entry* pe, int const* flushed, int const num_flushed) { TORRENT_PIECE_ASSERT(pe->in_use, pe); @@ -883,7 +883,7 @@ bool block_cache::evict_piece(cached_piece_entry* pe, tailqueue& jo // append will move the items from pe->jobs onto the end of jobs jobs.append(pe->jobs); - TORRENT_ASSERT(pe->jobs.size() == 0); + TORRENT_ASSERT(pe->jobs.empty()); if (mode == allow_ghost && (pe->cache_state == cached_piece_entry::read_lru1_ghost @@ -1005,7 +1005,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore) // to iterate over this linked list. Presumably because of the random // access of memory. It would be nice if pieces with no evictable blocks // weren't in this list - for (list_iterator i = lru_list[end]->iterate(); i.get() && num > 0;) + for (auto i = lru_list[end]->iterate(); i.get() && num > 0;) { cached_piece_entry* pe = i.get(); TORRENT_PIECE_ASSERT(pe->in_use, pe); @@ -1077,7 +1077,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore) { for (int pass = 0; pass < 2 && num > 0; ++pass) { - for (list_iterator i = m_lru[cached_piece_entry::write_lru].iterate(); i.get() && num > 0;) + for (auto i = m_lru[cached_piece_entry::write_lru].iterate(); i.get() && num > 0;) { cached_piece_entry* pe = i.get(); TORRENT_PIECE_ASSERT(pe->in_use, pe); @@ -1263,7 +1263,7 @@ void block_cache::insert_blocks(cached_piece_entry* pe, int block, spanin_use); - TORRENT_PIECE_ASSERT(iov.size() > 0, pe); + TORRENT_PIECE_ASSERT(!iov.empty(), pe); cache_hit(pe, j->d.io.offset / default_block_size, bool(j->flags & disk_interface::volatile_read)); @@ -1349,7 +1349,7 @@ bool block_cache::inc_block_refcount(cached_piece_entry* pe, int block, int reas return true; } -void block_cache::dec_block_refcount(cached_piece_entry* pe, int block, int reason) +void block_cache::dec_block_refcount(cached_piece_entry* pe, int const block, int const reason) { TORRENT_PIECE_ASSERT(pe->in_use, pe); TORRENT_PIECE_ASSERT(block < pe->blocks_in_piece, pe); @@ -1762,12 +1762,12 @@ cached_piece_entry* block_cache::find_piece(disk_io_job const* j) return find_piece(j->storage.get(), j->piece); } -cached_piece_entry* block_cache::find_piece(storage_interface* st, piece_index_t piece) +cached_piece_entry* block_cache::find_piece(storage_interface* st, piece_index_t const piece) { cached_piece_entry model; model.storage = st->shared_from_this(); model.piece = piece; - auto i = m_pieces.find(model); + auto const i = m_pieces.find(model); TORRENT_ASSERT(i == m_pieces.end() || (i->storage.get() == st && i->piece == piece)); if (i == m_pieces.end()) return nullptr; TORRENT_PIECE_ASSERT(i->in_use, &*i); diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 7307fd562..800de5d31 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -738,7 +738,7 @@ namespace { std::memcpy(ptr, ih.data(), ih.size()); ptr += 20; - std::memcpy(ptr, &m_our_peer_id[0], 20); + std::memcpy(ptr, m_our_peer_id.data(), 20); ptr += 20; #ifndef TORRENT_DISABLE_LOGGING diff --git a/src/pe_crypto.cpp b/src/pe_crypto.cpp index e55a4b800..46238fed4 100644 --- a/src/pe_crypto.cpp +++ b/src/pe_crypto.cpp @@ -308,7 +308,7 @@ namespace libtorrent { { span> empty; if (!m_encrypt) return std::make_tuple(0, empty); - if (bufs.size() == 0) return std::make_tuple(0, empty); + if (bufs.empty()) return std::make_tuple(0, empty); int bytes_processed = 0; for (auto& buf : bufs)