From a675682b6c54ba9f0b756562834270fdf61d1336 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 27 Jun 2016 22:28:51 -0400 Subject: [PATCH] some cleanup of TORRENT_DEBUG defines (#863) some cleanup of TORRENT_DEBUG defines --- Jamfile | 14 ++++------ .../libtorrent/aux_/allocating_handler.hpp | 6 ++-- include/libtorrent/bencode.hpp | 28 +++++++++---------- include/libtorrent/config.hpp | 2 +- include/libtorrent/peer_connection.hpp | 2 +- include/libtorrent/storage.hpp | 2 +- src/block_cache.cpp | 16 ++++------- src/disk_io_thread.cpp | 24 ++++++++-------- src/peer_connection.cpp | 6 ++-- src/storage.cpp | 2 +- 10 files changed, 47 insertions(+), 55 deletions(-) diff --git a/Jamfile b/Jamfile index a2d434e13..3d524c613 100644 --- a/Jamfile +++ b/Jamfile @@ -113,7 +113,8 @@ rule linking ( properties * ) } if windows in $(properties) - && ( on in $(properties) + && ( TORRENT_DEBUG + || on in $(properties) || production in $(properties) || debug in $(properties) || debug in $(properties) @@ -338,7 +339,7 @@ rule building ( properties * ) result += -ftrapv ; } - if ( debug in $(properties) + if ( production in $(properties) || on in $(properties) ) { result += src/assert.cpp ; @@ -422,10 +423,10 @@ feature memory-optimization : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_OPTIMIZE_MEMORY_USAGE ; feature asserts : auto on off production system : composite propagated ; -feature.compose on : TORRENT_RELEASE_ASSERTS=1 ; -feature.compose production : TORRENT_PRODUCTION_ASSERTS=1 TORRENT_RELEASE_ASSERTS=1 ; +feature.compose on : TORRENT_USE_ASSERTS=1 ; +feature.compose production : TORRENT_USE_ASSERTS=1 TORRENT_PRODUCTION_ASSERTS=1 ; +feature.compose system : TORRENT_USE_ASSERTS=1 TORRENT_USE_SYSTEM_ASSERTS=1 ; feature.compose off : TORRENT_USE_ASSERTS=0 ; -feature.compose system : TORRENT_USE_SYSTEM_ASSERTS=1 ; feature windows-version : vista win7 xp : composite propagated link-incompatible ; feature.compose vista : _WIN32_WINNT=0x0600 ; @@ -528,19 +529,16 @@ variant test_debug : debug debug full shared on on multi on - TORRENT_DEBUG ; variant test_barebones : debug : off off off off shared off off on on multi on - TORRENT_DEBUG ; variant test_arm : debug : off off off off off off on on - TORRENT_DEBUG ; # required for openssl on windows diff --git a/include/libtorrent/aux_/allocating_handler.hpp b/include/libtorrent/aux_/allocating_handler.hpp index 8c4f0a7c2..1503270ed 100644 --- a/include/libtorrent/aux_/allocating_handler.hpp +++ b/include/libtorrent/aux_/allocating_handler.hpp @@ -52,7 +52,7 @@ namespace libtorrent { namespace aux template struct handler_storage { -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS handler_storage() : used(false) {} @@ -96,7 +96,7 @@ namespace libtorrent { namespace aux { TORRENT_UNUSED(size); TORRENT_ASSERT(size <= Size); -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS TORRENT_ASSERT(!ctx->storage.used); ctx->storage.used = true; #endif @@ -112,7 +112,7 @@ namespace libtorrent { namespace aux TORRENT_ASSERT(size <= Size); TORRENT_ASSERT(ptr == &ctx->storage.bytes); -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ctx->storage.used = false; #endif } diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index 7c40387f3..abd52e50d 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -222,7 +222,7 @@ namespace libtorrent if (in == end) { err = true; -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif return; @@ -242,7 +242,7 @@ namespace libtorrent ret = entry(entry::int_t); char* end_pointer; ret.integer() = strtoll(val.c_str(), &end_pointer, 10); -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif if (end_pointer == val.c_str()) @@ -265,7 +265,7 @@ namespace libtorrent bdecode_recursive(in, end, e, err, depth + 1); if (err) { -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif return; @@ -273,13 +273,13 @@ namespace libtorrent if (in == end) { err = true; -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif return; } } -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif TORRENT_ASSERT(*in == 'e'); @@ -298,7 +298,7 @@ namespace libtorrent bdecode_recursive(in, end, key, err, depth + 1); if (err || key.type() != entry::string_t) { -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif return; @@ -307,7 +307,7 @@ namespace libtorrent bdecode_recursive(in, end, e, err, depth + 1); if (err) { -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif return; @@ -315,13 +315,13 @@ namespace libtorrent if (in == end) { err = true; -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif return; } } -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif TORRENT_ASSERT(*in == 'e'); @@ -336,7 +336,7 @@ namespace libtorrent std::string len_s = read_until(in, end, ':', err); if (err) { -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif return; @@ -348,7 +348,7 @@ namespace libtorrent read_string(in, end, len, ret.string(), err); if (err) { -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif return; @@ -357,12 +357,12 @@ namespace libtorrent else { err = true; -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif return; } -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS ret.m_type_queried = false; #endif } @@ -421,9 +421,7 @@ namespace libtorrent entry e; bool err = false; detail::bdecode_recursive(start, end, e, err, 0); -#ifdef TORRENT_DEBUG TORRENT_ASSERT(e.m_type_queried == false); -#endif if (err) return entry(); return e; } diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 421884645..bc03d6731 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -473,7 +473,7 @@ POSSIBILITY OF SUCH DAMAGE. // builds have asserts if they are explicitly enabled by // the release_asserts macro. #ifndef TORRENT_USE_ASSERTS -#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG #define TORRENT_USE_ASSERTS 1 #else #define TORRENT_USE_ASSERTS 0 diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 2f87d7fe0..b3171d54e 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -678,7 +678,7 @@ namespace libtorrent void max_out_request_queue(int s); int max_out_request_queue() const; -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS bool piece_failed; #endif diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 1625a87a7..2f25d8f7e 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -583,7 +583,7 @@ namespace libtorrent storage_interface* get_storage_impl() { return m_storage.get(); } -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS void assert_torrent_refcount() const; #endif private: diff --git a/src/block_cache.cpp b/src/block_cache.cpp index 2c76a6e26..6c9a3fb57 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -45,10 +45,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/performance_counters.hpp" #include "libtorrent/aux_/time.hpp" -#ifdef TORRENT_DEBUG -#include "libtorrent/random.hpp" -#endif - /* The disk cache mimics ARC (adaptive replacement cache). @@ -562,7 +558,7 @@ void block_cache::try_evict_one_volatile() if (pe->ok_to_evict()) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS for (int j = 0; j < pe->blocks_in_piece; ++j) TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); #endif @@ -605,7 +601,7 @@ void block_cache::try_evict_one_volatile() if (pe->ok_to_evict()) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS for (int j = 0; j < pe->blocks_in_piece; ++j) TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); #endif @@ -1079,7 +1075,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore) if (pe->ok_to_evict()) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS for (int j = 0; j < pe->blocks_in_piece; ++j) TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); #endif @@ -1119,7 +1115,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore) if (pe->ok_to_evict()) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS for (int j = 0; j < pe->blocks_in_piece; ++j) TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); #endif @@ -1152,7 +1148,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore) if (pe->ok_to_evict()) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS for (int j = 0; j < pe->blocks_in_piece; ++j) TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); #endif @@ -1198,7 +1194,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore) if (pe->ok_to_evict()) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS for (int j = 0; j < pe->blocks_in_piece; ++j) TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); #endif diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 266291792..a5fdf1f24 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1484,7 +1484,7 @@ namespace libtorrent { INVARIANT_CHECK; -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1604,7 +1604,7 @@ namespace libtorrent { INVARIANT_CHECK; -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1711,7 +1711,7 @@ namespace libtorrent void disk_io_thread::async_hash(piece_manager* storage, int piece, int flags , boost::function handler, void* requester) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1756,7 +1756,7 @@ namespace libtorrent void disk_io_thread::async_move_storage(piece_manager* storage, std::string const& p, int flags , boost::function handler) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1785,7 +1785,7 @@ namespace libtorrent , int const options , boost::function handler) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1838,7 +1838,7 @@ namespace libtorrent , std::vector& links , boost::function handler) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1860,7 +1860,7 @@ namespace libtorrent void disk_io_thread::async_rename_file(piece_manager* storage, int index, std::string const& name , boost::function handler) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1913,7 +1913,7 @@ namespace libtorrent void disk_io_thread::async_cache_piece(piece_manager* storage, int piece , boost::function handler) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1930,7 +1930,7 @@ namespace libtorrent void disk_io_thread::async_finalize_file(piece_manager* storage, int file , boost::function handler) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1948,7 +1948,7 @@ namespace libtorrent void disk_io_thread::async_flush_piece(piece_manager* storage, int piece , boost::function handler) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -1974,7 +1974,7 @@ namespace libtorrent , std::vector const& prios , boost::function handler) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); @@ -2030,7 +2030,7 @@ namespace libtorrent void disk_io_thread::async_clear_piece(piece_manager* storage, int index , boost::function handler) { -#ifdef TORRENT_DEBUG +#ifndef TORRENT_DISABLE_INVARIANT_CHECKS // the caller must increment the torrent refcount before // issuing an async disk request storage->assert_torrent_refcount(); diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index d99a62201..78dcb9698 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS #include #endif @@ -226,7 +226,7 @@ namespace libtorrent , static_cast(m_peer_info) , print_endpoint(local_ep).c_str()); #endif -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS piece_failed = false; #endif std::fill(m_peer_id.begin(), m_peer_id.end(), 0); @@ -5444,7 +5444,7 @@ namespace libtorrent , channels + c, max_channels - c); } -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS // make sure we don't have duplicates std::set unique_classes; for (int i = 0; i < c; ++i) diff --git a/src/storage.cpp b/src/storage.cpp index cb3d8c8ff..9412760aa 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -1488,7 +1488,7 @@ namespace libtorrent piece_manager::~piece_manager() {} -#ifdef TORRENT_DEBUG +#if TORRENT_USE_ASSERTS void piece_manager::assert_torrent_refcount() const { if (!m_torrent) return;