mirror of
https://github.com/transmission/transmission.git
synced 2026-04-18 07:56:33 +01:00
fix: use static_cast to cast from void pointers (#8724)
This commit is contained in:
@@ -599,7 +599,7 @@ void tr_peerIo::write_bytes(void const* bytes, size_t n_bytes, bool is_piece_dat
|
|||||||
outbuf_info_.emplace_back(n_bytes, is_piece_data);
|
outbuf_info_.emplace_back(n_bytes, is_piece_data);
|
||||||
|
|
||||||
auto [resbuf, reslen] = outbuf_.reserve_space(n_bytes);
|
auto [resbuf, reslen] = outbuf_.reserve_space(n_bytes);
|
||||||
filter_.encrypt(reinterpret_cast<std::byte const*>(bytes), n_bytes, resbuf);
|
filter_.encrypt(static_cast<std::byte const*>(bytes), n_bytes, resbuf);
|
||||||
outbuf_.commit_space(n_bytes);
|
outbuf_.commit_space(n_bytes);
|
||||||
|
|
||||||
flush_outbuf_soon();
|
flush_outbuf_soon();
|
||||||
@@ -618,7 +618,7 @@ size_t tr_peerIo::get_write_buffer_space(uint64_t now) const noexcept
|
|||||||
|
|
||||||
void tr_peerIo::read_bytes(void* bytes, size_t n_bytes)
|
void tr_peerIo::read_bytes(void* bytes, size_t n_bytes)
|
||||||
{
|
{
|
||||||
auto walk = reinterpret_cast<std::byte*>(bytes);
|
auto walk = static_cast<std::byte*>(bytes);
|
||||||
n_bytes = std::min(n_bytes, std::size(inbuf_));
|
n_bytes = std::min(n_bytes, std::size(inbuf_));
|
||||||
if (n_decrypt_remain_)
|
if (n_decrypt_remain_)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ bool tr_metadata_download::set_metadata_piece(int64_t const piece, void const* c
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto const offset = piece * MetadataPieceSize;
|
auto const offset = piece * MetadataPieceSize;
|
||||||
std::copy_n(reinterpret_cast<char const*>(data), len, std::begin(metadata_) + offset);
|
std::copy_n(static_cast<char const*>(data), len, std::begin(metadata_) + offset);
|
||||||
|
|
||||||
needed.erase(iter);
|
needed.erase(iter);
|
||||||
tr_logAddDebugMagnet(this, fmt::format("saving metainfo piece {}... {} remain", piece, std::size(needed)));
|
tr_logAddDebugMagnet(this, fmt::format("saving metainfo piece {}... {} remain", piece, std::size(needed)));
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
for (size_t i = 0, j = 0; i < 256; ++i)
|
for (size_t i = 0, j = 0; i < 256; ++i)
|
||||||
{
|
{
|
||||||
j = static_cast<uint8_t>(j + s_[i] + reinterpret_cast<uint8_t const*>(key)[i % key_length]);
|
j = static_cast<uint8_t>(j + s_[i] + static_cast<uint8_t const*>(key)[i % key_length]);
|
||||||
arc4_swap(i, j);
|
arc4_swap(i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
void add(void const* span_begin, size_t span_len)
|
void add(void const* span_begin, size_t span_len)
|
||||||
{
|
{
|
||||||
auto [buf, buflen] = reserve_space(span_len);
|
auto [buf, buflen] = reserve_space(span_len);
|
||||||
std::copy_n(reinterpret_cast<value_type const*>(span_begin), span_len, buf);
|
std::copy_n(static_cast<value_type const*>(span_begin), span_len, buf);
|
||||||
commit_space(span_len);
|
commit_space(span_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ extern "C"
|
|||||||
void const* v3,
|
void const* v3,
|
||||||
int len3)
|
int len3)
|
||||||
{
|
{
|
||||||
auto* setme = reinterpret_cast<std::byte*>(hash_return);
|
auto* setme = static_cast<std::byte*>(hash_return);
|
||||||
std::fill_n(static_cast<char*>(hash_return), hash_size, '\0');
|
std::fill_n(static_cast<char*>(hash_return), hash_size, '\0');
|
||||||
|
|
||||||
auto const sv1 = std::string_view{ static_cast<char const*>(v1), size_t(len1) };
|
auto const sv1 = std::string_view{ static_cast<char const*>(v1), size_t(len1) };
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] static auto make_raw(void const* value, size_t n_bytes)
|
[[nodiscard]] static auto make_raw(void const* value, size_t n_bytes)
|
||||||
{
|
{
|
||||||
return tr_variant{ std::string_view{ reinterpret_cast<char const*>(value), n_bytes } };
|
return tr_variant{ std::string_view{ static_cast<char const*>(value), n_bytes } };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename CharSpan>
|
template<typename CharSpan>
|
||||||
|
|||||||
Reference in New Issue
Block a user