fixed signed/unsigned warnings with latest version of Xcode clang (#3032)

This commit is contained in:
Alden Torres 2018-05-16 10:06:33 -04:00 committed by Arvid Norberg
parent a14d595eac
commit 7621be6df1
8 changed files with 11 additions and 11 deletions

View File

@ -170,7 +170,7 @@ namespace libtorrent {
int const cur_size_words = num_words();
if (cur_size_words != new_size_words)
{
aux::unique_ptr<std::uint32_t[]> b(new std::uint32_t[new_size_words + 1]);
aux::unique_ptr<std::uint32_t[]> b(new std::uint32_t[std::size_t(new_size_words + 1)]);
#ifdef BOOST_NO_EXCEPTIONS
if (b == nullptr) std::terminate();
#endif

View File

@ -616,7 +616,7 @@ cached_piece_entry* block_cache::allocate_piece(disk_io_job const* j, std::uint1
pe.expire = aux::time_now();
pe.blocks_in_piece = aux::numeric_cast<std::uint64_t>(blocks_in_piece);
pe.blocks.reset(new (std::nothrow) cached_block_entry[blocks_in_piece]);
pe.blocks.reset(new (std::nothrow) cached_block_entry[std::size_t(blocks_in_piece)]);
if (!pe.blocks) return nullptr;
p = const_cast<cached_piece_entry*>(&*m_pieces.insert(std::move(pe)).first);

View File

@ -112,7 +112,7 @@ namespace {
int const size = int(buf.size());
if (item.size != size)
{
item.value.reset(new char[size]);
item.value.reset(new char[std::size_t(size)]);
item.size = size;
}
std::memcpy(item.value.get(), buf.data(), buf.size());

View File

@ -265,7 +265,7 @@ namespace {
}
else if (int(m_size) == this->capacity())
{
int const capacity = this->capacity() * lazy_entry_grow_factor / 100;
std::size_t const capacity = std::size_t(this->capacity()) * lazy_entry_grow_factor / 100;
auto* tmp = new (std::nothrow) lazy_dict_entry[capacity + 1];
if (tmp == nullptr) return nullptr;
std::move(m_data.dict, m_data.dict + m_size + 1, tmp);
@ -435,7 +435,7 @@ namespace {
}
else if (int(m_size) == this->capacity())
{
int const capacity = this->capacity() * lazy_entry_grow_factor / 100;
std::size_t const capacity = std::size_t(this->capacity()) * lazy_entry_grow_factor / 100;
lazy_entry* tmp = new (std::nothrow) lazy_entry[capacity + 1];
if (tmp == nullptr) return nullptr;
std::move(m_data.list, m_data.list + m_size + 1, tmp);

View File

@ -304,7 +304,7 @@ namespace libtorrent {
open_file(open_mode::read_only, ec);
if (ec) return;
if (!buf) buf.reset(new char[m_piece_size]);
if (!buf) buf.reset(new char[std::size_t(m_piece_size)]);
std::int64_t const slot_offset = std::int64_t(m_header_size)
+ std::int64_t(static_cast<int>(slot)) * m_piece_size;

View File

@ -852,7 +852,7 @@ bool is_downloading_state(int const st)
}
std::shared_ptr<read_piece_struct> rp = std::make_shared<read_piece_struct>();
rp->piece_data.reset(new (std::nothrow) char[piece_size]);
rp->piece_data.reset(new (std::nothrow) char[std::size_t(piece_size)]);
if (!rp->piece_data)
{
m_ses.alerts().emplace_alert<read_piece_alert>(

View File

@ -576,7 +576,7 @@ namespace {
if (m_info_section_size == 0) return;
TORRENT_ASSERT(m_piece_hashes);
m_info_section.reset(new char[m_info_section_size]);
m_info_section.reset(new char[aux::numeric_cast<std::size_t>(m_info_section_size)]);
std::memcpy(m_info_section.get(), t.m_info_section.get(), aux::numeric_cast<std::size_t>(m_info_section_size));
ptrdiff_t offset = m_info_section.get() - t.m_info_section.get();
@ -946,7 +946,7 @@ namespace {
// copy the info section
m_info_section_size = int(section.size());
m_info_section.reset(new char[m_info_section_size]);
m_info_section.reset(new char[aux::numeric_cast<std::size_t>(m_info_section_size)]);
std::memcpy(m_info_section.get(), section.data(), aux::numeric_cast<std::size_t>(m_info_section_size));
TORRENT_ASSERT(section[0] == 'd');
TORRENT_ASSERT(section[aux::numeric_cast<std::size_t>(m_info_section_size - 1)] == 'e');

View File

@ -145,7 +145,7 @@ namespace libtorrent {namespace {
{
if (m_metadata_size > 0 || size <= 0 || size > 4 * 1024 * 1024) return;
m_metadata_size = size;
m_metadata.reset(new char[size]);
m_metadata.reset(new char[std::size_t(size)]);
m_requested_metadata.resize(div_round_up(size, 16 * 1024));
}
@ -550,7 +550,7 @@ namespace libtorrent {namespace {
return false;
}
m_metadata.reset(new char[total_size]);
m_metadata.reset(new char[std::size_t(total_size)]);
m_requested_metadata.resize(div_round_up(total_size, 16 * 1024));
m_metadata_size = total_size;
}