fix some warnings

This commit is contained in:
arvidn 2018-07-17 12:06:20 +02:00 committed by Arvid Norberg
parent f89c27183b
commit 5d3ac8ff5c
5 changed files with 9 additions and 10 deletions

View File

@ -836,7 +836,6 @@ namespace libtorrent
ptr += 20; ptr += 20;
memcpy(ptr, &m_our_peer_id[0], 20); memcpy(ptr, &m_our_peer_id[0], 20);
ptr += 20;
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
{ {

View File

@ -204,7 +204,9 @@ namespace libtorrent
{ {
*i = boost::asio::mutable_buffer(boost::asio::buffer_cast<void*>(*i), to_process); *i = boost::asio::mutable_buffer(boost::asio::buffer_cast<void*>(*i), to_process);
iovec.erase(++i, iovec.end()); iovec.erase(++i, iovec.end());
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
to_process = 0; to_process = 0;
#endif
break; break;
} }
to_process -= boost::asio::buffer_size(*i); to_process -= boost::asio::buffer_size(*i);

View File

@ -147,9 +147,10 @@ namespace libtorrent
char* allocate_string_copy(char const* str) char* allocate_string_copy(char const* str)
{ {
if (str == 0) return 0; if (str == 0) return 0;
char* tmp = static_cast<char*>(std::malloc(std::strlen(str) + 1)); int const len = std::strlen(str) + 1;
if (tmp == 0) return 0; char* tmp = static_cast<char*>(std::malloc(len));
std::strcpy(tmp, str); if (tmp == NULL) return 0;
std::memcpy(tmp, str, len);
return tmp; return tmp;
} }

View File

@ -163,6 +163,7 @@ namespace libtorrent
UTF8 sequence[5]; UTF8 sequence[5];
UTF8* start = sequence; UTF8* start = sequence;
res = ConvertUTF32toUTF8(const_cast<const UTF32**>(&cp), cp + 1, &start, start + 5, lenientConversion); res = ConvertUTF32toUTF8(const_cast<const UTF32**>(&cp), cp + 1, &start, start + 5, lenientConversion);
TORRENT_UNUSED(res);
TORRENT_ASSERT(res == conversionOK); TORRENT_ASSERT(res == conversionOK);
for (int i = 0; i < std::min(5, int(start - sequence)); ++i) for (int i = 0; i < std::min(5, int(start - sequence)); ++i)
@ -722,8 +723,7 @@ namespace libtorrent
} }
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
torrent_info::torrent_info(lazy_entry const& torrent_file, error_code& ec torrent_info::torrent_info(lazy_entry const& torrent_file, error_code& ec, int)
, int flags)
: m_piece_hashes(0) : m_piece_hashes(0)
, m_creation_date(0) , m_creation_date(0)
, m_info_section_size(0) , m_info_section_size(0)
@ -732,7 +732,6 @@ namespace libtorrent
, m_private(false) , m_private(false)
, m_i2p(false) , m_i2p(false)
{ {
TORRENT_UNUSED(flags);
std::pair<char const*, int> buf = torrent_file.data_section(); std::pair<char const*, int> buf = torrent_file.data_section();
bdecode_node e; bdecode_node e;
if (bdecode(buf.first, buf.first + buf.second, e, ec) != 0) if (bdecode(buf.first, buf.first + buf.second, e, ec) != 0)
@ -740,7 +739,7 @@ namespace libtorrent
parse_torrent_file(e, ec, 0); parse_torrent_file(e, ec, 0);
} }
torrent_info::torrent_info(lazy_entry const& torrent_file, int flags) torrent_info::torrent_info(lazy_entry const& torrent_file, int)
: m_piece_hashes(0) : m_piece_hashes(0)
, m_creation_date(0) , m_creation_date(0)
, m_info_section_size(0) , m_info_section_size(0)
@ -749,7 +748,6 @@ namespace libtorrent
, m_private(false) , m_private(false)
, m_i2p(false) , m_i2p(false)
{ {
TORRENT_UNUSED(flags);
std::pair<char const*, int> buf = torrent_file.data_section(); std::pair<char const*, int> buf = torrent_file.data_section();
bdecode_node e; bdecode_node e;
error_code ec; error_code ec;

View File

@ -128,7 +128,6 @@ namespace libtorrent
token = xml_comment; token = xml_comment;
const int name_len = tag_name_end - start - 2; const int name_len = tag_name_end - start - 2;
callback(token, start, name_len, NULL, 0); callback(token, start, name_len, NULL, 0);
tag_end = p - 2;
continue; continue;
} }
else else