diff --git a/examples/client_test.cpp b/examples/client_test.cpp index dd0166c85..754f93d21 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1665,7 +1665,7 @@ COLUMN OPTIONS , "%3d [%3d, %d] %s%s\x1b[K\n" , bucket, n.num_nodes, n.num_replacements , progress_bar + (128 - n.num_nodes) - , short_progress_bar + (8 - (std::min)(8, n.num_replacements))); + , short_progress_bar + (8 - std::min(8, n.num_replacements))); out += str; pos += 1; } diff --git a/examples/connection_tester.cpp b/examples/connection_tester.cpp index 3e7ef16f8..028527390 100644 --- a/examples/connection_tester.cpp +++ b/examples/connection_tester.cpp @@ -629,7 +629,7 @@ struct peer_conn } else { - block = (std::min)(start / 0x4000, block); + block = std::min(start / 0x4000, block); if (block == 0) { pieces.push_back(current_piece); @@ -802,7 +802,7 @@ void generate_torrent(std::vector& buf, int num_pieces, int num_files char b[100]; std::snprintf(b, sizeof(b), "%s/stress_test%d", torrent_name, i); ++i; - fs.add_file(b, (std::min)(s, std::int64_t(file_size))); + fs.add_file(b, std::min(s, file_size)); s -= file_size; file_size += 200; } diff --git a/examples/dump_torrent.cpp b/examples/dump_torrent.cpp index 16efc278b..a42a91a1a 100644 --- a/examples/dump_torrent.cpp +++ b/examples/dump_torrent.cpp @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) try for (lt::file_index_t i(0); i < st.end_file(); ++i) { auto const first = st.map_file(i, 0, 0).piece; - auto const last = st.map_file(i, (std::max)(std::int64_t(st.file_size(i))-1, std::int64_t(0)), 0).piece; + auto const last = st.map_file(i, std::max(std::int64_t(st.file_size(i)) - 1, std::int64_t(0)), 0).piece; auto const flags = st.file_flags(i); std::stringstream file_hash; if (!st.hash(i).is_all_zeros()) diff --git a/examples/print.cpp b/examples/print.cpp index 7858f45a0..a4405d5a6 100644 --- a/examples/print.cpp +++ b/examples/print.cpp @@ -544,4 +544,3 @@ one_more: fputs(buf, stdout); #endif } - diff --git a/examples/session_view.cpp b/examples/session_view.cpp index f68b190e1..9cb78b9e0 100644 --- a/examples/session_view.cpp +++ b/examples/session_view.cpp @@ -115,9 +115,9 @@ void session_view::render() , color(to_string(int(m_cnt[0][m_queued_reads_idx]), 3), col_red).c_str() , color(to_string(int(m_cnt[0][m_queued_writes_idx]), 3), col_green).c_str() , int((m_cnt[0][m_blocks_written_idx] - m_cnt[0][m_write_ops_idx]) * 100 - / (std::max)(std::int64_t(1), m_cnt[0][m_blocks_written_idx])) + / std::max(std::int64_t(1), m_cnt[0][m_blocks_written_idx])) , int(m_cnt[0][m_cache_hit_idx] * 100 - / (std::max)(std::int64_t(1), m_cnt[0][m_num_blocks_read_idx])) + / std::max(std::int64_t(1), m_cnt[0][m_num_blocks_read_idx])) , add_suffix(m_cnt[0][m_writes_cache_idx] * 16 * 1024).c_str() , add_suffix(m_cnt[0][m_reads_cache_idx] * 16 * 1024).c_str() , add_suffix(m_cnt[0][m_blocks_in_use_idx] * 16 * 1024).c_str() diff --git a/simulation/setup_dht.cpp b/simulation/setup_dht.cpp index 1a1ab77cf..382d635a9 100644 --- a/simulation/setup_dht.cpp +++ b/simulation/setup_dht.cpp @@ -296,7 +296,7 @@ void print_routing_table(std::vector const& rt) std::printf("%3d [%3d, %d] %s%s\n" , bucket, i->num_nodes, i->num_replacements , progress_bar + (128 - i->num_nodes) - , short_progress_bar + (8 - (std::min)(8, i->num_replacements))); + , short_progress_bar + (8 - std::min(8, i->num_replacements))); } } diff --git a/src/block_cache.cpp b/src/block_cache.cpp index 67ac22fd6..aabab2387 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -1239,8 +1239,8 @@ void block_cache::move_to_ghost(cached_piece_entry* pe) ghost_list->push_back(pe); } -int block_cache::pad_job(disk_io_job const* j, int blocks_in_piece - , int read_ahead) const +int block_cache::pad_job(disk_io_job const* j, int const blocks_in_piece + , int const read_ahead) const { int block_offset = j->d.io.offset & (default_block_size - 1); int start = j->d.io.offset / default_block_size; @@ -1249,7 +1249,7 @@ int block_cache::pad_job(disk_io_job const* j, int blocks_in_piece // take the read-ahead into account // make sure to not overflow in this case if (read_ahead == INT_MAX) end = blocks_in_piece; - else end = (std::min)(blocks_in_piece, (std::max)(start + read_ahead, end)); + else end = std::min(blocks_in_piece, std::max(start + read_ahead, end)); return end - start; } @@ -1493,8 +1493,8 @@ void block_cache::set_settings(aux::session_settings const& sett) // assumption is that there are about 128 blocks per piece, // and there are two ghost lists, so divide by 2. - m_ghost_size = (std::max)(8, sett.get_int(settings_pack::cache_size) - / (std::max)(sett.get_int(settings_pack::read_cache_line_size), 4) / 2); + m_ghost_size = std::max(8, sett.get_int(settings_pack::cache_size) + / std::max(sett.get_int(settings_pack::read_cache_line_size), 4) / 2); m_max_volatile_blocks = sett.get_int(settings_pack::cache_size_volatile); disk_buffer_pool::set_settings(sett); diff --git a/src/choker.cpp b/src/choker.cpp index 59bae07b2..517ffcf60 100644 --- a/src/choker.cpp +++ b/src/choker.cpp @@ -242,8 +242,8 @@ namespace libtorrent { d1 *= lhs->get_priority(peer_connection::upload_channel); d2 *= rhs->get_priority(peer_connection::upload_channel); - d1 = d1 * 1000 / (std::max)(std::int64_t(1), u1); - d2 = d2 * 1000 / (std::max)(std::int64_t(1), u2); + d1 = d1 * 1000 / std::max(std::int64_t(1), u1); + d2 = d2 * 1000 / std::max(std::int64_t(1), u2); if (d1 > d2) return true; if (d1 < d2) return false; @@ -255,8 +255,8 @@ namespace libtorrent { } // anonymous namespace int unchoke_sort(std::vector& peers - , int max_upload_rate - , time_duration unchoke_interval + , int const max_upload_rate + , time_duration const unchoke_interval , aux::session_settings const& sett) { #if TORRENT_USE_ASSERTS @@ -269,7 +269,7 @@ namespace libtorrent { int upload_slots = sett.get_int(settings_pack::unchoke_slots_limit); if (upload_slots < 0) - upload_slots = (std::numeric_limits::max)(); + upload_slots = std::numeric_limits::max(); // ==== BitTyrant ==== // @@ -382,28 +382,28 @@ namespace libtorrent { int const pieces = sett.get_int(settings_pack::seeding_piece_quota); std::partial_sort(peers.begin(), peers.begin() - + (std::min)(upload_slots, int(peers.size())), peers.end() + + std::min(upload_slots, int(peers.size())), peers.end() , std::bind(&unchoke_compare_rr, _1, _2, pieces)); } else if (sett.get_int(settings_pack::seed_choking_algorithm) == settings_pack::fastest_upload) { std::partial_sort(peers.begin(), peers.begin() - + (std::min)(upload_slots, int(peers.size())), peers.end() + + std::min(upload_slots, int(peers.size())), peers.end() , std::bind(&unchoke_compare_fastest_upload, _1, _2)); } else if (sett.get_int(settings_pack::seed_choking_algorithm) == settings_pack::anti_leech) { std::partial_sort(peers.begin(), peers.begin() - + (std::min)(upload_slots, int(peers.size())), peers.end() + + std::min(upload_slots, int(peers.size())), peers.end() , std::bind(&unchoke_compare_anti_leech, _1, _2)); } else { int const pieces = sett.get_int(settings_pack::seeding_piece_quota); std::partial_sort(peers.begin(), peers.begin() - + (std::min)(upload_slots, int(peers.size())), peers.end() + + std::min(upload_slots, int(peers.size())), peers.end() , std::bind(&unchoke_compare_rr, _1, _2, pieces)); TORRENT_ASSERT_FAIL(); diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index 3f065223a..73c01c8dd 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -72,7 +72,7 @@ namespace libtorrent { , std::function const& trigger_trim) : m_in_use(0) , m_max_use(64) - , m_low_watermark((std::max)(m_max_use - 32, 0)) + , m_low_watermark(std::max(m_max_use - 32, 0)) , m_trigger_cache_trim(trigger_trim) , m_exceeded_max_size(false) , m_ios(ios) diff --git a/src/disk_io_thread_pool.cpp b/src/disk_io_thread_pool.cpp index 98b017e13..895030fa5 100644 --- a/src/disk_io_thread_pool.cpp +++ b/src/disk_io_thread_pool.cpp @@ -136,7 +136,7 @@ namespace libtorrent { return m_threads.front().get_id(); } - void disk_io_thread_pool::job_queued(int queue_size) + void disk_io_thread_pool::job_queued(int const queue_size) { // this check is not strictly necessary // but do it to avoid acquiring the mutex in the trivial case @@ -147,9 +147,9 @@ namespace libtorrent { // reduce the number of threads requested to stop if we're going to need // them for these new jobs int to_exit = m_threads_to_exit; - while (to_exit > (std::max)(0, m_num_idle_threads - queue_size) && + while (to_exit > std::max(0, m_num_idle_threads - queue_size) && !m_threads_to_exit.compare_exchange_weak(to_exit - , (std::max)(0, m_num_idle_threads - queue_size))); + , std::max(0, m_num_idle_threads - queue_size))); // now start threads until we either have enough to service // all queued jobs without blocking or hit the max @@ -192,7 +192,7 @@ namespace libtorrent { if (min_idle <= 0) return; // stop either the minimum number of idle threads or the number of threads // which must be stopped to get below the max, whichever is larger - int const to_stop = (std::max)(min_idle, int(m_threads.size()) - m_max_threads); + int const to_stop = std::max(min_idle, int(m_threads.size()) - m_max_threads); stop_threads(to_stop); } diff --git a/src/file.cpp b/src/file.cpp index 650daa7f2..cbda08dfb 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -166,12 +166,12 @@ namespace { // sure we wait for all of them, partially in sequence DWORD wait_for_multiple_objects(int num_handles, HANDLE* h) { - int batch_size = (std::min)(num_handles, MAXIMUM_WAIT_OBJECTS); + int batch_size = std::min(num_handles, MAXIMUM_WAIT_OBJECTS); while (WaitForMultipleObjects(batch_size, h, TRUE, INFINITE) != WAIT_FAILED) { h += batch_size; num_handles -= batch_size; - batch_size = (std::min)(num_handles, MAXIMUM_WAIT_OBJECTS); + batch_size = std::min(num_handles, MAXIMUM_WAIT_OBJECTS); if (batch_size <= 0) return WAIT_OBJECT_0; } return WAIT_FAILED; diff --git a/src/http_parser.cpp b/src/http_parser.cpp index 694decf72..55b9ca835 100644 --- a/src/http_parser.cpp +++ b/src/http_parser.cpp @@ -266,7 +266,7 @@ restart_response: // we're done once we reach the end of the headers // if (!m_method.empty()) m_finished = true; // the HTTP header should always be < 2 GB - TORRENT_ASSERT(m_recv_pos < (std::numeric_limits::max)()); + TORRENT_ASSERT(m_recv_pos < std::numeric_limits::max()); m_body_start_pos = int(m_recv_pos); break; } @@ -363,7 +363,7 @@ restart_response: std::int64_t payload = m_cur_chunk_end - m_recv_pos; if (payload > 0) { - TORRENT_ASSERT(payload < (std::numeric_limits::max)()); + TORRENT_ASSERT(payload < std::numeric_limits::max()); m_recv_pos += payload; std::get<0>(ret) += int(payload); incoming -= int(payload); @@ -429,7 +429,7 @@ restart_response: && m_content_length >= 0) { TORRENT_ASSERT(m_content_length - m_recv_pos + m_body_start_pos - < (std::numeric_limits::max)()); + < std::numeric_limits::max()); incoming = int(m_content_length - m_recv_pos + m_body_start_pos); } diff --git a/src/kademlia/node_id.cpp b/src/kademlia/node_id.cpp index 11c9a6465..8a89de616 100644 --- a/src/kademlia/node_id.cpp +++ b/src/kademlia/node_id.cpp @@ -64,7 +64,7 @@ int distance_exp(node_id const& n1, node_id const& n2) // TODO: it's a little bit weird to return 159 - leading zeroes. It should // probably be 160 - leading zeroes, but all other code in here is tuned to // this expectation now, and it doesn't really matter (other than complexity) - return (std::max)(159 - distance(n1, n2).count_leading_zeroes(), 0); + return std::max(159 - distance(n1, n2).count_leading_zeroes(), 0); } int min_distance_exp(node_id const& n1, std::vector const& ids) diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index f8415e707..d5f670c15 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -285,7 +285,7 @@ routing_table::table_t::iterator routing_table::find_bucket(node_id const& id) ++num_buckets; } - int bucket_index = (std::min)(159 - distance_exp(m_id, id), num_buckets - 1); + int bucket_index = std::min(159 - distance_exp(m_id, id), num_buckets - 1); TORRENT_ASSERT(bucket_index < int(m_buckets.size())); TORRENT_ASSERT(bucket_index >= 0); diff --git a/src/kademlia/rpc_manager.cpp b/src/kademlia/rpc_manager.cpp index 4bcc3d6c3..d76354668 100644 --- a/src/kademlia/rpc_manager.cpp +++ b/src/kademlia/rpc_manager.cpp @@ -447,7 +447,7 @@ time_duration rpc_manager::tick() std::for_each(timeouts.begin(), timeouts.end(), std::bind(&observer::timeout, _1)); std::for_each(short_timeouts.begin(), short_timeouts.end(), std::bind(&observer::short_timeout, _1)); - return (std::max)(ret, duration_cast(milliseconds(200))); + return std::max(ret, duration_cast(milliseconds(200))); } void rpc_manager::add_our_id(entry& e) diff --git a/src/kademlia/traversal_algorithm.cpp b/src/kademlia/traversal_algorithm.cpp index 19da9a414..d9f96180c 100644 --- a/src/kademlia/traversal_algorithm.cpp +++ b/src/kademlia/traversal_algorithm.cpp @@ -524,7 +524,7 @@ bool traversal_algorithm::add_requests() o->flags |= observer::flag_queried; if (invoke(*i)) { - TORRENT_ASSERT(m_invoke_count < (std::numeric_limits::max)()); + TORRENT_ASSERT(m_invoke_count < std::numeric_limits::max()); ++m_invoke_count; ++outstanding; } @@ -580,13 +580,13 @@ void traversal_algorithm::status(dht_lookup& l) l.target = m_target; int last_sent = INT_MAX; - time_point now = aux::time_now(); + time_point const now = aux::time_now(); for (auto const& r : m_results) { observer const& o = *r; if (o.flags & observer::flag_queried) { - last_sent = (std::min)(last_sent, int(total_seconds(now - o.sent()))); + last_sent = std::min(last_sent, int(total_seconds(now - o.sent()))); if (o.has_short_timeout()) ++l.first_timeout; continue; } diff --git a/src/path.cpp b/src/path.cpp index 9d17c1acc..44cda7dce 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -527,7 +527,7 @@ namespace libtorrent { { char const* slash = std::strrchr(f.c_str(), '/'); #ifdef TORRENT_WINDOWS - slash = (std::max)((char const*)std::strrchr(f.c_str(), '\\'), slash); + slash = std::max((char const*)std::strrchr(f.c_str(), '\\'), slash); #endif char const* ext = std::strrchr(f.c_str(), '.'); // if we don't have an extension, just return f diff --git a/src/peer_class.cpp b/src/peer_class.cpp index 22d4849bd..21994cc8a 100644 --- a/src/peer_class.cpp +++ b/src/peer_class.cpp @@ -69,8 +69,8 @@ namespace libtorrent { label = pci->label; set_upload_limit(pci->upload_limit); set_download_limit(pci->download_limit); - priority[peer_connection::upload_channel] = (std::max)(1, (std::min)(255, pci->upload_priority)); - priority[peer_connection::download_channel] = (std::max)(1, (std::min)(255, pci->download_priority)); + priority[peer_connection::upload_channel] = std::max(1, std::min(255, pci->upload_priority)); + priority[peer_connection::download_channel] = std::max(1, std::min(255, pci->download_priority)); } peer_class_t peer_class_pool::new_peer_class(std::string label) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 733ef6e1d..2fc1e2c58 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3654,7 +3654,7 @@ namespace libtorrent { int const block_offset = block.block_index * t->block_size(); int const block_size - = (std::min)(t->torrent_file().piece_size(block.piece_index)-block_offset, + = std::min(t->torrent_file().piece_size(block.piece_index) - block_offset, t->block_size()); TORRENT_ASSERT(block_size > 0); TORRENT_ASSERT(block_size <= t->block_size()); diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 45f510cb1..045d6d53a 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -221,7 +221,7 @@ namespace libtorrent { TORRENT_ASSERT(downloading_iter == m_downloads[download_state].end() || downloading_iter->index != piece); TORRENT_ASSERT(block_index >= 0); - TORRENT_ASSERT(block_index < (std::numeric_limits::max)()); + TORRENT_ASSERT(block_index < std::numeric_limits::max()); ret.info_idx = std::uint16_t(block_index); TORRENT_ASSERT(int(ret.info_idx) * m_blocks_per_piece + m_blocks_per_piece <= int(m_block_info.size())); @@ -1809,7 +1809,7 @@ namespace { , int const num_blocks) { if (src.empty()) return num_blocks; - int const to_copy = (std::min)(int(src.size()), num_blocks); + int const to_copy = std::min(int(src.size()), num_blocks); dst.insert(dst.end(), src.begin(), src.begin() + to_copy); src.erase(src.begin(), src.begin() + to_copy); @@ -2611,7 +2611,7 @@ get_out: #if TORRENT_USE_INVARIANT_CHECKS verify_pick(interesting_blocks, pieces); #endif - return (std::max)(num_blocks, 0); + return std::max(num_blocks, 0); } int piece_picker::add_blocks_downloading(downloading_piece const& dp diff --git a/src/platform_util.cpp b/src/platform_util.cpp index 940d94aea..d73ac85a6 100644 --- a/src/platform_util.cpp +++ b/src/platform_util.cpp @@ -72,7 +72,7 @@ namespace libtorrent { if (getrlimit(RLIMIT_NOFILE, &rl) == 0) { if (rl.rlim_cur == rlim_infinity) - return (std::numeric_limits::max)(); + return std::numeric_limits::max(); return rl.rlim_cur <= std::numeric_limits::max() ? int(rl.rlim_cur) : std::numeric_limits::max(); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 0f1411638..b19dbfe81 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -3221,7 +3221,7 @@ namespace aux { m_created += hours(4); - const int four_hours = 60 * 60 * 4; + constexpr int four_hours = 60 * 60 * 4; for (auto& i : m_torrents) { i.second->step_session_time(four_hours); @@ -3345,8 +3345,8 @@ namespace aux { // TODO: this should apply to all bandwidth channels if (m_settings.get_bool(settings_pack::rate_limit_ip_overhead)) { - int up_limit = upload_rate_limit(m_global_class); - int down_limit = download_rate_limit(m_global_class); + int const up_limit = upload_rate_limit(m_global_class); + int const down_limit = download_rate_limit(m_global_class); if (down_limit > 0 && m_stat.download_ip_overhead() >= down_limit @@ -3365,8 +3365,8 @@ namespace aux { } } - m_peak_up_rate = (std::max)(m_stat.upload_rate(), m_peak_up_rate); - m_peak_down_rate = (std::max)(m_stat.download_rate(), m_peak_down_rate); + m_peak_up_rate = std::max(m_stat.upload_rate(), m_peak_up_rate); + m_peak_down_rate = std::max(m_stat.download_rate(), m_peak_down_rate); m_stat.second_tick(tick_interval_ms); @@ -3382,7 +3382,7 @@ namespace aux { { aux::vector& want_scrape = m_torrent_lists[torrent_want_scrape]; m_auto_scrape_time_scaler = m_settings.get_int(settings_pack::auto_scrape_interval) - / (std::max)(1, int(want_scrape.size())); + / std::max(1, int(want_scrape.size())); if (m_auto_scrape_time_scaler < m_settings.get_int(settings_pack::auto_scrape_min_interval)) m_auto_scrape_time_scaler = m_settings.get_int(settings_pack::auto_scrape_min_interval); @@ -3477,7 +3477,7 @@ namespace aux { || t->max_connections() < 6) continue; - int const peers_to_disconnect = (std::min)((std::max)(t->num_peers() + int const peers_to_disconnect = std::min(std::max(t->num_peers() * m_settings.get_int(settings_pack::peer_turnover) / 100, 1) , t->num_connect_candidates()); t->disconnect_peers(peers_to_disconnect, errors::optimistic_disconnect); @@ -3754,7 +3754,7 @@ namespace aux { int session_impl::get_int_setting(int n) const { int const v = settings().get_int(n); - if (v < 0) return (std::numeric_limits::max)(); + if (v < 0) return std::numeric_limits::max(); return v; } @@ -3795,17 +3795,17 @@ namespace aux { // make sure the remaining torrents are paused, but their order is not // relevant std::partial_sort(checking.begin(), checking.begin() + - (std::min)(checking_limit, int(checking.size())), checking.end() + std::min(checking_limit, int(checking.size())), checking.end() , [](torrent const* lhs, torrent const* rhs) { return lhs->sequence_number() < rhs->sequence_number(); }); std::partial_sort(downloaders.begin(), downloaders.begin() + - (std::min)(hard_limit, int(downloaders.size())), downloaders.end() + std::min(hard_limit, int(downloaders.size())), downloaders.end() , [](torrent const* lhs, torrent const* rhs) { return lhs->sequence_number() < rhs->sequence_number(); }); std::partial_sort(seeds.begin(), seeds.begin() + - (std::min)(hard_limit, int(seeds.size())), seeds.end() + std::min(hard_limit, int(seeds.size())), seeds.end() , [this](torrent const* lhs, torrent const* rhs) { return lhs->seed_rank(m_settings) > rhs->seed_rank(m_settings); }); } @@ -3867,7 +3867,7 @@ namespace aux { for (auto& e : plugins) { uint64_t const priority = e->get_unchoke_priority(peer_connection_handle(*peer.peer)); - peer.ext_priority = (std::min)(priority, peer.ext_priority); + peer.ext_priority = std::min(priority, peer.ext_priority); } } return peer.ext_priority; @@ -6911,7 +6911,7 @@ namespace aux { if (m_settings.get_int(settings_pack::unchoke_slots_limit) < 0 && m_settings.get_int(settings_pack::choking_algorithm) == settings_pack::fixed_slots_choker) - TORRENT_ASSERT(m_stats_counters[counters::num_unchoke_slots] == (std::numeric_limits::max)()); + TORRENT_ASSERT(m_stats_counters[counters::num_unchoke_slots] == std::numeric_limits::max()); for (torrent_list_index_t l{}; l != m_torrent_lists.end_index(); ++l) { diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index 8cdc38dea..71ec0d237 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -87,7 +87,7 @@ namespace { if (i == m_block_hashes.end() || i->first.piece_index != p) return; int size = m_torrent.torrent_file().piece_size(p); - peer_request r = {p, 0, (std::min)(16 * 1024, size)}; + peer_request r = {p, 0, std::min(16 * 1024, size)}; piece_block pb(p, 0); while (size > 0) { @@ -108,7 +108,7 @@ namespace { r.start += 16 * 1024; size -= 16 * 1024; - r.length = (std::min)(16 * 1024, size); + r.length = std::min(16 * 1024, size); ++pb.block_index; } @@ -125,7 +125,7 @@ namespace { } } - void on_piece_failed(piece_index_t p) override + void on_piece_failed(piece_index_t const p) override { // The piece failed the hash check. Record // the CRC and origin peer of every block @@ -138,7 +138,7 @@ namespace { m_torrent.picker().get_downloaders(downloaders, p); int size = m_torrent.torrent_file().piece_size(p); - peer_request r = {p, 0, (std::min)(16*1024, size)}; + peer_request r = {p, 0, std::min(16*1024, size)}; piece_block pb(p, 0); for (auto const& i : downloaders) { @@ -156,7 +156,7 @@ namespace { r.start += 16*1024; size -= 16*1024; - r.length = (std::min)(16*1024, size); + r.length = std::min(16*1024, size); ++pb.block_index; } TORRENT_ASSERT(size <= 0); diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index 1dfaae9ed..020786dc1 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -259,7 +259,7 @@ namespace libtorrent {namespace { int offset = piece * 16 * 1024; metadata = m_tp.metadata().data() + offset; - metadata_piece_size = (std::min)( + metadata_piece_size = std::min( m_tp.get_metadata_size() - offset, 16 * 1024); TORRENT_ASSERT(metadata_piece_size > 0); TORRENT_ASSERT(offset >= 0); @@ -394,7 +394,7 @@ namespace libtorrent {namespace { break; case metadata_dont_have: { - m_request_limit = (std::max)(aux::time_now() + minutes(1), m_request_limit); + m_request_limit = std::max(aux::time_now() + minutes(1), m_request_limit); auto const i = std::find(m_sent_requests.begin() , m_sent_requests.end(), piece); // unwanted piece? diff --git a/test/bittorrent_peer.cpp b/test/bittorrent_peer.cpp index a8d6cac02..d6581fa93 100644 --- a/test/bittorrent_peer.cpp +++ b/test/bittorrent_peer.cpp @@ -471,7 +471,7 @@ void peer_conn::on_message(error_code const& ec, size_t bytes_transferred) } else { - block = (std::min)(start / 0x4000, block); + block = std::min(start / 0x4000, block); if (block == 0) { pieces.push_back(current_piece); diff --git a/test/test_bandwidth_limiter.cpp b/test/test_bandwidth_limiter.cpp index 4d99f3a3d..711d27e22 100644 --- a/test/test_bandwidth_limiter.cpp +++ b/test/test_bandwidth_limiter.cpp @@ -196,7 +196,7 @@ void test_equal_connections(int num, int limit) run_test(v, manager); float sum = 0.f; - float err = (std::max)(limit / num * 0.3f, 1000.f); + float const err = std::max(limit / num * 0.3f, 1000.f); for (connections_t::iterator i = v.begin() , end(v.end()); i != end; ++i) { @@ -307,7 +307,7 @@ void test_torrents(int num, int limit1, int limit2, int global_limit) if (global_limit > 0 && global_limit < limit1 + limit2) { - limit1 = (std::min)(limit1, global_limit / 2); + limit1 = std::min(limit1, global_limit / 2); limit2 = global_limit - limit1; } float sum = 0.f; diff --git a/test/test_dht.cpp b/test/test_dht.cpp index 18503e1e7..62181f99b 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -1732,7 +1732,7 @@ void test_routing_table(address(&rand_addr)()) std::generate(tmp.begin(), tmp.end(), random_byte); table.find_node(tmp, temp, 0, bucket_size * 2); std::printf("returned: %d\n", int(temp.size())); - TEST_EQUAL(int(temp.size()), (std::min)(bucket_size * 2, int(nodes.size()))); + TEST_EQUAL(int(temp.size()), std::min(bucket_size * 2, int(nodes.size()))); std::sort(nodes.begin(), nodes.end(), std::bind(&compare_ref , std::bind(&node_entry::id, _1) diff --git a/test/test_resume.cpp b/test/test_resume.cpp index 2cc0837aa..2f226dfbd 100644 --- a/test/test_resume.cpp +++ b/test/test_resume.cpp @@ -840,7 +840,7 @@ void test_zero_file_prio(bool test_deprecated = false) rd["file-format"] = "libtorrent resume file"; rd["file-version"] = 1; rd["info-hash"] = ti->info_hash().to_string(); - rd["blocks per piece"] = (std::max)(1, ti->piece_length() / 0x4000); + rd["blocks per piece"] = std::max(1, ti->piece_length() / 0x4000); entry::list_type& file_prio = rd["file_priority"].list(); for (int i = 0; i < 100; ++i) @@ -965,7 +965,7 @@ void test_seed_mode(test_mode_t const flags) rd["file-format"] = "libtorrent resume file"; rd["file-version"] = 1; rd["info-hash"] = ti->info_hash().to_string(); - rd["blocks per piece"] = (std::max)(1, ti->piece_length() / 0x4000); + rd["blocks per piece"] = std::max(1, ti->piece_length() / 0x4000); if (flags & test_mode::file_prio) { diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index 73b46c54d..35c0aa55b 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -297,7 +297,7 @@ TORRENT_TEST(extract_peer_hostname) peer_entry result = extract_peer("d2:ip11:example.com4:porti1ee" , error_code(), true); TEST_EQUAL(result.hostname, "example.com"); - TEST_EQUAL(result.pid, (peer_id::min)()); + TEST_EQUAL(result.pid, peer_id::min()); TEST_EQUAL(result.port, 1); }