fix osx build (#804)

fix osx build with asserts enabled
This commit is contained in:
Arvid Norberg 2016-06-11 00:48:13 -04:00 committed by GitHub
parent 8d51e04344
commit 5ecd00c5c5
9 changed files with 27 additions and 19 deletions

View File

@ -64,10 +64,6 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0);
TORRENT_EXPORT void assert_print(char const* fmt, ...) TORRENT_FORMAT(1,2);
// internal
#if (TORRENT_USE_ASSERTS || defined TORRENT_ASIO_DEBUGGING) \
&& !defined TORRENT_PRODUCTION_ASSERTS
TORRENT_NO_RETURN
#endif
TORRENT_EXPORT void assert_fail(const char* expr, int line
, char const* file, char const* function, char const* val, int kind = 0);

View File

@ -245,9 +245,13 @@ TORRENT_EXPORT void assert_print(char const* fmt, ...)
#endif
}
#ifndef TORRENT_PRODUCTION_ASSERTS
TORRENT_NO_RETURN
// we deliberately don't want asserts to be marked as no-return, since that
// would trigger warnings in debug builds of any code coming after the assert
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
#endif
TORRENT_EXPORT void assert_fail(char const* expr, int line
, char const* file, char const* function, char const* value, int kind)
{
@ -300,6 +304,10 @@ TORRENT_EXPORT void assert_fail(char const* expr, int line
#endif
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#elif !TORRENT_USE_ASSERTS
// these are just here to make it possible for a client that built with debug

View File

@ -1341,7 +1341,7 @@ void block_cache::insert_blocks(cached_piece_entry* pe, int block, file::iovec_t
TORRENT_ASSERT(iov[i].iov_base);
#ifdef TORRENT_DEBUG_BUFFERS
TORRENT_PIECE_ASSERT(is_disk_buffer((char*)iov[i].iov_base), pe);
TORRENT_PIECE_ASSERT(is_disk_buffer(static_cast<char*>(iov[i].iov_base)), pe);
#endif
if (pe->blocks[block].buf && (flags & blocks_inc_refcount))

View File

@ -359,7 +359,7 @@ namespace libtorrent
, end(peers.end()); i != end; ++i)
{
peer_connection const& p = **i;
int rate = int(p.uploaded_in_last_round()
int const rate = int(p.uploaded_in_last_round()
* 1000 / total_milliseconds(unchoke_interval));
if (rate < rate_threshold) break;
@ -383,7 +383,7 @@ namespace libtorrent
if (sett.get_int(settings_pack::seed_choking_algorithm)
== settings_pack::round_robin)
{
int pieces = sett.get_int(settings_pack::seeding_piece_quota);
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()
@ -405,12 +405,12 @@ namespace libtorrent
}
else
{
TORRENT_ASSERT(false);
int pieces = sett.get_int(settings_pack::seeding_piece_quota);
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()
, boost::bind(&unchoke_compare_rr, _1, _2, pieces));
TORRENT_ASSERT(false);
}
return upload_slots;

View File

@ -282,7 +282,7 @@ void traversal_algorithm::traverse(node_id const& id, udp::endpoint addr)
void traversal_algorithm::finished(observer_ptr o)
{
#ifdef TORRENT_DEBUG
#if TORRENT_USE_ASSERTS
std::vector<observer_ptr>::iterator i = std::find(
m_results.begin(), m_results.end(), o);

View File

@ -296,7 +296,8 @@ namespace libtorrent
TORRENT_UNUSED(ec);
// not implemented
TORRENT_ASSERT(false);
ec.assign(boost::system::errc::operation_not_supported
, boost::system::generic_category());
}
void part_file::export_file(file& f, boost::int64_t offset, boost::int64_t size, error_code& ec)

View File

@ -3043,10 +3043,11 @@ namespace libtorrent
TORRENT_ASSERT(p.start == j->d.io.offset);
TORRENT_ASSERT(picker.num_peers(block_finished) == 0);
if (j->ret == -1 && j->error.ec == boost::system::errc::operation_canceled)
if (j->ret == -1
&& j->error.ec == boost::system::errc::operation_canceled)
{
TORRENT_ASSERT(false); // how do we get here?
picker.mark_as_canceled(block_finished, peer_info_struct());
TORRENT_ASSERT(false); // how do we get here?
return;
}
// fprintf(stderr, "peer_connection mark_as_finished peer: %p piece: %d block: %d\n"

View File

@ -85,7 +85,7 @@ namespace
tcp::endpoint const& m_ep;
};
#if TORRENT_USE_ASSERTS
#ifndef TORRENT_DISABLE_INVARIANT_CHECKS
struct match_peer_connection
{
match_peer_connection(peer_connection_interface const& c) : m_conn(c) {}
@ -98,7 +98,9 @@ namespace
peer_connection_interface const& m_conn;
};
#endif
#if TORRENT_USE_ASSERTS
struct match_peer_connection_or_endpoint
{
match_peer_connection_or_endpoint(peer_connection_interface const& c) : m_conn(c) {}

View File

@ -182,7 +182,7 @@ boost::shared_ptr<piece_picker> setup_picker(
TEST_CHECK(avail == availability_vec[i]);
}
#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
#if TORRENT_USE_INVARIANT_CHECKS
p->check_invariant();
#endif
return p;
@ -191,7 +191,7 @@ boost::shared_ptr<piece_picker> setup_picker(
bool verify_pick(boost::shared_ptr<piece_picker> p
, std::vector<piece_block> const& picked, bool allow_multi_blocks = false)
{
#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
#if TORRENT_USE_INVARIANT_CHECKS
p->check_invariant();
#endif
if (!allow_multi_blocks)