forked from premiere/premiere-libtorrent
fix some PVS studio warnings
This commit is contained in:
parent
818cc1c495
commit
592544f30f
|
@ -681,7 +681,7 @@ struct peer_conn
|
|||
if (corruption_counter == 0)
|
||||
{
|
||||
corruption_counter = 1000;
|
||||
memset(write_buffer, 0, 10);
|
||||
std::memset(write_buffer, 0, 10);
|
||||
}
|
||||
}
|
||||
char* ptr = write_buf_proto;
|
||||
|
@ -1009,7 +1009,7 @@ int main(int argc, char* argv[])
|
|||
, torrent_name, std::strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
size_t ret = fwrite(&buf[0], 1, buf.size(), f);
|
||||
size_t ret = fwrite(buf.data(), 1, buf.size(), f);
|
||||
if (ret != buf.size())
|
||||
{
|
||||
std::fprintf(stderr, "write returned: %d (expected %d)\n", int(ret), int(buf.size()));
|
||||
|
|
|
@ -247,13 +247,13 @@ namespace libtorrent {
|
|||
void set_all() noexcept
|
||||
{
|
||||
if (size() == 0) return;
|
||||
std::memset(buf(), 0xff, std::size_t(num_words() * 4));
|
||||
std::memset(buf(), 0xff, std::size_t(num_words()) * 4);
|
||||
clear_trailing_bits();
|
||||
}
|
||||
void clear_all() noexcept
|
||||
{
|
||||
if (size() == 0) return;
|
||||
std::memset(buf(), 0x00, std::size_t(num_words() * 4));
|
||||
std::memset(buf(), 0x00, std::size_t(num_words()) * 4);
|
||||
}
|
||||
|
||||
// make the bitfield empty, of zero size.
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace libtorrent {
|
|||
{
|
||||
packet* p = static_cast<packet*>(std::malloc(sizeof(packet) + aux::numeric_cast<std::uint16_t>(size)));
|
||||
if (p == nullptr) aux::throw_ex<std::bad_alloc>();
|
||||
new (p) packet();
|
||||
p = new (p) packet();
|
||||
p->allocated = aux::numeric_cast<std::uint16_t>(size);
|
||||
return packet_ptr(p);
|
||||
}
|
||||
|
|
|
@ -384,11 +384,11 @@ void http_connection::start(std::string const& hostname, int port
|
|||
}
|
||||
else
|
||||
#endif
|
||||
m_hostname = hostname;
|
||||
if (ps && ps->proxy_hostnames
|
||||
&& (ps->type == settings_pack::socks5
|
||||
|| ps->type == settings_pack::socks5_pw))
|
||||
{
|
||||
m_hostname = hostname;
|
||||
m_port = std::uint16_t(port);
|
||||
m_endpoints.emplace_back(address(), m_port);
|
||||
connect();
|
||||
|
@ -400,7 +400,6 @@ void http_connection::start(std::string const& hostname, int port
|
|||
, std::bind(&http_connection::on_resolve
|
||||
, me, _1, _2));
|
||||
}
|
||||
m_hostname = hostname;
|
||||
m_port = std::uint16_t(port);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4085,7 +4085,7 @@ namespace libtorrent {
|
|||
if (m_connecting)
|
||||
{
|
||||
m_counters.inc_stats_counter(counters::num_peers_half_open, -1);
|
||||
if (t) t->dec_num_connecting(m_peer_info);
|
||||
if (t && m_peer_info) t->dec_num_connecting(m_peer_info);
|
||||
m_connecting = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace aux {
|
|||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wformat-nonliteral"
|
||||
#endif
|
||||
int const ret = std::vsnprintf(m_storage.data() + pos, static_cast<std::size_t>(len + 1), fmt, args);
|
||||
int const ret = std::vsnprintf(m_storage.data() + pos, static_cast<std::size_t>(len) + 1, fmt, args);
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
|
|
@ -1284,7 +1284,7 @@ void upnp::on_upnp_get_ip_address_response(error_code const& e
|
|||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (s.error_code != -1)
|
||||
{
|
||||
log("error while getting external IP address, code: %u", s.error_code);
|
||||
log("error while getting external IP address, code: %d", s.error_code);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1386,8 +1386,7 @@ void upnp::on_upnp_map_response(error_code const& e
|
|||
if (s.error_code != -1)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log("error while adding port map, code: %u"
|
||||
, s.error_code);
|
||||
log("error while adding port map, code: %d", s.error_code);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue