run sonarqube with deprecated functions disabled. fix some of its code smells
This commit is contained in:
parent
646581f8a2
commit
7717c02c2f
|
@ -155,7 +155,7 @@ script:
|
||||||
fi'
|
fi'
|
||||||
|
|
||||||
- 'if [ "$sonar_scan" == "1" ]; then
|
- 'if [ "$sonar_scan" == "1" ]; then
|
||||||
build-wrapper-linux-x86-64 --out-dir bw-output bjam -a -j3 optimization=off crypto=$crypto $toolset variant=$variant -l300 &&
|
build-wrapper-linux-x86-64 --out-dir bw-output bjam -a -j3 optimization=off crypto=$crypto deprecated-functions=off $toolset variant=$variant -l300 &&
|
||||||
sonar-scanner -D sonar.login=$SONAR_TOKEN;
|
sonar-scanner -D sonar.login=$SONAR_TOKEN;
|
||||||
fi'
|
fi'
|
||||||
|
|
||||||
|
|
|
@ -485,7 +485,6 @@ namespace aux {
|
||||||
int copy_from_piece(cached_piece_entry* p, disk_io_job* j
|
int copy_from_piece(cached_piece_entry* p, disk_io_job* j
|
||||||
, buffer_allocator_interface& allocator, bool expect_no_fail = false);
|
, buffer_allocator_interface& allocator, bool expect_no_fail = false);
|
||||||
|
|
||||||
void free_piece(cached_piece_entry* p);
|
|
||||||
int drain_piece_bufs(cached_piece_entry& p, std::vector<char*>& buf);
|
int drain_piece_bufs(cached_piece_entry& p, std::vector<char*>& buf);
|
||||||
|
|
||||||
// block container
|
// block container
|
||||||
|
|
|
@ -49,15 +49,15 @@ namespace libtorrent {
|
||||||
{
|
{
|
||||||
m_abort = true;
|
m_abort = true;
|
||||||
|
|
||||||
std::vector<bw_request> tm;
|
std::vector<bw_request> queue;
|
||||||
tm.swap(m_queue);
|
queue.swap(m_queue);
|
||||||
m_queued_bytes = 0;
|
m_queued_bytes = 0;
|
||||||
|
|
||||||
while (!tm.empty())
|
while (!queue.empty())
|
||||||
{
|
{
|
||||||
bw_request& bwr = tm.back();
|
bw_request& bwr = queue.back();
|
||||||
bwr.peer->assign_bandwidth(m_channel, bwr.assigned);
|
bwr.peer->assign_bandwidth(m_channel, bwr.assigned);
|
||||||
tm.pop_back();
|
queue.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ namespace libtorrent {
|
||||||
|
|
||||||
std::vector<bandwidth_channel*> channels;
|
std::vector<bandwidth_channel*> channels;
|
||||||
|
|
||||||
std::vector<bw_request> tm;
|
std::vector<bw_request> queue;
|
||||||
|
|
||||||
for (auto i = m_queue.begin(); i != m_queue.end();)
|
for (auto i = m_queue.begin(); i != m_queue.end();)
|
||||||
{
|
{
|
||||||
|
@ -165,7 +165,7 @@ namespace libtorrent {
|
||||||
}
|
}
|
||||||
|
|
||||||
i->assigned = 0;
|
i->assigned = 0;
|
||||||
tm.push_back(*i);
|
queue.push_back(*i);
|
||||||
i = m_queue.erase(i);
|
i = m_queue.erase(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ namespace libtorrent {
|
||||||
{
|
{
|
||||||
a += i->request_size - i->assigned;
|
a += i->request_size - i->assigned;
|
||||||
TORRENT_ASSERT(i->assigned <= i->request_size);
|
TORRENT_ASSERT(i->assigned <= i->request_size);
|
||||||
tm.push_back(*i);
|
queue.push_back(*i);
|
||||||
i = m_queue.erase(i);
|
i = m_queue.erase(i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -211,11 +211,11 @@ namespace libtorrent {
|
||||||
m_queued_bytes -= a;
|
m_queued_bytes -= a;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!tm.empty())
|
while (!queue.empty())
|
||||||
{
|
{
|
||||||
bw_request& bwr = tm.back();
|
bw_request& bwr = queue.back();
|
||||||
bwr.peer->assign_bandwidth(m_channel, bwr.assigned);
|
bwr.peer->assign_bandwidth(m_channel, bwr.assigned);
|
||||||
tm.pop_back();
|
queue.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1400,56 +1400,6 @@ void block_cache::abort_dirty(cached_piece_entry* pe)
|
||||||
update_cache_state(pe);
|
update_cache_state(pe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// frees all buffers associated with this piece. May only
|
|
||||||
// be called for pieces with a refcount of 0
|
|
||||||
void block_cache::free_piece(cached_piece_entry* pe)
|
|
||||||
{
|
|
||||||
INVARIANT_CHECK;
|
|
||||||
|
|
||||||
TORRENT_PIECE_ASSERT(pe->in_use, pe);
|
|
||||||
|
|
||||||
TORRENT_PIECE_ASSERT(pe->refcount == 0, pe);
|
|
||||||
TORRENT_PIECE_ASSERT(pe->piece_refcount == 0, pe);
|
|
||||||
TORRENT_PIECE_ASSERT(pe->outstanding_read == 0, pe);
|
|
||||||
|
|
||||||
// build a vector of all the buffers we need to free
|
|
||||||
// and free them all in one go
|
|
||||||
TORRENT_ALLOCA(to_delete, char*, pe->blocks_in_piece);
|
|
||||||
int num_to_delete = 0;
|
|
||||||
int removed_clean = 0;
|
|
||||||
for (int i = 0; i < pe->blocks_in_piece; ++i)
|
|
||||||
{
|
|
||||||
if (pe->blocks[i].buf == nullptr) continue;
|
|
||||||
TORRENT_PIECE_ASSERT(pe->blocks[i].pending == false, pe);
|
|
||||||
TORRENT_PIECE_ASSERT(pe->blocks[i].refcount == 0, pe);
|
|
||||||
TORRENT_PIECE_ASSERT(num_to_delete < pe->blocks_in_piece, pe);
|
|
||||||
to_delete[num_to_delete++] = pe->blocks[i].buf;
|
|
||||||
pe->blocks[i].buf = nullptr;
|
|
||||||
TORRENT_PIECE_ASSERT(pe->num_blocks > 0, pe);
|
|
||||||
--pe->num_blocks;
|
|
||||||
if (pe->blocks[i].dirty)
|
|
||||||
{
|
|
||||||
TORRENT_PIECE_ASSERT(m_write_cache_size > 0, pe);
|
|
||||||
--m_write_cache_size;
|
|
||||||
TORRENT_PIECE_ASSERT(pe->num_dirty > 0, pe);
|
|
||||||
--pe->num_dirty;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
++removed_clean;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TORRENT_PIECE_ASSERT(m_read_cache_size >= removed_clean, pe);
|
|
||||||
m_read_cache_size -= removed_clean;
|
|
||||||
if (pe->cache_state == cached_piece_entry::volatile_read_lru)
|
|
||||||
{
|
|
||||||
m_volatile_size -= num_to_delete;
|
|
||||||
}
|
|
||||||
if (num_to_delete) free_multiple_buffers(to_delete.first(num_to_delete));
|
|
||||||
update_cache_state(pe);
|
|
||||||
}
|
|
||||||
|
|
||||||
int block_cache::drain_piece_bufs(cached_piece_entry& p, std::vector<char*>& buf)
|
int block_cache::drain_piece_bufs(cached_piece_entry& p, std::vector<char*>& buf)
|
||||||
{
|
{
|
||||||
int const piece_size = p.storage->files().piece_size(p.piece);
|
int const piece_size = p.storage->files().piece_size(p.piece);
|
||||||
|
|
|
@ -301,7 +301,7 @@ namespace libtorrent {
|
||||||
&& GetLastError() != ERROR_ALREADY_EXISTS)
|
&& GetLastError() != ERROR_ALREADY_EXISTS)
|
||||||
ec.assign(GetLastError(), system_category());
|
ec.assign(GetLastError(), system_category());
|
||||||
#else
|
#else
|
||||||
int ret = ::mkdir(n.c_str(), 0777);
|
int ret = ::mkdir(n.c_str(), S_IRWXU | S_IRGRP | S_IROTH);
|
||||||
if (ret < 0 && errno != EEXIST)
|
if (ret < 0 && errno != EEXIST)
|
||||||
ec.assign(errno, system_category());
|
ec.assign(errno, system_category());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -295,7 +295,7 @@ struct utp_socket_impl
|
||||||
bool test_socket_state();
|
bool test_socket_state();
|
||||||
void maybe_trigger_receive_callback();
|
void maybe_trigger_receive_callback();
|
||||||
void maybe_trigger_send_callback();
|
void maybe_trigger_send_callback();
|
||||||
bool cancel_handlers(error_code const& ec, bool kill);
|
bool cancel_handlers(error_code const& ec, bool shutdown);
|
||||||
bool consume_incoming_data(
|
bool consume_incoming_data(
|
||||||
utp_header const* ph, std::uint8_t const* ptr, int payload_size, time_point now);
|
utp_header const* ph, std::uint8_t const* ptr, int payload_size, time_point now);
|
||||||
void update_mtu_limits();
|
void update_mtu_limits();
|
||||||
|
@ -881,18 +881,18 @@ void utp_stream::on_close_reason(void* self, close_reason_t reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
void utp_stream::on_read(void* self, std::size_t const bytes_transferred
|
void utp_stream::on_read(void* self, std::size_t const bytes_transferred
|
||||||
, error_code const& ec, bool const kill)
|
, error_code const& ec, bool const shutdown)
|
||||||
{
|
{
|
||||||
utp_stream* s = static_cast<utp_stream*>(self);
|
utp_stream* s = static_cast<utp_stream*>(self);
|
||||||
|
|
||||||
UTP_LOGV("%8p: calling read handler read:%d ec:%s kill:%d\n", static_cast<void*>(s->m_impl)
|
UTP_LOGV("%8p: calling read handler read:%d ec:%s shutdown:%d\n", static_cast<void*>(s->m_impl)
|
||||||
, int(bytes_transferred), ec.message().c_str(), kill);
|
, int(bytes_transferred), ec.message().c_str(), shutdown);
|
||||||
|
|
||||||
TORRENT_ASSERT(s->m_read_handler);
|
TORRENT_ASSERT(s->m_read_handler);
|
||||||
TORRENT_ASSERT(bytes_transferred > 0 || ec || s->m_impl->m_null_buffers);
|
TORRENT_ASSERT(bytes_transferred > 0 || ec || s->m_impl->m_null_buffers);
|
||||||
s->m_io_service.post(std::bind<void>(std::move(s->m_read_handler), ec, bytes_transferred));
|
s->m_io_service.post(std::bind<void>(std::move(s->m_read_handler), ec, bytes_transferred));
|
||||||
s->m_read_handler = nullptr;
|
s->m_read_handler = nullptr;
|
||||||
if (kill && s->m_impl)
|
if (shutdown && s->m_impl)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(ec);
|
TORRENT_ASSERT(ec);
|
||||||
detach_utp_impl(s->m_impl);
|
detach_utp_impl(s->m_impl);
|
||||||
|
@ -901,19 +901,19 @@ void utp_stream::on_read(void* self, std::size_t const bytes_transferred
|
||||||
}
|
}
|
||||||
|
|
||||||
void utp_stream::on_write(void* self, std::size_t const bytes_transferred
|
void utp_stream::on_write(void* self, std::size_t const bytes_transferred
|
||||||
, error_code const& ec, bool const kill)
|
, error_code const& ec, bool const shutdown)
|
||||||
{
|
{
|
||||||
utp_stream* s = static_cast<utp_stream*>(self);
|
utp_stream* s = static_cast<utp_stream*>(self);
|
||||||
|
|
||||||
UTP_LOGV("%8p: calling write handler written:%d ec:%s kill:%d\n"
|
UTP_LOGV("%8p: calling write handler written:%d ec:%s shutdown:%d\n"
|
||||||
, static_cast<void*>(s->m_impl)
|
, static_cast<void*>(s->m_impl)
|
||||||
, int(bytes_transferred), ec.message().c_str(), kill);
|
, int(bytes_transferred), ec.message().c_str(), shutdown);
|
||||||
|
|
||||||
TORRENT_ASSERT(s->m_write_handler);
|
TORRENT_ASSERT(s->m_write_handler);
|
||||||
TORRENT_ASSERT(bytes_transferred > 0 || ec);
|
TORRENT_ASSERT(bytes_transferred > 0 || ec);
|
||||||
s->m_io_service.post(std::bind<void>(std::move(s->m_write_handler), ec, bytes_transferred));
|
s->m_io_service.post(std::bind<void>(std::move(s->m_write_handler), ec, bytes_transferred));
|
||||||
s->m_write_handler = nullptr;
|
s->m_write_handler = nullptr;
|
||||||
if (kill && s->m_impl)
|
if (shutdown && s->m_impl)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(ec);
|
TORRENT_ASSERT(ec);
|
||||||
detach_utp_impl(s->m_impl);
|
detach_utp_impl(s->m_impl);
|
||||||
|
@ -921,18 +921,18 @@ void utp_stream::on_write(void* self, std::size_t const bytes_transferred
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void utp_stream::on_connect(void* self, error_code const& ec, bool kill)
|
void utp_stream::on_connect(void* self, error_code const& ec, bool shutdown)
|
||||||
{
|
{
|
||||||
utp_stream* s = static_cast<utp_stream*>(self);
|
utp_stream* s = static_cast<utp_stream*>(self);
|
||||||
TORRENT_ASSERT(s);
|
TORRENT_ASSERT(s);
|
||||||
|
|
||||||
UTP_LOGV("%8p: calling connect handler ec:%s kill:%d\n"
|
UTP_LOGV("%8p: calling connect handler ec:%s shutdown:%d\n"
|
||||||
, static_cast<void*>(s->m_impl), ec.message().c_str(), kill);
|
, static_cast<void*>(s->m_impl), ec.message().c_str(), shutdown);
|
||||||
|
|
||||||
TORRENT_ASSERT(s->m_connect_handler);
|
TORRENT_ASSERT(s->m_connect_handler);
|
||||||
s->m_io_service.post(std::bind<void>(std::move(s->m_connect_handler), ec));
|
s->m_io_service.post(std::bind<void>(std::move(s->m_connect_handler), ec));
|
||||||
s->m_connect_handler = nullptr;
|
s->m_connect_handler = nullptr;
|
||||||
if (kill && s->m_impl)
|
if (shutdown && s->m_impl)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(ec);
|
TORRENT_ASSERT(ec);
|
||||||
detach_utp_impl(s->m_impl);
|
detach_utp_impl(s->m_impl);
|
||||||
|
@ -2396,7 +2396,7 @@ void utp_socket_impl::incoming(std::uint8_t const* buf, int size, packet_ptr p
|
||||||
check_receive_buffers();
|
check_receive_buffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool utp_socket_impl::cancel_handlers(error_code const& ec, bool kill)
|
bool utp_socket_impl::cancel_handlers(error_code const& ec, bool shutdown)
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
@ -2413,9 +2413,9 @@ bool utp_socket_impl::cancel_handlers(error_code const& ec, bool kill)
|
||||||
m_write_handler = false;
|
m_write_handler = false;
|
||||||
m_connect_handler = false;
|
m_connect_handler = false;
|
||||||
|
|
||||||
if (read) utp_stream::on_read(m_userdata, 0, ec, kill);
|
if (read) utp_stream::on_read(m_userdata, 0, ec, shutdown);
|
||||||
if (write) utp_stream::on_write(m_userdata, 0, ec, kill);
|
if (write) utp_stream::on_write(m_userdata, 0, ec, shutdown);
|
||||||
if (connect) utp_stream::on_connect(m_userdata, ec, kill);
|
if (connect) utp_stream::on_connect(m_userdata, ec, shutdown);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue