fix uses of defines for whether or not asserts are active (#832)
This commit is contained in:
parent
d3cd568447
commit
ead11737b4
|
@ -34,10 +34,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/config.hpp"
|
||||
|
||||
#if (defined TORRENT_DEBUG && TORRENT_USE_ASSERTS) \
|
||||
#if TORRENT_USE_ASSERTS \
|
||||
|| defined TORRENT_ASIO_DEBUGGING \
|
||||
|| defined TORRENT_PROFILE_CALLS \
|
||||
|| defined TORRENT_RELEASE_ASSERTS \
|
||||
|| defined TORRENT_DEBUG_BUFFERS
|
||||
|
||||
#include <string>
|
||||
|
|
|
@ -440,7 +440,7 @@ private:
|
|||
char m_reserved_bits[8];
|
||||
#endif
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
bool m_in_constructor;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/pool/pool.hpp>
|
||||
#endif
|
||||
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG
|
||||
#include <set>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ namespace libtorrent
|
|||
// flags controlling this job
|
||||
boost::uint8_t flags;
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
bool in_use:1;
|
||||
|
||||
// set to true when the job is added to the completion queue.
|
||||
|
|
|
@ -73,7 +73,7 @@ struct TORRENT_EXTRA_EXPORT observer : boost::noncopyable
|
|||
, flags(0)
|
||||
{
|
||||
TORRENT_ASSERT(a);
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
m_in_constructor = true;
|
||||
m_was_sent = false;
|
||||
m_was_abandoned = false;
|
||||
|
@ -164,7 +164,7 @@ private:
|
|||
public:
|
||||
unsigned char flags;
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
bool m_in_constructor:1;
|
||||
bool m_was_sent:1;
|
||||
bool m_was_abandoned:1;
|
||||
|
|
|
@ -39,10 +39,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <atomic>
|
||||
#endif
|
||||
|
||||
#if (defined TORRENT_DEBUG && TORRENT_USE_ASSERTS) \
|
||||
#if TORRENT_USE_ASSERTS \
|
||||
|| defined TORRENT_ASIO_DEBUGGING \
|
||||
|| defined TORRENT_PROFILE_CALLS \
|
||||
|| defined TORRENT_RELEASE_ASSERTS \
|
||||
|| defined TORRENT_DEBUG_BUFFERS
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace libtorrent
|
|||
, m_dont_have_id(0)
|
||||
, m_share_mode_id(0)
|
||||
#endif
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
, m_in_constructor(true)
|
||||
#endif
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace libtorrent
|
|||
, action(read)
|
||||
, ret(0)
|
||||
, flags(0)
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
, in_use(false)
|
||||
, job_posted(false)
|
||||
, callback_called(false)
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace libtorrent
|
|||
|
||||
new (ptr) disk_io_job;
|
||||
ptr->action = static_cast<disk_io_job::action_t>(type);
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
ptr->in_use = true;
|
||||
#endif
|
||||
return ptr;
|
||||
|
@ -72,7 +72,7 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(j);
|
||||
if (j == 0) return;
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
TORRENT_ASSERT(j->in_use);
|
||||
j->in_use = false;
|
||||
#endif
|
||||
|
|
|
@ -251,7 +251,7 @@ namespace libtorrent
|
|||
boost::tie(payload, protocol) = m_parser.incoming(recv_buffer, parse_error);
|
||||
received_bytes(0, protocol);
|
||||
bytes_transferred -= protocol;
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
if (payload > front_request.length) payload = front_request.length;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ observer_ptr find_data::new_observer(void* ptr
|
|||
, udp::endpoint const& ep, node_id const& id)
|
||||
{
|
||||
observer_ptr o(new (ptr) find_data_observer(this, ep, id));
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
return o;
|
||||
|
|
|
@ -383,7 +383,7 @@ namespace
|
|||
void* ptr = node.m_rpc.allocate_observer();
|
||||
if (ptr == 0) return;
|
||||
observer_ptr o(new (ptr) announce_observer(algo, i->first.ep(), i->first.id));
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
entry e;
|
||||
|
@ -470,7 +470,7 @@ void node::direct_request(udp::endpoint ep, entry& e
|
|||
void* ptr = m_rpc.allocate_observer();
|
||||
if (ptr == 0) return;
|
||||
observer_ptr o(new (ptr) direct_observer(algo, ep, (node_id::min)()));
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
m_rpc.invoke(e, ep, o);
|
||||
|
@ -690,7 +690,7 @@ void node::send_single_refresh(udp::endpoint const& ep, int bucket
|
|||
boost::intrusive_ptr<traversal_algorithm> algo(
|
||||
new traversal_algorithm(*this, (node_id::min)()));
|
||||
observer_ptr o(new (ptr) ping_observer(algo, ep, id));
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
entry e;
|
||||
|
|
|
@ -66,7 +66,7 @@ void put_data::set_targets(std::vector<std::pair<node_entry, std::string> > cons
|
|||
observer_ptr o(new (ptr) put_data_observer(this, i->first.ep()
|
||||
, i->first.id, i->second));
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
m_results.push_back(o);
|
||||
|
|
|
@ -45,7 +45,7 @@ observer_ptr bootstrap::new_observer(void* ptr
|
|||
, udp::endpoint const& ep, node_id const& id)
|
||||
{
|
||||
observer_ptr o(new (ptr) get_peers_observer(this, ep, id));
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
return o;
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(to_process == 0);
|
||||
}
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
to_process = 0;
|
||||
for (std::vector<boost::asio::mutable_buffer>::iterator i = iovec.begin();
|
||||
i != iovec.end(); ++i)
|
||||
|
@ -154,7 +154,7 @@ namespace libtorrent
|
|||
m_send_barriers.pop_front();
|
||||
}
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
if (next_barrier != INT_MAX)
|
||||
{
|
||||
int overhead = 0;
|
||||
|
|
|
@ -58,7 +58,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/bt_peer_connection.hpp"
|
||||
#endif
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
#include "libtorrent/socket_io.hpp" // for print_endpoint
|
||||
#endif
|
||||
|
||||
|
|
|
@ -637,7 +637,7 @@ namespace libtorrent
|
|||
bencode(std::back_inserter(buf), ses_state);
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
|
||||
#if TORRENT_USE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
|
||||
int ret =
|
||||
#endif
|
||||
bdecode(&buf[0], &buf[0] + buf.size(), e, ec);
|
||||
|
@ -664,7 +664,7 @@ namespace libtorrent
|
|||
std::pair<char const*, int> buf = ses_state.data_section();
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
|
||||
#if TORRENT_USE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
|
||||
int ret =
|
||||
#endif
|
||||
bdecode(buf.first, buf.first + buf.second, e, ec);
|
||||
|
|
|
@ -851,7 +851,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_abort);
|
||||
TORRENT_ASSERT(prev == NULL && next == NULL);
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
for (int i = 0; i < aux::session_interface::num_torrent_lists; ++i)
|
||||
{
|
||||
if (!m_links[i].in_list()) continue;
|
||||
|
@ -8115,7 +8115,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_info_hash == m_torrent_file->info_hash());
|
||||
}
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
for (int i = 0; i < aux::session_interface::num_torrent_lists; ++i)
|
||||
{
|
||||
if (!m_links[i].in_list()) continue;
|
||||
|
@ -11107,7 +11107,7 @@ namespace libtorrent
|
|||
|
||||
st->state = static_cast<torrent_status::state_t>(m_state);
|
||||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
if (st->state == torrent_status::finished
|
||||
|| st->state == torrent_status::seeding)
|
||||
{
|
||||
|
|
|
@ -563,7 +563,7 @@ namespace libtorrent
|
|||
// info_hash
|
||||
std::copy(tracker_req().info_hash.begin(), tracker_req().info_hash.end()
|
||||
, view.data());
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
TORRENT_ASSERT(view.size() == 20);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -102,10 +102,9 @@ LONG WINAPI seh_exception_handler(LPEXCEPTION_POINTERS p)
|
|||
{
|
||||
char stack_text[10000];
|
||||
|
||||
#if (defined TORRENT_DEBUG && TORRENT_USE_ASSERTS) \
|
||||
#if TORRENT_USE_ASSERTS \
|
||||
|| defined TORRENT_ASIO_DEBUGGING \
|
||||
|| defined TORRENT_PROFILE_CALLS \
|
||||
|| defined TORRENT_RELEASE_ASSERTS \
|
||||
|| defined TORRENT_DEBUG_BUFFERS
|
||||
print_backtrace(stack_text, sizeof(stack_text), 30
|
||||
, p->ContextRecord);
|
||||
|
@ -159,10 +158,9 @@ void sig_handler(int sig)
|
|||
{
|
||||
char stack_text[10000];
|
||||
|
||||
#if (defined TORRENT_DEBUG && TORRENT_USE_ASSERTS) \
|
||||
#if TORRENT_USE_ASSERTS \
|
||||
|| defined TORRENT_ASIO_DEBUGGING \
|
||||
|| defined TORRENT_PROFILE_CALLS \
|
||||
|| defined TORRENT_RELEASE_ASSERTS \
|
||||
|| defined TORRENT_DEBUG_BUFFERS
|
||||
print_backtrace(stack_text, sizeof(stack_text), 30);
|
||||
#elif defined __FUNCTION__
|
||||
|
|
|
@ -79,7 +79,7 @@ struct test_storage_impl : storage_interface
|
|||
|
||||
static void nop() {}
|
||||
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
#define INITIALIZE_JOB(j) j.in_use = true;
|
||||
#else
|
||||
#define INITIALIZE_JOB(j)
|
||||
|
|
|
@ -2652,7 +2652,7 @@ TORRENT_TEST(rpc_invalid_error_msg)
|
|||
node, node_id()));
|
||||
|
||||
observer_ptr o(new (rpc.allocate_observer()) null_observer(algo, source, node_id()));
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
rpc.invoke(req, source, o);
|
||||
|
|
Loading…
Reference in New Issue