Msvc warnings (#685)

fix msvc warnings and build examples with warnings-as-errors
This commit is contained in:
Arvid Norberg 2016-05-02 12:36:21 -04:00
parent 0d2c04cb2e
commit c91a700c07
43 changed files with 156 additions and 140 deletions

View File

@ -104,7 +104,7 @@ rule linking ( properties * )
# the system library. Only add this include path # the system library. Only add this include path
# if we're not using openssl (which we're most # if we're not using openssl (which we're most
# likely not if we're using libgcrypt) # likely not if we're using libgcrypt)
result += <library>gcrypt <include>/opt/local/include ; result += <library>gcrypt ;
} }
# socket functions on windows require winsock libraries # socket functions on windows require winsock libraries
@ -520,10 +520,10 @@ lib gcc : : <name>gcc <link>static ;
lib libiconv : : <name>iconv <link>shared <search>/usr/local/lib ; lib libiconv : : <name>iconv <link>shared <search>/usr/local/lib ;
# openssl on linux/bsd/macos etc. # openssl on linux/bsd/macos etc.
lib gcrypt : : <name>gcrypt <link>shared <search>/opt/local/lib ; lib gcrypt : : <name>gcrypt <link>shared <search>/opt/local/lib <search>/usr/local/lib : : <include>/opt/local/include <include>/usr/local/include ;
lib z : : <link>shared <name>z <search>/usr/lib ; lib z : : <link>shared <name>z <search>/usr/lib ;
lib crypto : : <name>crypto <link>shared <search>/usr/lib <use>z ; lib crypto : : <name>crypto <link>shared <search>/usr/lib <use>z : : <include>/usr/include <include>/opt/local/include ;
lib ssl : : <name>ssl <link>shared <use>crypto <search>/opt/local/lib ; lib ssl : : <name>ssl <link>shared <use>crypto <search>/opt/local/lib <search>/usr/local/lib : : <include>/opt/local/include <include>/usr/local/include ;
lib dl : : <link>shared <name>dl ; lib dl : : <link>shared <name>dl ;
# time functions used on linux require librt # time functions used on linux require librt

View File

@ -95,7 +95,7 @@ cache:
build_script: build_script:
# examples # examples
- cd %ROOT_DIRECTORY%\examples - cd %ROOT_DIRECTORY%\examples
- b2.exe --hash -j2 %compiler% address-model=%model% variant=%variant% linkflags=%linkflags% include=%include% link=shared - b2.exe --hash warnings-as-errors=on -j2 %compiler% address-model=%model% variant=%variant% linkflags=%linkflags% include=%include% link=shared
# test # test
- cd %ROOT_DIRECTORY%\test - cd %ROOT_DIRECTORY%\test

View File

@ -85,7 +85,7 @@ int main(int argc, char const* argv[])
, std::istream_iterator<char>()}; , std::istream_iterator<char>()};
lt::error_code ec; lt::error_code ec;
lt::add_torrent_params atp = lt::read_resume_data(&buf[0], buf.size(), ec); lt::add_torrent_params atp = lt::read_resume_data(&buf[0], int(buf.size()), ec);
atp.url = argv[1]; atp.url = argv[1];
atp.save_path = "."; // save in current dir atp.save_path = "."; // save in current dir
ses.async_add_torrent(atp); ses.async_add_torrent(atp);

View File

@ -139,7 +139,7 @@ struct set_keypress
bool sleep_and_input(int* c, int sleep) bool sleep_and_input(int* c, int sleep)
{ {
libtorrent::time_point start = libtorrent::clock_type::now(); libtorrent::time_point const start = libtorrent::clock_type::now();
int ret = 0; int ret = 0;
retry: retry:
fd_set set; fd_set set;
@ -569,7 +569,7 @@ bool disable_storage = false;
bool quit = false; bool quit = false;
void signal_handler(int signo) void signal_handler(int)
{ {
// make the main loop terminate // make the main loop terminate
quit = true; quit = true;
@ -646,19 +646,9 @@ void print_settings(int const start, int const num
} }
} }
// monitored_dir is true if this torrent is added because
// it was found in the directory that is monitored. If it
// is, it should be remembered so that it can be removed
// if it's no longer in that directory.
void add_torrent(libtorrent::session& ses void add_torrent(libtorrent::session& ses
, handles_t& files , handles_t& files
, std::set<libtorrent::torrent_handle>& non_files , std::string torrent)
, std::string torrent
, int allocation_mode
, std::string const& save_path
, bool monitored_dir
, int torrent_upload_limit
, int torrent_download_limit)
{ {
using namespace libtorrent; using namespace libtorrent;
static int counter = 0; static int counter = 0;
@ -760,12 +750,7 @@ bool filter_fun(std::string const& p)
void scan_dir(std::string const& dir_path void scan_dir(std::string const& dir_path
, libtorrent::session& ses , libtorrent::session& ses
, handles_t& files , handles_t& files)
, std::set<libtorrent::torrent_handle>& non_files
, int allocation_mode
, std::string const& save_path
, int torrent_upload_limit
, int torrent_download_limit)
{ {
std::set<std::string> valid; std::set<std::string> valid;
@ -794,8 +779,7 @@ void scan_dir(std::string const& dir_path
// the file has been added to the dir, start // the file has been added to the dir, start
// downloading it. // downloading it.
add_torrent(ses, files, non_files, file, allocation_mode add_torrent(ses, files, file);
, save_path, true, torrent_upload_limit, torrent_download_limit);
valid.insert(file); valid.insert(file);
} }
@ -956,6 +940,12 @@ bool handle_alert(libtorrent::session& ses, libtorrent::alert* a
return true; return true;
} }
#ifdef _MSC_VER
// it seems msvc makes the definitions of 'p' escape the if-statement here
#pragma warning(push)
#pragma warning(disable: 4456)
#endif
if (metadata_received_alert* p = alert_cast<metadata_received_alert>(a)) if (metadata_received_alert* p = alert_cast<metadata_received_alert>(a))
{ {
// if we have a monitor dir, save the .torrent file we just received in it // if we have a monitor dir, save the .torrent file we just received in it
@ -1018,7 +1008,7 @@ bool handle_alert(libtorrent::session& ses, libtorrent::alert* a
int peer_port = atoi(port); int peer_port = atoi(port);
error_code ec; error_code ec;
if (peer_port > 0) if (peer_port > 0)
h.connect_peer(tcp::endpoint(address::from_string(ip, ec), peer_port)); h.connect_peer(tcp::endpoint(address::from_string(ip, ec), boost::uint16_t(peer_port)));
} }
} }
@ -1098,12 +1088,16 @@ bool handle_alert(libtorrent::session& ses, libtorrent::alert* a
return true; return true;
} }
return false; return false;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
} }
void print_piece(libtorrent::partial_piece_info* pp void print_piece(libtorrent::partial_piece_info* pp
, libtorrent::cached_piece_info* cs , libtorrent::cached_piece_info* cs
, std::vector<libtorrent::peer_info> const& peers , std::vector<libtorrent::peer_info> const& peers
, torrent_status const* ts
, std::string& out) , std::string& out)
{ {
using namespace libtorrent; using namespace libtorrent;
@ -1121,7 +1115,7 @@ void print_piece(libtorrent::partial_piece_info* pp
int index = pp ? peer_index(pp->blocks[j].peer(), peers) % 36 : -1; int index = pp ? peer_index(pp->blocks[j].peer(), peers) % 36 : -1;
char chr = '+'; char chr = '+';
if (index >= 0) if (index >= 0)
chr = (index < 10)?'0' + index:'A' + index - 10; chr = char((index < 10)?'0' + index:'A' + index - 10);
bool snubbed = index >= 0 ? ((peers[index].flags & peer_info::snubbed) != 0) : false; bool snubbed = index >= 0 ? ((peers[index].flags & peer_info::snubbed) != 0) : false;
char const* color = ""; char const* color = "";
@ -1140,7 +1134,7 @@ void print_piece(libtorrent::partial_piece_info* pp
{ {
if (pp->blocks[j].num_peers > 1) color = esc("1;7"); if (pp->blocks[j].num_peers > 1) color = esc("1;7");
else color = snubbed ? esc("35;7") : esc("33;7"); else color = snubbed ? esc("35;7") : esc("33;7");
chr = '0' + (pp->blocks[j].bytes_progress * 10 / pp->blocks[j].block_size); chr = char('0' + (pp->blocks[j].bytes_progress * 10 / pp->blocks[j].block_size));
} }
else if (pp->blocks[j].state == block_info::finished) color = esc("32;7"); else if (pp->blocks[j].state == block_info::finished) color = esc("32;7");
else if (pp->blocks[j].state == block_info::writing) color = esc("36;7"); else if (pp->blocks[j].state == block_info::writing) color = esc("36;7");
@ -1159,15 +1153,6 @@ void print_piece(libtorrent::partial_piece_info* pp
} }
out += esc("0"); out += esc("0");
out += "]"; out += "]";
/*
char const* cache_kind_str[] = {"read", "write", "read-volatile"};
snprintf(str, sizeof(str), " %3d cache age: %-5.1f state: %s%s\n"
, cs ? cs->next_to_hash : 0
, cs ? (total_milliseconds(clock_type::now() - cs->last_use) / 1000.f) : 0.f
, cs ? cache_kind_str[cs->kind] : "N/A"
, ts && ts->pieces.size() ? (ts->pieces[piece] ? " have" : " dont-have") : "");
out += str;
*/
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@ -1354,6 +1339,10 @@ int main(int argc, char* argv[])
case 'Q': share_mode = true; --i; break; case 'Q': share_mode = true; --i; break;
case 't': poll_interval = atoi(arg); break; case 't': poll_interval = atoi(arg); break;
case 'F': refresh_delay = atoi(arg); break; case 'F': refresh_delay = atoi(arg); break;
case 'a': allocation_mode = (arg == std::string("sparse"))
? libtorrent::storage_mode_sparse
: libtorrent::storage_mode_allocate;
break;
case 'x': case 'x':
{ {
FILE* filter = fopen(arg, "r"); FILE* filter = fopen(arg, "r");
@ -1500,9 +1489,7 @@ int main(int argc, char* argv[])
} }
// if it's a torrent file, open it as usual // if it's a torrent file, open it as usual
add_torrent(ses, files, non_files, i->c_str() add_torrent(ses, files, i->c_str());
, allocation_mode, save_path, false
, torrent_upload_limit, torrent_download_limit);
} }
// main loop // main loop
@ -1556,9 +1543,9 @@ int main(int argc, char* argv[])
{ {
// escape code, read another character // escape code, read another character
#ifdef WIN32 #ifdef WIN32
int c = _getch(); c = _getch();
#else #else
int c = getc(stdin); c = getc(stdin);
if (c == EOF) { break; } if (c == EOF) { break; }
if (c != '[') continue; if (c != '[') continue;
c = getc(stdin); c = getc(stdin);
@ -1678,12 +1665,12 @@ int main(int argc, char* argv[])
, boost::bind(&handles_t::value_type::second, _1) == st.handle); , boost::bind(&handles_t::value_type::second, _1) == st.handle);
if (i != files.end()) if (i != files.end())
{ {
error_code ec; error_code err;
std::string path; std::string path;
if (is_absolute_path(i->first)) path = i->first; if (is_absolute_path(i->first)) path = i->first;
else path = path_append(monitor_dir, i->first); else path = path_append(monitor_dir, i->first);
if (::remove(path.c_str()) < 0) if (::remove(path.c_str()) < 0)
printf("failed to delete .torrent file: %s\n", ec.message().c_str()); printf("failed to delete .torrent file: %s\n", err.message().c_str());
files.erase(i); files.erase(i);
} }
if (st.handle.is_valid()) if (st.handle.is_valid())
@ -1710,14 +1697,13 @@ int main(int argc, char* argv[])
if (c == 'R') if (c == 'R')
{ {
// save resume data for all torrents // save resume data for all torrents
std::vector<torrent_status> torrents; std::vector<torrent_status> torr;
ses.get_torrent_status(&torrents, &yes, 0); ses.get_torrent_status(&torr, &yes, 0);
for (std::vector<torrent_status>::iterator i = torrents.begin() for (torrent_status const& st : torr)
, end(torrents.end()); i != end; ++i)
{ {
if (i->need_save_resume) if (st.need_save_resume)
{ {
i->handle.save_resume_data(); st.handle.save_resume_data();
++num_outstanding_resume_data; ++num_outstanding_resume_data;
} }
} }
@ -1835,7 +1821,6 @@ int main(int argc, char* argv[])
// loop through the alert queue to see if anything has happened. // loop through the alert queue to see if anything has happened.
std::vector<alert*> alerts; std::vector<alert*> alerts;
ses.pop_alerts(&alerts); ses.pop_alerts(&alerts);
std::string now = timestamp();
for (std::vector<alert*>::iterator i = alerts.begin() for (std::vector<alert*>::iterator i = alerts.begin()
, end(alerts.end()); i != end; ++i) , end(alerts.end()); i != end; ++i)
{ {
@ -1938,7 +1923,7 @@ int main(int argc, char* argv[])
if (print_trackers) if (print_trackers)
{ {
std::vector<announce_entry> tr = h.trackers(); std::vector<announce_entry> tr = h.trackers();
time_point now = clock_type::now(); time_point const now = clock_type::now();
for (std::vector<announce_entry>::iterator i = tr.begin() for (std::vector<announce_entry>::iterator i = tr.begin()
, end(tr.end()); i != end; ++i) , end(tr.end()); i != end; ++i)
{ {
@ -1987,7 +1972,7 @@ int main(int argc, char* argv[])
< boost::bind(&partial_piece_info::piece_index, _2)); < boost::bind(&partial_piece_info::piece_index, _2));
if (ppi != queue.end() && ppi->piece_index == i->piece) pp = &*ppi; if (ppi != queue.end() && ppi->piece_index == i->piece) pp = &*ppi;
print_piece(pp, &*i, peers, &s, out); print_piece(pp, &*i, peers, out);
int num_blocks = pp ? pp->blocks_in_piece : int(i->blocks.size()); int num_blocks = pp ? pp->blocks_in_piece : int(i->blocks.size());
p += num_blocks + 8; p += num_blocks + 8;
@ -2015,7 +2000,7 @@ int main(int argc, char* argv[])
{ {
if (pos + 3 >= terminal_height) break; if (pos + 3 >= terminal_height) break;
print_piece(&*i, 0, peers, &s, out); print_piece(&*i, 0, peers, out);
int num_blocks = i->blocks_in_piece; int num_blocks = i->blocks_in_piece;
p += num_blocks + 8; p += num_blocks + 8;
@ -2155,9 +2140,7 @@ int main(int argc, char* argv[])
if (!monitor_dir.empty() if (!monitor_dir.empty()
&& next_dir_scan < clock_type::now()) && next_dir_scan < clock_type::now())
{ {
scan_dir(monitor_dir, ses, files, non_files scan_dir(monitor_dir, ses, files);
, allocation_mode, save_path, torrent_upload_limit
, torrent_download_limit);
next_dir_scan = clock_type::now() + seconds(poll_interval); next_dir_scan = clock_type::now() + seconds(poll_interval);
} }
} }
@ -2200,7 +2183,7 @@ int main(int argc, char* argv[])
std::vector<alert*> alerts; std::vector<alert*> alerts;
ses.pop_alerts(&alerts); ses.pop_alerts(&alerts);
std::string now = timestamp(); std::string const now = timestamp();
for (std::vector<alert*>::iterator i = alerts.begin() for (std::vector<alert*>::iterator i = alerts.begin()
, end(alerts.end()); i != end; ++i) , end(alerts.end()); i != end; ++i)
{ {

View File

@ -261,7 +261,7 @@ struct peer_conn
, boost::bind(&peer_conn::on_handshake, this, h, _1, _2)); , boost::bind(&peer_conn::on_handshake, this, h, _1, _2));
} }
void on_handshake(char* h, error_code const& ec, size_t bytes_transferred) void on_handshake(char* h, error_code const& ec, size_t)
{ {
free(h); free(h);
if (ec) if (ec)
@ -275,7 +275,7 @@ struct peer_conn
, boost::bind(&peer_conn::on_handshake2, this, _1, _2)); , boost::bind(&peer_conn::on_handshake2, this, _1, _2));
} }
void on_handshake2(error_code const& ec, size_t bytes_transferred) void on_handshake2(error_code const& ec, size_t)
{ {
if (ec) if (ec)
{ {
@ -331,7 +331,7 @@ struct peer_conn
} }
} }
void on_have_all_sent(error_code const& ec, size_t bytes_transferred) void on_have_all_sent(error_code const& ec, size_t)
{ {
if (ec) if (ec)
{ {
@ -376,7 +376,7 @@ struct peer_conn
} }
else else
{ {
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
} }
char msg[] = "\0\0\0\xd\x06" char msg[] = "\0\0\0\xd\x06"
@ -404,7 +404,7 @@ struct peer_conn
return true; return true;
} }
void on_req_sent(char* m, error_code const& ec, size_t bytes_transferred) void on_req_sent(char* m, error_code const& ec, size_t)
{ {
free(m); free(m);
if (ec) if (ec)
@ -465,7 +465,7 @@ struct peer_conn
, boost::bind(&peer_conn::on_msg_length, this, _1, _2)); , boost::bind(&peer_conn::on_msg_length, this, _1, _2));
} }
void on_msg_length(error_code const& ec, size_t bytes_transferred) void on_msg_length(error_code const& ec, size_t)
{ {
if ((ec == boost::asio::error::operation_aborted || ec == boost::asio::error::bad_descriptor) if ((ec == boost::asio::error::operation_aborted || ec == boost::asio::error::bad_descriptor)
&& restarting) && restarting)
@ -671,7 +671,6 @@ struct peer_conn
{ {
fprintf(stderr, "received invalid block. piece %d block %d\n", piece, start / 0x4000); fprintf(stderr, "received invalid block. piece %d block %d\n", piece, start / 0x4000);
exit(1); exit(1);
return false;
} }
} }
return true; return true;
@ -831,8 +830,10 @@ void generate_data(char const* path, torrent_info const& ti)
boost::scoped_ptr<storage_interface> st(default_storage_constructor(params)); boost::scoped_ptr<storage_interface> st(default_storage_constructor(params));
storage_error error; {
st->initialize(error); storage_error error;
st->initialize(error);
}
boost::uint32_t piece[0x4000 / 4]; boost::uint32_t piece[0x4000 / 4];
for (int i = 0; i < ti.num_pieces(); ++i) for (int i = 0; i < ti.num_pieces(); ++i)
@ -974,8 +975,8 @@ int main(int argc, char* argv[])
const int piece_size = 1024 * 1024; const int piece_size = 1024 * 1024;
libtorrent::create_torrent t(fs, piece_size); libtorrent::create_torrent t(fs, piece_size);
sha1_hash zero(0); sha1_hash zero(0);
for (int i = 0; i < fs.num_pieces(); ++i) for (int k = 0; k < fs.num_pieces(); ++k)
t.set_hash(i, zero); t.set_hash(k, zero);
buf.clear(); buf.clear();
@ -1024,12 +1025,12 @@ int main(int argc, char* argv[])
fprintf(stderr, "ERROR RESOLVING %s: %s\n", destination_ip, ec.message().c_str()); fprintf(stderr, "ERROR RESOLVING %s: %s\n", destination_ip, ec.message().c_str());
return 1; return 1;
} }
tcp::endpoint ep(addr, destination_port); tcp::endpoint ep(addr, boost::uint16_t(destination_port));
#if !defined __APPLE__ #if !defined __APPLE__
// apparently darwin doesn't seems to let you bind to // apparently darwin doesn't seems to let you bind to
// loopback on any other IP than 127.0.0.1 // loopback on any other IP than 127.0.0.1
unsigned long ip = addr.to_ulong(); boost::uint32_t const ip = addr.to_ulong();
if ((ip & 0xff000000) == 0x7f000000) if ((ip & 0xff000000) == 0x7f000000)
{ {
local_bind = true; local_bind = true;

View File

@ -2423,6 +2423,9 @@ namespace libtorrent
private: private:
int m_array_idx; int m_array_idx;
int m_num_blocks; int m_num_blocks;
#else
picker_log_alert(aux::stack_allocator& alloc)
: peer_alert(alloc, torrent_handle(), tcp::endpoint(), peer_id()) {}
#endif // TORRENT_DISABLE_LOGGING #endif // TORRENT_DISABLE_LOGGING
}; };

View File

@ -95,15 +95,26 @@ extern char const* libtorrent_assert_log;
#define TORRENT_ASSERT_VAL(x, y) \ #define TORRENT_ASSERT_VAL(x, y) \
do { if (x) {} else { std::stringstream __s__; __s__ << #y ": " << y; \ do { if (x) {} else { std::stringstream __s__; __s__ << #y ": " << y; \
assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, __s__.str().c_str(), 0); } } TORRENT_WHILE_0 assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, __s__.str().c_str(), 0); } } TORRENT_WHILE_0
#define TORRENT_ASSERT_FAIL_VAL(y) \
do { std::stringstream __s__; __s__ << #y ": " << y; \
assert_fail("<unconditional>", __LINE__, __FILE__, TORRENT_FUNCTION, __s__.str().c_str(), 0); } TORRENT_WHILE_0
#else #else
#define TORRENT_ASSERT_VAL(x, y) TORRENT_ASSERT(x) #define TORRENT_ASSERT_VAL(x, y) TORRENT_ASSERT(x)
#define TORRENT_ASSERT_FAIL_VAL(x) TORRENT_ASSERT_FAIL()
#endif #endif
#define TORRENT_ASSERT_FAIL() \
assert_fail("<unconditional>", __LINE__, __FILE__, TORRENT_FUNCTION, 0, 0)
#else #else
#include <cassert> #include <cassert>
#define TORRENT_ASSERT_PRECOND(x) assert(x) #define TORRENT_ASSERT_PRECOND(x) assert(x)
#define TORRENT_ASSERT(x) assert(x) #define TORRENT_ASSERT(x) assert(x)
#define TORRENT_ASSERT_VAL(x, y) assert(x) #define TORRENT_ASSERT_VAL(x, y) assert(x)
#define TORRENT_ASSERT_FAIL_VAL(x) assert(false)
#define TORRENT_ASSERT_FAIL() assert(false)
#endif #endif
#else // TORRENT_USE_ASSERTS #else // TORRENT_USE_ASSERTS
@ -111,6 +122,8 @@ extern char const* libtorrent_assert_log;
#define TORRENT_ASSERT_PRECOND(a) do {} TORRENT_WHILE_0 #define TORRENT_ASSERT_PRECOND(a) do {} TORRENT_WHILE_0
#define TORRENT_ASSERT(a) do {} TORRENT_WHILE_0 #define TORRENT_ASSERT(a) do {} TORRENT_WHILE_0
#define TORRENT_ASSERT_VAL(a, b) do {} TORRENT_WHILE_0 #define TORRENT_ASSERT_VAL(a, b) do {} TORRENT_WHILE_0
#define TORRENT_ASSERT_FAIL_VAL(a) do {} TORRENT_WHILE_0
#define TORRENT_ASSERT_FAIL() do {} TORRENT_WHILE_0
#endif // TORRENT_USE_ASSERTS #endif // TORRENT_USE_ASSERTS

View File

@ -74,5 +74,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push, 1) #pragma warning(push, 1)
// warning C4005: macro redefinition
#pragma warning( disable : 4005 )
#endif #endif

View File

@ -149,7 +149,7 @@ namespace libtorrent { namespace aux
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)
view[i] = str[i]; view[i] = str[i];
view = array_view<Byte>(view.data() + len, view.size() - len); view = array_view<Byte>(view.data() + len, int(view.size()) - len);
return len; return len;
} }

View File

@ -871,7 +871,7 @@ namespace libtorrent
#endif #endif
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
ssl::context* ssl_ctx() { return &m_ssl_ctx; } ssl::context* ssl_ctx() override { return &m_ssl_ctx; }
void on_incoming_utp_ssl(boost::shared_ptr<socket_type> const& s); void on_incoming_utp_ssl(boost::shared_ptr<socket_type> const& s);
void ssl_handshake(error_code const& ec, boost::shared_ptr<socket_type> s); void ssl_handshake(error_code const& ec, boost::shared_ptr<socket_type> s);
#endif #endif

View File

@ -118,7 +118,7 @@ namespace libtorrent
{ {
if (v >= 0 && v < 10) return char('0' + v); if (v >= 0 && v < 10) return char('0' + v);
else if (v >= 10) return char('A' + (v - 10)); else if (v >= 10) return char('A' + (v - 10));
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
return '0'; return '0';
} }

View File

@ -35,10 +35,14 @@ POSSIBILITY OF SUCH DAMAGE.
#include <vector> #include <vector>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp> #include <boost/type_traits/is_base_of.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
namespace libtorrent { namespace libtorrent {

View File

@ -44,7 +44,7 @@ namespace libtorrent
} }
TORRENT_CATCH_ALL TORRENT_CATCH_ALL
{ {
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
} }
@ -59,7 +59,7 @@ namespace libtorrent
} }
TORRENT_CATCH_ALL TORRENT_CATCH_ALL
{ {
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
} }

View File

@ -250,6 +250,13 @@ public:
std::map<std::string, node*> const& m_nodes; std::map<std::string, node*> const& m_nodes;
private: private:
#ifdef _MSC_VER
#pragma warning(push)
// warning: default constructor could not be generated
#pragma warning(disable: 4510)
// warning: struct can never be instantiated
#pragma warning(disable: 4610)
#endif
struct protocol_descriptor struct protocol_descriptor
{ {
udp protocol; udp protocol;
@ -257,6 +264,9 @@ private:
char const* nodes_key; char const* nodes_key;
}; };
#ifdef _MSC_VER
#pragma warning(pop)
#endif
static protocol_descriptor const& map_protocol_to_descriptor(udp protocol); static protocol_descriptor const& map_protocol_to_descriptor(udp protocol);
dht_observer* m_observer; dht_observer* m_observer;

View File

@ -621,7 +621,7 @@ namespace libtorrent
std::set<const torrent_peer*> have_peers; std::set<const torrent_peer*> have_peers;
#endif #endif
enum enum : boost::uint32_t
{ {
// index is set to this to indicate that we have the // index is set to this to indicate that we have the
// piece. There is no entry for the piece in the // piece. There is no entry for the piece in the

View File

@ -117,7 +117,7 @@ POSSIBILITY OF SUCH DAMAGE.
get<utp_stream>()->x; break; \ get<utp_stream>()->x; break; \
TORRENT_SOCKTYPE_I2P_FORWARD(x) \ TORRENT_SOCKTYPE_I2P_FORWARD(x) \
TORRENT_SOCKTYPE_SSL_FORWARD(x) \ TORRENT_SOCKTYPE_SSL_FORWARD(x) \
default: TORRENT_ASSERT(false); \ default: TORRENT_ASSERT_FAIL(); \
} }
#define TORRENT_SOCKTYPE_FORWARD_RET(x, def) \ #define TORRENT_SOCKTYPE_FORWARD_RET(x, def) \
@ -132,7 +132,7 @@ POSSIBILITY OF SUCH DAMAGE.
return get<utp_stream>()->x; \ return get<utp_stream>()->x; \
TORRENT_SOCKTYPE_I2P_FORWARD_RET(x, def) \ TORRENT_SOCKTYPE_I2P_FORWARD_RET(x, def) \
TORRENT_SOCKTYPE_SSL_FORWARD_RET(x, def) \ TORRENT_SOCKTYPE_SSL_FORWARD_RET(x, def) \
default: TORRENT_ASSERT(false); return def; \ default: TORRENT_ASSERT_FAIL(); return def; \
} }
namespace libtorrent namespace libtorrent

View File

@ -104,7 +104,7 @@ namespace libtorrent
int loss_multiplier() const { return m_sett.get_int(settings_pack::utp_loss_multiplier); } int loss_multiplier() const { return m_sett.get_int(settings_pack::utp_loss_multiplier); }
void mtu_for_dest(address const& addr, int& link_mtu, int& utp_mtu); void mtu_for_dest(address const& addr, int& link_mtu, int& utp_mtu);
int num_sockets() const { return m_utp_sockets.size(); } int num_sockets() const { return int(m_utp_sockets.size()); }
void defer_ack(utp_socket_impl* s); void defer_ack(utp_socket_impl* s);
void subscribe_drained(utp_socket_impl* s); void subscribe_drained(utp_socket_impl* s);

View File

@ -364,7 +364,7 @@ public:
TORRENT_ASSERT(!m_read_handler); TORRENT_ASSERT(!m_read_handler);
if (m_read_handler) if (m_read_handler)
{ {
TORRENT_ASSERT(false); // we should never do this! TORRENT_ASSERT_FAIL(); // we should never do this!
m_io_service.post(boost::bind<void>(handler, boost::asio::error::operation_not_supported, 0)); m_io_service.post(boost::bind<void>(handler, boost::asio::error::operation_not_supported, 0));
return; return;
} }

View File

@ -109,7 +109,7 @@ namespace libtorrent
void write_have(int) {} void write_have(int) {}
void write_dont_have(int) {} void write_dont_have(int) {}
void write_piece(peer_request const&, disk_buffer_holder&) void write_piece(peer_request const&, disk_buffer_holder&)
{ TORRENT_ASSERT(false); } { TORRENT_ASSERT_FAIL(); }
void write_keepalive() {} void write_keepalive() {}
void on_connected(); void on_connected();
void write_reject_request(peer_request const&) {} void write_reject_request(peer_request const&) {}

View File

@ -2001,7 +2001,7 @@ namespace libtorrent
else if (packet_type <= msg_extended) else if (packet_type <= msg_extended)
counter = counters::num_incoming_extended; counter = counters::num_incoming_extended;
else else
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
stats_counters().inc_stats_counter(counter); stats_counters().inc_stats_counter(counter);
} }

View File

@ -405,7 +405,7 @@ namespace libtorrent
} }
else else
{ {
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
int pieces = sett.get_int(settings_pack::seeding_piece_quota); int pieces = sett.get_int(settings_pack::seeding_piece_quota);
std::partial_sort(peers.begin(), peers.begin() std::partial_sort(peers.begin(), peers.begin()

View File

@ -89,8 +89,12 @@ namespace libtorrent
#define TORRENT_PIECE_ASSERT(cond, piece) \ #define TORRENT_PIECE_ASSERT(cond, piece) \
do { if (!(cond)) { assert_print_piece(piece); assert_fail(#cond, __LINE__, __FILE__, TORRENT_FUNCTION, 0); } } TORRENT_WHILE_0 do { if (!(cond)) { assert_print_piece(piece); assert_fail(#cond, __LINE__, __FILE__, TORRENT_FUNCTION, 0); } } TORRENT_WHILE_0
#define TORRENT_PIECE_ASSERT_FAIL(piece) \
do { assert_print_piece(piece); assert_fail("<unconditional>", __LINE__, __FILE__, TORRENT_FUNCTION, 0); } TORRENT_WHILE_0
#else #else
#define TORRENT_PIECE_ASSERT(cond, piece) do {} TORRENT_WHILE_0 #define TORRENT_PIECE_ASSERT(cond, piece) do {} TORRENT_WHILE_0
#define TORRENT_PIECE_ASSERT_FAIL(piece) do {} TORRENT_WHILE_0
#endif // TORRENT_USE_ASSERTS #endif // TORRENT_USE_ASSERTS
namespace { namespace {
@ -1297,7 +1301,7 @@ namespace libtorrent
{ {
// the piece is supposed to be allocated when the // the piece is supposed to be allocated when the
// disk job is allocated // disk job is allocated
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
return ret; return ret;
} }
TORRENT_PIECE_ASSERT(pe->outstanding_read == 1, pe); TORRENT_PIECE_ASSERT(pe->outstanding_read == 1, pe);
@ -2997,7 +3001,7 @@ namespace libtorrent
// we should always be able to evict the piece, since // we should always be able to evict the piece, since
// this is a fence job // this is a fence job
TORRENT_PIECE_ASSERT(false, pe); TORRENT_PIECE_ASSERT_FAIL(pe);
return retry_job; return retry_job;
} }

View File

@ -611,7 +611,7 @@ namespace libtorrent
{ {
// currently, only swapping entries of the same type or where one // currently, only swapping entries of the same type or where one
// of the entries is uninitialized is supported. // of the entries is uninitialized is supported.
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
} }

View File

@ -140,7 +140,7 @@ namespace libtorrent
} }
else else
{ {
TORRENT_ASSERT_VAL(false, ps.type); TORRENT_ASSERT_FAIL_VAL(ps.type);
return false; return false;
} }
return true; return true;

View File

@ -51,7 +51,7 @@ namespace libtorrent
} }
#endif #endif
else else
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
int ip_filter::access(address const& addr) const int ip_filter::access(address const& addr) const

View File

@ -637,7 +637,8 @@ namespace libtorrent { namespace dht
m_send_quota -= int(m_send_buf.size()); m_send_quota -= int(m_send_buf.size());
error_code ec; error_code ec;
m_send_fun(addr, aux::array_view<char const>(&m_send_buf[0], m_send_buf.size()), ec, 0); m_send_fun(addr, aux::array_view<char const>(&m_send_buf[0]
, int(m_send_buf.size())), ec, 0);
if (ec) if (ec)
{ {
m_counters.inc_stats_counter(counters::dht_messages_out_dropped); m_counters.inc_stats_counter(counters::dht_messages_out_dropped);

View File

@ -1234,7 +1234,7 @@ node::protocol_descriptor const& node::map_protocol_to_descriptor(udp protocol)
return descriptors[i]; return descriptors[i];
} }
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
throw std::out_of_range("unknown protocol"); throw std::out_of_range("unknown protocol");
} }

View File

@ -296,7 +296,7 @@ namespace libtorrent
TORRENT_UNUSED(ec); TORRENT_UNUSED(ec);
// not implemented // not implemented
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
void part_file::export_file(file& f, boost::int64_t offset, boost::int64_t size, error_code& ec) void part_file::export_file(file& f, boost::int64_t offset, boost::int64_t size, error_code& ec)

View File

@ -43,7 +43,7 @@ namespace libtorrent
!= m_class.begin() + m_size) return; != m_class.begin() + m_size) return;
if (m_size >= m_class.size() - 1) if (m_size >= m_class.size() - 1)
{ {
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
return; return;
} }
m_class[m_size] = c; m_class[m_size] = c;

View File

@ -3033,7 +3033,7 @@ namespace libtorrent
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? TORRENT_ASSERT_FAIL(); // how do we get here?
picker.mark_as_canceled(block_finished, peer_info_struct()); picker.mark_as_canceled(block_finished, peer_info_struct());
return; return;
} }

View File

@ -2488,7 +2488,7 @@ get_out:
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
} }

View File

@ -336,13 +336,6 @@ namespace libtorrent
void session::start(int flags, settings_pack const& pack, io_service* ios) void session::start(int flags, settings_pack const& pack, io_service* ios)
{ {
#if defined _MSC_VER && defined TORRENT_DEBUG
// workaround for microsoft's
// hardware exceptions that makes
// it hard to debug stuff
::_set_se_translator(straight_to_debugger);
#endif
bool const internal_executor = ios == NULL; bool const internal_executor = ios == NULL;
if (internal_executor) if (internal_executor)

View File

@ -2312,7 +2312,7 @@ namespace aux {
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
if (m_dht && buf.size() > 20 && buf.front() == 'd' && buf.back() == 'e') if (m_dht && buf.size() > 20 && buf.front() == 'd' && buf.back() == 'e')
{ {
handled = m_dht->incoming_packet(packet.from, buf.data(), buf.size()); handled = m_dht->incoming_packet(packet.from, buf.data(), int(buf.size()));
} }
#endif #endif

View File

@ -712,7 +712,7 @@ namespace libtorrent
return i != m_bools.end() && i->first == name; return i != m_bools.end() && i->first == name;
} }
} }
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
return false; return false;
} }

View File

@ -218,7 +218,7 @@ namespace libtorrent
get<ssl_stream<utp_stream> >()->~ssl_stream(); get<ssl_stream<utp_stream> >()->~ssl_stream();
break; break;
#endif #endif
default: TORRENT_ASSERT(false); default: TORRENT_ASSERT_FAIL();
} }
m_type = 0; m_type = 0;
} }
@ -272,7 +272,7 @@ namespace libtorrent
, *static_cast<ssl::context*>(userdata)); , *static_cast<ssl::context*>(userdata));
break; break;
#endif #endif
default: TORRENT_ASSERT(false); default: TORRENT_ASSERT_FAIL();
} }
m_type = type; m_type = type;

View File

@ -211,7 +211,7 @@ namespace libtorrent
detail::write_uint8(flags, ptr); detail::write_uint8(flags, ptr);
std::unique_lock<std::mutex> l(disk_access_mutex); std::unique_lock<std::mutex> l(disk_access_mutex);
int ret = fwrite(event, 1, sizeof(event), g_access_log); int const ret = int(fwrite(event, 1, sizeof(event), g_access_log));
l.unlock(); l.unlock();
if (ret != sizeof(event)) if (ret != sizeof(event))
{ {
@ -762,7 +762,7 @@ namespace libtorrent
#if defined TORRENT_DEBUG_FILE_LEAKS #if defined TORRENT_DEBUG_FILE_LEAKS
print_open_files("delete-files idle assert failed", m_files.name().c_str()); print_open_files("delete-files idle assert failed", m_files.name().c_str());
#endif #endif
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
#endif #endif

View File

@ -384,7 +384,7 @@ namespace libtorrent
// we might want to do a full check to see if we have // we might want to do a full check to see if we have
// all the pieces. This is low priority since almost // all the pieces. This is low priority since almost
// no one uses merkle torrents // no one uses merkle torrents
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
} }
@ -1622,7 +1622,7 @@ namespace libtorrent
// wrap the PEM certificate in a BIO, for openssl to read // wrap the PEM certificate in a BIO, for openssl to read
BIO* bp = BIO_new_mem_buf( BIO* bp = BIO_new_mem_buf(
const_cast<void*>(static_cast<void const*>(cert.c_str())) const_cast<void*>(static_cast<void const*>(cert.c_str()))
, cert.size()); , int(cert.size()));
// parse the certificate into OpenSSL's internal // parse the certificate into OpenSSL's internal
// representation // representation
@ -5867,7 +5867,7 @@ namespace libtorrent
peer_iterator i = sorted_find(m_connections, p); peer_iterator i = sorted_find(m_connections, p);
if (i == m_connections.end()) if (i == m_connections.end())
{ {
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
return; return;
} }
@ -7639,7 +7639,7 @@ namespace libtorrent
TORRENT_LIST_NAME(torrent_downloading_auto_managed); TORRENT_LIST_NAME(torrent_downloading_auto_managed);
TORRENT_LIST_NAME(torrent_seeding_auto_managed); TORRENT_LIST_NAME(torrent_seeding_auto_managed);
TORRENT_LIST_NAME(torrent_checking_auto_managed); TORRENT_LIST_NAME(torrent_checking_auto_managed);
default: TORRENT_ASSERT_VAL(false, idx); default: TORRENT_ASSERT_FAIL_VAL(idx);
} }
#undef TORRENT_LIST_NAME #undef TORRENT_LIST_NAME
return ""; return "";
@ -7758,7 +7758,7 @@ namespace libtorrent
++ret; ++ret;
TORRENT_ASSERT(p->associated_torrent().lock().get() == this); TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
int num_conns = m_connections.size(); int const num_conns = int(m_connections.size());
#endif #endif
p->disconnect(ec, op_bittorrent); p->disconnect(ec, op_bittorrent);
TORRENT_ASSERT(int(m_connections.size()) == num_conns - 1); TORRENT_ASSERT(int(m_connections.size()) == num_conns - 1);
@ -8355,7 +8355,7 @@ namespace libtorrent
if (!p.is_choked() && !p.ignore_unchoke_slots()) ++num_uploads; if (!p.is_choked() && !p.ignore_unchoke_slots()) ++num_uploads;
torrent* associated_torrent = p.associated_torrent().lock().get(); torrent* associated_torrent = p.associated_torrent().lock().get();
if (associated_torrent != this && associated_torrent != 0) if (associated_torrent != this && associated_torrent != 0)
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
TORRENT_ASSERT(num_uploads == int(m_num_uploads)); TORRENT_ASSERT(num_uploads == int(m_num_uploads));
TORRENT_ASSERT(seeds == int(m_num_seeds)); TORRENT_ASSERT(seeds == int(m_num_seeds));
@ -8399,7 +8399,7 @@ namespace libtorrent
, k->timed_out ? "timed-out" : "", k->busy ? "busy": ""); , k->timed_out ? "timed-out" : "", k->busy ? "busy": "");
} }
} }
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
} }
} }
@ -8421,12 +8421,12 @@ namespace libtorrent
if (m_peer_list && m_peer_list->begin_peer() != m_peer_list->end_peer()) if (m_peer_list && m_peer_list->begin_peer() != m_peer_list->end_peer())
{ {
peer_list::const_iterator i = m_peer_list->begin_peer(); peer_list::const_iterator i = m_peer_list->begin_peer();
peer_list::const_iterator prev = i++; peer_list::const_iterator p = i++;
peer_list::const_iterator end(m_peer_list->end_peer()); peer_list::const_iterator end(m_peer_list->end_peer());
peer_address_compare cmp; peer_address_compare cmp;
for (; i != end; ++i, ++prev) for (; i != end; ++i, ++p)
{ {
TORRENT_ASSERT(!cmp(*i, *prev)); TORRENT_ASSERT(!cmp(*i, *p));
} }
} }
#endif #endif
@ -10974,7 +10974,7 @@ namespace libtorrent
return true; return true;
default: default:
// unexpected state // unexpected state
TORRENT_ASSERT_VAL(false, st); TORRENT_ASSERT_FAIL_VAL(st);
return false; return false;
} }
} }

View File

@ -466,6 +466,6 @@ namespace libtorrent
int tracker_manager::num_requests() const int tracker_manager::num_requests() const
{ {
std::lock_guard<std::mutex> l(m_mutex); std::lock_guard<std::mutex> l(m_mutex);
return m_http_conns.size() + m_udp_conns.size(); return int(m_http_conns.size() + m_udp_conns.size());
} }
} }

View File

@ -170,14 +170,14 @@ udp_socket::udp_socket(io_service& ios)
int udp_socket::read(array_view<packet> pkts, error_code& ec) int udp_socket::read(array_view<packet> pkts, error_code& ec)
{ {
int const num = pkts.size(); int const num = int(pkts.size());
int ret = 0; int ret = 0;
packet p; packet p;
while (ret < num) while (ret < num)
{ {
int const len = m_socket.receive_from(boost::asio::buffer(*m_buf) int const len = int(m_socket.receive_from(boost::asio::buffer(*m_buf)
, p.from, 0, ec); , p.from, 0, ec));
if (ec == error::would_block if (ec == error::would_block
|| ec == error::try_again || ec == error::try_again
@ -334,7 +334,7 @@ void udp_socket::wrap(char const* hostname, int const port, array_view<char cons
write_uint16(0, h); // reserved write_uint16(0, h); // reserved
write_uint8(0, h); // fragment write_uint8(0, h); // fragment
write_uint8(3, h); // atyp write_uint8(3, h); // atyp
int hostlen = (std::min)(strlen(hostname), size_t(255)); int const hostlen = (std::min)(int(strlen(hostname)), 255);
write_uint8(hostlen, h); // hostname len write_uint8(hostlen, h); // hostname len
memcpy(h, hostname, hostlen); memcpy(h, hostname, hostlen);
h += hostlen; h += hostlen;
@ -360,7 +360,7 @@ bool udp_socket::unwrap(udp::endpoint& from, array_view<char>& buf)
using namespace libtorrent::detail; using namespace libtorrent::detail;
// the minimum socks5 header size // the minimum socks5 header size
int const size = buf.size(); int const size = int(buf.size());
if (size <= 10) return false; if (size <= 10) return false;
char* p = buf.data(); char* p = buf.data();
@ -728,7 +728,7 @@ void socks5::connect2(error_code const& e)
{ {
// in this case we need to read more data from the socket // in this case we need to read more data from the socket
// no IPv6 support for UDP socks5 // no IPv6 support for UDP socks5
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
return; return;
} }

View File

@ -598,7 +598,7 @@ namespace libtorrent
resp.min_interval = 60; resp.min_interval = 60;
resp.incomplete = aux::read_int32(buf); resp.incomplete = aux::read_int32(buf);
resp.complete = aux::read_int32(buf); resp.complete = aux::read_int32(buf);
int const num_peers = buf.size() / 6; int const num_peers = int(buf.size()) / 6;
if ((buf.size() % 6) != 0) if ((buf.size() % 6) != 0)
{ {
fail(error_code(errors::invalid_tracker_response_length)); fail(error_code(errors::invalid_tracker_response_length));
@ -768,16 +768,18 @@ namespace libtorrent
if (!m_hostname.empty()) if (!m_hostname.empty())
{ {
m_man.send_hostname(m_hostname.c_str() m_man.send_hostname(m_hostname.c_str()
, m_target.port(), aux::array_view<char const>(buf, sizeof(buf) - out.size()), ec , m_target.port(), aux::array_view<char const>(buf
, int(sizeof(buf) - out.size())), ec
, udp_socket::tracker_connection); , udp_socket::tracker_connection);
} }
else else
{ {
m_man.send(m_target, aux::array_view<char const>(buf, sizeof(buf) - out.size()), ec m_man.send(m_target, aux::array_view<char const>(buf
, int(sizeof(buf) - out.size())), ec
, udp_socket::tracker_connection); , udp_socket::tracker_connection);
} }
m_state = action_announce; m_state = action_announce;
sent_bytes(sizeof(buf) - out.size() + 28); // assuming UDP/IP header sent_bytes(int(sizeof(buf) - out.size()) + 28); // assuming UDP/IP header
++m_attempts; ++m_attempts;
if (ec) if (ec)
{ {

View File

@ -750,7 +750,7 @@ bool utp_incoming_packet(utp_socket_impl* s
, udp::endpoint const& ep, time_point receive_time) , udp::endpoint const& ep, time_point receive_time)
{ {
return s->incoming_packet( return s->incoming_packet(
aux::array_view<boost::uint8_t const>(reinterpret_cast<boost::uint8_t const*>(p.data()), p.size()) aux::array_view<boost::uint8_t const>(reinterpret_cast<boost::uint8_t const*>(p.data()), int(p.size()))
, ep, receive_time); , ep, receive_time);
} }
@ -2426,7 +2426,7 @@ void utp_socket_impl::ack_packet(packet* p, time_point const& receive_time
rtt = 100000; rtt = 100000;
// the clock for this platform is not monotonic! // the clock for this platform is not monotonic!
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
UTP_LOGV("%8p: acked packet %d (%d bytes) (rtt:%u)\n" UTP_LOGV("%8p: acked packet %d (%d bytes) (rtt:%u)\n"
@ -2947,7 +2947,7 @@ bool utp_socket_impl::incoming_packet(aux::array_view<boost::uint8_t const> buf
// look for extended headers // look for extended headers
boost::uint8_t const* ptr = buf.data(); boost::uint8_t const* ptr = buf.data();
int const size = buf.size(); int const size = int(buf.size());
ptr += sizeof(utp_header); ptr += sizeof(utp_header);
unsigned int extension = ph->extension; unsigned int extension = ph->extension;

View File

@ -217,7 +217,7 @@ bool peer_conn::write_request()
} }
else else
{ {
TORRENT_ASSERT(false); TORRENT_ASSERT_FAIL();
} }
} }
char msg[] = "\0\0\0\xd\x06" char msg[] = "\0\0\0\xd\x06"

View File

@ -39,12 +39,12 @@ using namespace libtorrent;
struct allocator : buffer_allocator_interface struct allocator : buffer_allocator_interface
{ {
void free_disk_buffer(char*) {} void free_disk_buffer(char*) {}
char* allocate_disk_buffer(char const*) { TORRENT_ASSERT(false); return NULL; } char* allocate_disk_buffer(char const*) { TORRENT_ASSERT_FAIL(); return NULL; }
char* allocate_disk_buffer(bool& char* allocate_disk_buffer(bool&
, boost::shared_ptr<disk_observer> , boost::shared_ptr<disk_observer>
, char const*) { TORRENT_ASSERT(false); return NULL; } , char const*) { TORRENT_ASSERT_FAIL(); return NULL; }
char* async_allocate_disk_buffer(char const* char* async_allocate_disk_buffer(char const*
, boost::function<void(char*)> const&) { TORRENT_ASSERT(false); return NULL; } , boost::function<void(char*)> const&) { TORRENT_ASSERT_FAIL(); return NULL; }
void reclaim_block(block_cache_reference ref) {} void reclaim_block(block_cache_reference ref) {}
}; };