fix default release build with VS2015 UP2 compiler warnings (#624)
* fix default release build with VS2015 UP2 compiler warnings this will allow to successfully build: bjam toolset=msvc-14.0 release deprecated-functions=off character-set=unicode link=static warnings-as-errors=on
This commit is contained in:
parent
d090bec242
commit
7b5d48c02a
|
@ -275,8 +275,11 @@ int sha512(const unsigned char *message, size_t message_len, unsigned char *out)
|
|||
{
|
||||
sha512_context ctx;
|
||||
int ret;
|
||||
if ((ret = sha512_init(&ctx))) return ret;
|
||||
if ((ret = sha512_update(&ctx, message, message_len))) return ret;
|
||||
if ((ret = sha512_final(&ctx, out))) return ret;
|
||||
ret = sha512_init(&ctx);
|
||||
if (ret) return ret;
|
||||
ret = sha512_update(&ctx, message, message_len);
|
||||
if (ret) return ret;
|
||||
ret = sha512_final(&ctx, out);
|
||||
if (ret) return ret;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -680,7 +680,7 @@ namespace libtorrent
|
|||
// what to do when it's actually touching the file
|
||||
struct fileop
|
||||
{
|
||||
virtual int file_op(int file_index, boost::int64_t file_offset, int size
|
||||
virtual int file_op(int const file_index, boost::int64_t const file_offset, int const size
|
||||
, file::iovec_t const* bufs, storage_error& ec) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -1892,8 +1892,8 @@ namespace libtorrent {
|
|||
for (int i = 0; i < m_num_peers; i++) {
|
||||
tcp::endpoint endp = peers[i];
|
||||
std::size_t size = endp.size();
|
||||
|
||||
detail::write_uint8(size, ptr);
|
||||
TORRENT_ASSERT(size < 0x100);
|
||||
detail::write_uint8(uint8_t(size), ptr);
|
||||
memcpy(ptr, endp.data(), size);
|
||||
ptr += size;
|
||||
}
|
||||
|
|
|
@ -396,7 +396,7 @@ int block_cache::try_read(disk_io_job* j, bool expect_no_fail)
|
|||
#if TORRENT_USE_ASSERTS
|
||||
p->piece_log.push_back(piece_log_t(j->action, j->d.io.offset / 0x4000));
|
||||
#endif
|
||||
cache_hit(p, j->requester, j->flags & disk_io_job::volatile_read);
|
||||
cache_hit(p, j->requester, (j->flags & disk_io_job::volatile_read) != 0);
|
||||
|
||||
ret = copy_from_piece(p, j, expect_no_fail);
|
||||
if (ret < 0) return ret;
|
||||
|
|
|
@ -1239,6 +1239,12 @@ namespace libtorrent
|
|||
p.length = m_recv_buffer.packet_size() - header_size;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p.piece = 0;
|
||||
p.start = 0;
|
||||
p.length = 0;
|
||||
}
|
||||
|
||||
if (recv_pos <= header_size)
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace libtorrent { namespace aux
|
|||
#if TORRENT_HAS_SSE
|
||||
unsigned int cpui[4];
|
||||
cpuid(cpui, 1);
|
||||
return cpui[2] & (1 << 20);
|
||||
return (cpui[2] & (1 << 20)) != 0;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -78,7 +78,7 @@ namespace libtorrent { namespace aux
|
|||
#if TORRENT_HAS_SSE
|
||||
unsigned int cpui[4];
|
||||
cpuid(cpui, 1);
|
||||
return cpui[2] & (1 << 23);
|
||||
return (cpui[2] & (1 << 23)) != 0;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
|
|
@ -423,7 +423,14 @@ namespace libtorrent
|
|||
m_max_use = result / m_block_size;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4127 ) /* warning C4127: conditional expression is constant */
|
||||
#endif // _MSC_VER
|
||||
if (sizeof(void*) == 4)
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif // _MSC_VER
|
||||
{
|
||||
// 32 bit builds should capped below 2 GB of memory, even
|
||||
// when more actual ram is available, because we're still
|
||||
|
|
|
@ -2279,7 +2279,7 @@ namespace libtorrent
|
|||
#if TORRENT_USE_ASSERTS
|
||||
pe->piece_log.push_back(piece_log_t(j->action));
|
||||
#endif
|
||||
m_disk_cache.cache_hit(pe, j->requester, j->flags & disk_io_job::volatile_read);
|
||||
m_disk_cache.cache_hit(pe, j->requester, (j->flags & disk_io_job::volatile_read) != 0);
|
||||
|
||||
TORRENT_PIECE_ASSERT(pe->cache_state <= cached_piece_entry::read_lru1 || pe->cache_state == cached_piece_entry::read_lru2, pe);
|
||||
++pe->piece_refcount;
|
||||
|
|
|
@ -594,16 +594,16 @@ namespace libtorrent
|
|||
PIP_ADAPTER_ADDRESSES adapter_addresses
|
||||
= reinterpret_cast<IP_ADAPTER_ADDRESSES*>(&buffer[0]);
|
||||
|
||||
DWORD r = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER
|
||||
DWORD res = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER
|
||||
| GAA_FLAG_SKIP_ANYCAST, NULL, adapter_addresses, &buf_size);
|
||||
if (r == ERROR_BUFFER_OVERFLOW)
|
||||
if (res == ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
buffer.resize(buf_size);
|
||||
adapter_addresses = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(&buffer[0]);
|
||||
r = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER
|
||||
res = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER
|
||||
| GAA_FLAG_SKIP_ANYCAST, NULL, adapter_addresses, &buf_size);
|
||||
}
|
||||
if (r != NO_ERROR)
|
||||
if (res != NO_ERROR)
|
||||
{
|
||||
FreeLibrary(iphlp);
|
||||
ec = error_code(WSAGetLastError(), system_category());
|
||||
|
|
|
@ -780,9 +780,9 @@ namespace libtorrent
|
|||
// we don't care about the last character, since it's OK for it
|
||||
// to be a slash or a back slash
|
||||
bool found = false;
|
||||
for (int i = 2; i < int(f.size()) - 1; ++i)
|
||||
for (int j = 2; j < int(f.size()) - 1; ++j)
|
||||
{
|
||||
if (f[i] != '\\' && f[i] != '/') continue;
|
||||
if (f[j] != '\\' && f[j] != '/') continue;
|
||||
// there is a directory separator in here,
|
||||
// i.e. this is not the root
|
||||
found = true;
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace libtorrent
|
|||
{
|
||||
// file prio is only supported on vista and up
|
||||
// so load the functions dynamically
|
||||
typedef enum _FILE_INFO_BY_HANDLE_CLASS {
|
||||
typedef enum {
|
||||
FileBasicInfo,
|
||||
FileStandardInfo,
|
||||
FileNameInfo,
|
||||
|
@ -78,20 +78,20 @@ namespace libtorrent
|
|||
FileIoPriorityHintInfo,
|
||||
FileRemoteProtocolInfo,
|
||||
MaximumFileInfoByHandleClass
|
||||
} FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS;
|
||||
} FILE_INFO_BY_HANDLE_CLASS_LOCAL;
|
||||
|
||||
typedef enum _PRIORITY_HINT {
|
||||
typedef enum {
|
||||
IoPriorityHintVeryLow = 0,
|
||||
IoPriorityHintLow,
|
||||
IoPriorityHintNormal,
|
||||
MaximumIoPriorityHintType
|
||||
} PRIORITY_HINT;
|
||||
} PRIORITY_HINT_LOCAL;
|
||||
|
||||
typedef struct _FILE_IO_PRIORITY_HINT_INFO {
|
||||
PRIORITY_HINT PriorityHint;
|
||||
} FILE_IO_PRIORITY_HINT_INFO, *PFILE_IO_PRIORITY_HINT_INFO;
|
||||
typedef struct {
|
||||
PRIORITY_HINT_LOCAL PriorityHint;
|
||||
} FILE_IO_PRIORITY_HINT_INFO_LOCAL;
|
||||
|
||||
typedef BOOL (WINAPI *SetFileInformationByHandle_t)(HANDLE hFile, FILE_INFO_BY_HANDLE_CLASS FileInformationClass, LPVOID lpFileInformation, DWORD dwBufferSize);
|
||||
typedef BOOL (WINAPI *SetFileInformationByHandle_t)(HANDLE hFile, FILE_INFO_BY_HANDLE_CLASS_LOCAL FileInformationClass, LPVOID lpFileInformation, DWORD dwBufferSize);
|
||||
static SetFileInformationByHandle_t SetFileInformationByHandle = NULL;
|
||||
|
||||
static bool failed_kernel_load = false;
|
||||
|
@ -117,7 +117,7 @@ namespace libtorrent
|
|||
|
||||
TORRENT_ASSERT(SetFileInformationByHandle);
|
||||
|
||||
FILE_IO_PRIORITY_HINT_INFO io_hint;
|
||||
FILE_IO_PRIORITY_HINT_INFO_LOCAL io_hint;
|
||||
io_hint.PriorityHint = IoPriorityHintLow;
|
||||
SetFileInformationByHandle(f->native_handle(),
|
||||
FileIoPriorityHintInfo, &io_hint, sizeof(io_hint));
|
||||
|
|
|
@ -490,7 +490,7 @@ observer::~observer()
|
|||
// reported back to the traversal_algorithm as
|
||||
// well. If it wasn't sent, it cannot have been
|
||||
// reported back
|
||||
TORRENT_ASSERT(m_was_sent == bool(flags & flag_done) || m_was_abandoned);
|
||||
TORRENT_ASSERT(m_was_sent == ((flags & flag_done) != 0) || m_was_abandoned);
|
||||
TORRENT_ASSERT(!m_in_constructor);
|
||||
#if TORRENT_USE_ASSERTS
|
||||
TORRENT_ASSERT(m_in_use);
|
||||
|
|
|
@ -187,7 +187,13 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
int next_barrier = 0;
|
||||
if (iovec.empty() || (next_barrier = m_send_barriers.front().enc_handler->encrypt(iovec)))
|
||||
bool process_barrier = iovec.empty();
|
||||
if (!process_barrier)
|
||||
{
|
||||
next_barrier = m_send_barriers.front().enc_handler->encrypt(iovec);
|
||||
process_barrier = (next_barrier != 0);
|
||||
}
|
||||
if (process_barrier)
|
||||
{
|
||||
if (m_send_barriers.front().next != INT_MAX)
|
||||
{
|
||||
|
|
|
@ -87,7 +87,8 @@ namespace libtorrent
|
|||
}
|
||||
else
|
||||
{
|
||||
ret = m_peer_classes.size();
|
||||
TORRENT_ASSERT(m_peer_classes.size() < 0x100);
|
||||
ret = peer_class_t(m_peer_classes.size());
|
||||
m_peer_classes.push_back(boost::shared_ptr<peer_class>());
|
||||
}
|
||||
|
||||
|
|
|
@ -3955,7 +3955,8 @@ namespace libtorrent
|
|||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
if ((handled = (*i)->write_request(r))) break;
|
||||
handled = (*i)->write_request(r);
|
||||
if (handled) break;
|
||||
}
|
||||
if (is_disconnecting()) return;
|
||||
if (!handled)
|
||||
|
|
|
@ -183,7 +183,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(index >= 0 && index < int(m_piece_map.size()));
|
||||
piece_pos const& pp = m_piece_map[index];
|
||||
piece_stats_t ret = {
|
||||
pp.peer_count + m_seeds,
|
||||
int(pp.peer_count + m_seeds),
|
||||
pp.priority(this),
|
||||
pp.have(),
|
||||
pp.downloading()
|
||||
|
@ -458,11 +458,18 @@ namespace libtorrent
|
|||
void piece_picker::check_invariant(torrent const* t) const
|
||||
{
|
||||
#ifndef TORRENT_DEBUG_REFCOUNTS
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4127 ) /* warning C4127: conditional expression is constant */
|
||||
#endif // _MSC_VER
|
||||
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
|
||||
TORRENT_ASSERT(sizeof(piece_pos) == 4);
|
||||
#else
|
||||
TORRENT_ASSERT(sizeof(piece_pos) == 8);
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif // _MSC_VER
|
||||
#endif
|
||||
TORRENT_ASSERT(m_num_have >= 0);
|
||||
TORRENT_ASSERT(m_num_have_filtered >= 0);
|
||||
|
|
|
@ -745,25 +745,25 @@ namespace aux {
|
|||
val = settings.dict_find_int("max_torrent_search_reply");
|
||||
if (val) m_dht_settings.max_torrent_search_reply = val.int_value();
|
||||
val = settings.dict_find_int("restrict_routing_ips");
|
||||
if (val) m_dht_settings.restrict_routing_ips = val.int_value();
|
||||
if (val) m_dht_settings.restrict_routing_ips = (val.int_value() != 0);
|
||||
val = settings.dict_find_int("restrict_search_ips");
|
||||
if (val) m_dht_settings.restrict_search_ips = val.int_value();
|
||||
if (val) m_dht_settings.restrict_search_ips = (val.int_value() != 0);
|
||||
val = settings.dict_find_int("extended_routing_table");
|
||||
if (val) m_dht_settings.extended_routing_table = val.int_value();
|
||||
if (val) m_dht_settings.extended_routing_table = (val.int_value() != 0);
|
||||
val = settings.dict_find_int("aggressive_lookups");
|
||||
if (val) m_dht_settings.aggressive_lookups = val.int_value();
|
||||
if (val) m_dht_settings.aggressive_lookups = (val.int_value() != 0);
|
||||
val = settings.dict_find_int("privacy_lookups");
|
||||
if (val) m_dht_settings.privacy_lookups = val.int_value();
|
||||
if (val) m_dht_settings.privacy_lookups = (val.int_value() != 0);
|
||||
val = settings.dict_find_int("enforce_node_id");
|
||||
if (val) m_dht_settings.enforce_node_id = val.int_value();
|
||||
if (val) m_dht_settings.enforce_node_id = (val.int_value() != 0);
|
||||
val = settings.dict_find_int("ignore_dark_internet");
|
||||
if (val) m_dht_settings.ignore_dark_internet = val.int_value();
|
||||
if (val) m_dht_settings.ignore_dark_internet = (val.int_value() != 0);
|
||||
val = settings.dict_find_int("block_timeout");
|
||||
if (val) m_dht_settings.block_timeout = val.int_value();
|
||||
val = settings.dict_find_int("block_ratelimit");
|
||||
if (val) m_dht_settings.block_ratelimit = val.int_value();
|
||||
val = settings.dict_find_int("read_only");
|
||||
if (val) m_dht_settings.read_only = val.int_value();
|
||||
if (val) m_dht_settings.read_only = (val.int_value() != 0);
|
||||
val = settings.dict_find_int("item_lifetime");
|
||||
if (val) m_dht_settings.item_lifetime = val.int_value();
|
||||
}
|
||||
|
@ -919,7 +919,7 @@ namespace aux {
|
|||
TORRENT_ASSERT(e->first.size() <= max_dht_query_length);
|
||||
if (e->first.size() > max_dht_query_length) continue;
|
||||
extension_dht_query registration;
|
||||
registration.query_len = e->first.size();
|
||||
registration.query_len = uint8_t(e->first.size());
|
||||
std::copy(e->first.begin(), e->first.end(), registration.query.begin());
|
||||
registration.handler = e->second;
|
||||
m_extension_dht_queries.push_back(registration);
|
||||
|
@ -1685,7 +1685,7 @@ namespace aux {
|
|||
#endif
|
||||
|
||||
listen_socket_t ret;
|
||||
ret.ssl = flags & open_ssl_socket;
|
||||
ret.ssl = (flags & open_ssl_socket) != 0;
|
||||
int last_op = 0;
|
||||
listen_failed_alert::socket_type_t const sock_type
|
||||
= (flags & open_ssl_socket)
|
||||
|
@ -3474,7 +3474,7 @@ namespace aux {
|
|||
|
||||
bool session_impl::has_dht() const
|
||||
{
|
||||
return m_dht.get();
|
||||
return m_dht.get() != NULL;
|
||||
}
|
||||
|
||||
void session_impl::prioritize_dht(boost::weak_ptr<torrent> t)
|
||||
|
|
|
@ -418,7 +418,7 @@ namespace libtorrent
|
|||
for (int k = 0; k < sizeof(bool_settings)/sizeof(bool_settings[0]); ++k)
|
||||
{
|
||||
if (key != bool_settings[k].name) continue;
|
||||
pack->set_bool(settings_pack::bool_type_base + k, val.int_value());
|
||||
pack->set_bool(settings_pack::bool_type_base + k, val.int_value() != 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,9 +72,9 @@ namespace libtorrent
|
|||
|
||||
bool is_utp(socket_type const& s)
|
||||
{
|
||||
return s.get<utp_stream>()
|
||||
return s.get<utp_stream>() != NULL
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
|| s.get<ssl_stream<utp_stream> >()
|
||||
|| s.get<ssl_stream<utp_stream> >() != NULL
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
@ -82,9 +82,9 @@ namespace libtorrent
|
|||
#if TORRENT_USE_I2P
|
||||
bool is_i2p(socket_type const& s)
|
||||
{
|
||||
return s.get<i2p_stream>()
|
||||
return s.get<i2p_stream>() != NULL
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
|| s.get<ssl_stream<i2p_stream> >()
|
||||
|| s.get<ssl_stream<i2p_stream> >() != NULL
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
|
|
@ -194,9 +194,11 @@ namespace libtorrent
|
|||
m_buffer.resize(m_user.size() + m_password.size() + 3);
|
||||
p = &m_buffer[0];
|
||||
write_uint8(1, p);
|
||||
write_uint8(m_user.size(), p);
|
||||
TORRENT_ASSERT(m_user.size() < 0x100);
|
||||
write_uint8(uint8_t(m_user.size()), p);
|
||||
write_string(m_user, p);
|
||||
write_uint8(m_password.size(), p);
|
||||
TORRENT_ASSERT(m_password.size() < 0x100);
|
||||
write_uint8(uint8_t(m_password.size()), p);
|
||||
write_string(m_password, p);
|
||||
|
||||
#if defined TORRENT_ASIO_DEBUGGING
|
||||
|
@ -275,8 +277,8 @@ namespace libtorrent
|
|||
if (!m_dst_name.empty())
|
||||
{
|
||||
write_uint8(3, p); // address type
|
||||
TORRENT_ASSERT(m_dst_name.size() <= 255);
|
||||
write_uint8(m_dst_name.size(), p);
|
||||
TORRENT_ASSERT(m_dst_name.size() < 0x100);
|
||||
write_uint8(uint8_t(m_dst_name.size()), p);
|
||||
std::copy(m_dst_name.begin(), m_dst_name.end(), p);
|
||||
p += m_dst_name.size();
|
||||
}
|
||||
|
|
|
@ -518,8 +518,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_WINDOWS
|
||||
// don't do full file allocations on network drives
|
||||
#if TORRENT_USE_WSTRING
|
||||
std::wstring f = convert_to_wstring(m_save_path);
|
||||
int drive_type = GetDriveTypeW(f.c_str());
|
||||
std::wstring file_name = convert_to_wstring(m_save_path);
|
||||
int drive_type = GetDriveTypeW(file_name.c_str());
|
||||
#else
|
||||
int drive_type = GetDriveTypeA(m_save_path.c_str());
|
||||
#endif
|
||||
|
@ -1630,7 +1630,7 @@ namespace libtorrent
|
|||
bool disk_job_fence::has_fence() const
|
||||
{
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
return m_has_fence;
|
||||
return m_has_fence != 0;
|
||||
}
|
||||
|
||||
int disk_job_fence::num_blocked() const
|
||||
|
|
|
@ -58,9 +58,14 @@ namespace libtorrent
|
|||
char *p = &ret.back();
|
||||
*p = '\0';
|
||||
boost::uint64_t un = n;
|
||||
// TODO: warning C4146: unary minus operator applied to unsigned type,
|
||||
// result still unsigned
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4146 ) /* warning C4146: unary minus operator applied to unsigned type */
|
||||
#endif // _MSC_VER
|
||||
if (n < 0) un = -un;
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif // _MSC_VER
|
||||
do {
|
||||
*--p = '0' + un % 10;
|
||||
un /= 10;
|
||||
|
|
|
@ -247,7 +247,7 @@ namespace libtorrent
|
|||
, m_resolve_countries(false)
|
||||
#endif
|
||||
#endif
|
||||
, m_need_save_resume_data(p.flags & add_torrent_params::flag_need_save_resume)
|
||||
, m_need_save_resume_data((p.flags & add_torrent_params::flag_need_save_resume) != 0)
|
||||
, m_seeding_time(0)
|
||||
, m_max_uploads((1<<24)-1)
|
||||
, m_save_resume_flags(0)
|
||||
|
@ -273,7 +273,7 @@ namespace libtorrent
|
|||
, m_num_seeds(0)
|
||||
, m_last_upload((std::numeric_limits<boost::int16_t>::min)())
|
||||
, m_storage_tick(0)
|
||||
, m_auto_managed(p.flags & add_torrent_params::flag_auto_managed)
|
||||
, m_auto_managed((p.flags & add_torrent_params::flag_auto_managed) != 0)
|
||||
, m_current_gauge_state(no_gauge_state)
|
||||
, m_moving_storage(false)
|
||||
, m_inactive(false)
|
||||
|
@ -405,7 +405,7 @@ namespace libtorrent
|
|||
m_seed_mode = (p.flags & add_torrent_params::flag_seed_mode) != 0
|
||||
&& std::count(p.file_priorities.begin(), p.file_priorities.end(), 0) == 0
|
||||
&& std::count(p.piece_priorities.begin(), p.piece_priorities.end(), 0) == 0
|
||||
&& std::count(p.have_pieces.begin(), p.have_pieces.end(), 0) == 0;
|
||||
&& std::count(p.have_pieces.begin(), p.have_pieces.end(), false) == 0;
|
||||
|
||||
m_connections_initialized = true;
|
||||
m_block_size_shift = root2((std::min)(block_size, m_torrent_file->piece_length()));
|
||||
|
@ -9397,7 +9397,7 @@ namespace libtorrent
|
|||
|
||||
if (!b)
|
||||
{
|
||||
do_pause(flags & flag_clear_disk_cache);
|
||||
do_pause((flags & flag_clear_disk_cache) != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -529,8 +529,13 @@ namespace libtorrent
|
|||
size_t ret = 5381;
|
||||
int c;
|
||||
|
||||
while ((c = *s1++))
|
||||
for (;;)
|
||||
{
|
||||
c = *s1++;
|
||||
if (c == 0)
|
||||
break;
|
||||
ret = (ret * 33) ^ to_lower(c);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1287,7 +1292,7 @@ namespace libtorrent
|
|||
m_merkle_tree[0].assign(root_hash.string_ptr());
|
||||
}
|
||||
|
||||
m_private = info.dict_find_int_value("private", 0);
|
||||
m_private = info.dict_find_int_value("private", 0) != 0;
|
||||
|
||||
#ifndef TORRENT_DISABLE_MUTABLE_TORRENTS
|
||||
bdecode_node similar = info.dict_find_list("similar");
|
||||
|
|
|
@ -1183,9 +1183,11 @@ void udp_socket::handshake2(error_code const& e)
|
|||
// start sub-negotiation
|
||||
p = &m_tmp_buf[0];
|
||||
write_uint8(1, p);
|
||||
write_uint8(m_proxy_settings.username.size(), p);
|
||||
TORRENT_ASSERT(m_proxy_settings.username.size() < 0x100);
|
||||
write_uint8(uint8_t(m_proxy_settings.username.size()), p);
|
||||
write_string(m_proxy_settings.username, p);
|
||||
write_uint8(m_proxy_settings.password.size(), p);
|
||||
TORRENT_ASSERT(m_proxy_settings.password.size() < 0x100);
|
||||
write_uint8(uint8_t(m_proxy_settings.password.size()), p);
|
||||
write_string(m_proxy_settings.password, p);
|
||||
TORRENT_ASSERT_VAL(p - m_tmp_buf < int(sizeof(m_tmp_buf)), (p - m_tmp_buf));
|
||||
#if defined TORRENT_ASIO_DEBUGGING
|
||||
|
|
|
@ -166,8 +166,12 @@ namespace libtorrent { namespace
|
|||
// use that port. But only if we didn't connect to the peer.
|
||||
// if we connected to it, use the port we know works
|
||||
torrent_peer *pi = 0;
|
||||
if (!p->is_outgoing() && (pi = peer->peer_info_struct()) && pi->port > 0)
|
||||
remote.port(pi->port);
|
||||
if (!p->is_outgoing())
|
||||
{
|
||||
pi = peer->peer_info_struct();
|
||||
if ((pi != NULL) && (pi->port > 0))
|
||||
remote.port(pi->port);
|
||||
}
|
||||
|
||||
// no supported flags to set yet
|
||||
// 0x01 - peer supports encryption
|
||||
|
@ -578,8 +582,12 @@ namespace libtorrent { namespace
|
|||
tcp::endpoint remote = peer->remote();
|
||||
|
||||
torrent_peer *pi = 0;
|
||||
if (!p->is_outgoing() && (pi = peer->peer_info_struct()) && pi->port > 0)
|
||||
remote.port(pi->port);
|
||||
if (!p->is_outgoing())
|
||||
{
|
||||
pi = peer->peer_info_struct();
|
||||
if ((pi != NULL) && (pi->port > 0))
|
||||
remote.port(pi->port);
|
||||
}
|
||||
|
||||
// i->first was added since the last time
|
||||
if (remote.address().is_v4())
|
||||
|
|
|
@ -2118,7 +2118,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
}
|
||||
else if (ec)
|
||||
{
|
||||
TORRENT_ASSERT(stack_alloced != bool(payload_size));
|
||||
TORRENT_ASSERT(stack_alloced != (payload_size != 0));
|
||||
m_error = ec;
|
||||
set_state(UTP_STATE_ERROR_WAIT);
|
||||
test_socket_state();
|
||||
|
@ -2511,7 +2511,7 @@ bool utp_socket_impl::cancel_handlers(error_code const& ec, bool kill)
|
|||
bool ret = m_read_handler || m_write_handler || m_connect_handler;
|
||||
|
||||
// calling the callbacks with m_userdata being 0 will just crash
|
||||
TORRENT_ASSERT((ret && bool(m_userdata)) || !ret);
|
||||
TORRENT_ASSERT((ret && (m_userdata != NULL)) || !ret);
|
||||
|
||||
bool read = m_read_handler;
|
||||
bool write = m_write_handler;
|
||||
|
|
Loading…
Reference in New Issue