mirror of
https://github.com/transmission/transmission
synced 2025-02-22 14:10:34 +00:00
fix: sonarcloud (#2227)
* fix: sonarcloud useless-sequence-of-pointer-operators warning
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AXzyMRYbK9dvryvWm8XC\&open\=AXzyMRYbK9dvryvWm8XC
* fix: sonarcloud unused-function warning
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06Stxd1usi2gyYkPTE\&open\=AX06Stxd1usi2gyYkPTE
* fix: sonarcloud init-statement warning
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AXzyMRABK9dvryvWm8Wv\&open\=AXzyMRABK9dvryvWm8Wv
* fix: sonarcloud assignment-in-expression warning
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AXztC8rqIH_lVCrUGWcX\&open\=AXztC8rqIH_lVCrUGWcX
* fix: sonarcloud use-init-statement warning
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AXy-sssdW63O2GMuTBKY\&open\=AXy-sssdW63O2GMuTBKY
* fix: replace-redundant-type-with-auto warning
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AXy-sssdW63O2GMuTBKZ\&open\=AXy-sssdW63O2GMuTBKZ
* fix: use-init-statement
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AXzOK_MX7S1ht0f4sjIh\&open\=AXzOK_MX7S1ht0f4sjIh
* fix: use-structured-binding-declaration warning
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06Stxd1usi2gyYkPTK\&open\=AX06Stxd1usi2gyYkPTK
* fix: use-init-statement
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06Stxd1usi2gyYkPTL\&open\=AX06Stxd1usi2gyYkPTL
* fix: use-structured-binding-declaration warning
Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06Stxd1usi2gyYkPTP\&open\=AX06Stxd1usi2gyYkPTP
* fixup! fix: use-structured-binding-declaration warning
* Revert "fix: sonarcloud useless-sequence-of-pointer-operators warning"
This reverts commit 26c99e75c6
.
cannot convert from 'const _InIt' to 'const rpc_method *'
This commit is contained in:
parent
72cae4996f
commit
74f367c150
6 changed files with 21 additions and 26 deletions
|
@ -417,8 +417,7 @@ static void on_scrape_done(
|
|||
|
||||
if (variant_loaded)
|
||||
{
|
||||
auto sv = std::string_view{};
|
||||
if (tr_variantDictFindStrView(&top, TR_KEY_failure_reason, &sv))
|
||||
if (auto sv = std::string_view{}; tr_variantDictFindStrView(&top, TR_KEY_failure_reason, &sv))
|
||||
{
|
||||
response->errmsg = sv;
|
||||
}
|
||||
|
|
|
@ -1527,7 +1527,8 @@ static void multiscrape(tr_announcer* announcer, std::vector<tr_tier*> const& ti
|
|||
continue;
|
||||
}
|
||||
|
||||
req->info_hash[req->info_hash_count++] = tr_torrentInfoHash(tier->tor);
|
||||
req->info_hash[req->info_hash_count] = tr_torrentInfoHash(tier->tor);
|
||||
++req->info_hash_count;
|
||||
tier->isScraping = true;
|
||||
tier->lastScrapeStartTime = now;
|
||||
found = true;
|
||||
|
@ -1540,7 +1541,8 @@ static void multiscrape(tr_announcer* announcer, std::vector<tr_tier*> const& ti
|
|||
req->scrape_url = scrape_info->scrape_url;
|
||||
tier_build_log_name(tier, req->log_name, sizeof(req->log_name));
|
||||
|
||||
req->info_hash[req->info_hash_count++] = tr_torrentInfoHash(tier->tor);
|
||||
req->info_hash[req->info_hash_count] = tr_torrentInfoHash(tier->tor);
|
||||
++req->info_hash_count;
|
||||
tier->isScraping = true;
|
||||
tier->lastScrapeStartTime = now;
|
||||
}
|
||||
|
|
|
@ -800,8 +800,8 @@ static ReadState readCryptoProvide(tr_handshake* handshake, struct evbuffer* inb
|
|||
obfuscatedTorrentHash[i] = req2[i] ^ req3[i];
|
||||
}
|
||||
|
||||
tr_torrent const* const tor = tr_torrentFindFromObfuscatedHash(handshake->session, obfuscatedTorrentHash);
|
||||
if (tor != nullptr)
|
||||
if (tr_torrent const* const tor = tr_torrentFindFromObfuscatedHash(handshake->session, obfuscatedTorrentHash);
|
||||
tor != nullptr)
|
||||
{
|
||||
bool const clientIsSeed = tr_torrentIsSeed(tor);
|
||||
bool const peerIsSeed = tr_peerMgrPeerIsSeed(tor, tr_peerIoGetAddress(handshake->io, nullptr));
|
||||
|
@ -848,7 +848,7 @@ static ReadState readPadC(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
}
|
||||
|
||||
/* read the throwaway padc */
|
||||
char* const padc = tr_new(char, handshake->pad_c_len);
|
||||
auto* const padc = tr_new(char, handshake->pad_c_len);
|
||||
tr_peerIoReadBytes(handshake->io, inbuf, padc, handshake->pad_c_len);
|
||||
tr_free(padc);
|
||||
|
||||
|
|
|
@ -269,8 +269,8 @@ static std::optional<tr_sha1_digest_t> recalculateHash(tr_torrent* tor, tr_piece
|
|||
while (bytes_left != 0)
|
||||
{
|
||||
size_t const len = std::min(bytes_left, std::size(buffer));
|
||||
auto const success = tr_cacheReadBlock(tor->session->cache, tor, piece, offset, len, std::data(buffer)) == 0;
|
||||
if (!success)
|
||||
if (auto const success = tr_cacheReadBlock(tor->session->cache, tor, piece, offset, len, std::data(buffer)) == 0;
|
||||
!success)
|
||||
{
|
||||
tr_sha1_final(sha, nullptr);
|
||||
return {};
|
||||
|
|
|
@ -123,10 +123,10 @@ std::string tr_magnet_metainfo::magnet() const
|
|||
tr_http_escape(s, name, true);
|
||||
}
|
||||
|
||||
for (auto const& it : trackers)
|
||||
for (auto const& [tier, tracker] : trackers)
|
||||
{
|
||||
s += "&tr="sv;
|
||||
tr_http_escape(s, tr_quark_get_string_view(it.second.announce_url), true);
|
||||
tr_http_escape(s, tr_quark_get_string_view(tracker.announce_url), true);
|
||||
}
|
||||
|
||||
for (auto const& webseed : webseed_urls)
|
||||
|
@ -268,9 +268,9 @@ void tr_magnet_metainfo::toVariant(tr_variant* top) const
|
|||
else
|
||||
{
|
||||
auto* list = tr_variantDictAddList(top, TR_KEY_announce_list, n);
|
||||
for (auto const& pair : this->trackers)
|
||||
for (auto const& [tier, tracker] : this->trackers)
|
||||
{
|
||||
tr_variantListAddStr(tr_variantListAddList(list, 1), tr_quark_get_string_view(pair.second.announce_url));
|
||||
tr_variantListAddStr(tr_variantListAddList(list, 1), tr_quark_get_string_view(tracker.announce_url));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,11 +47,6 @@ struct peer_at
|
|||
{
|
||||
return compare(that) == 0;
|
||||
}
|
||||
|
||||
bool operator<(peer_at const& that) const
|
||||
{
|
||||
return compare(that) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct PeerAtHash
|
||||
|
@ -155,11 +150,11 @@ std::vector<tr_block_index_t> ActiveRequests::remove(tr_peer const* peer)
|
|||
removed.reserve(impl_->blocks_.size());
|
||||
|
||||
auto const key = peer_at{ const_cast<tr_peer*>(peer), 0 };
|
||||
for (auto const& it : impl_->blocks_)
|
||||
for (auto const& [block, peers_at] : impl_->blocks_)
|
||||
{
|
||||
if (it.second.count(key))
|
||||
if (peers_at.count(key))
|
||||
{
|
||||
removed.push_back(it.first);
|
||||
removed.push_back(block);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,8 +171,7 @@ std::vector<tr_peer*> ActiveRequests::remove(tr_block_index_t block)
|
|||
{
|
||||
auto removed = std::vector<tr_peer*>{};
|
||||
|
||||
auto it = impl_->blocks_.find(block);
|
||||
if (it != std::end(impl_->blocks_))
|
||||
if (auto it = impl_->blocks_.find(block); it != std::end(impl_->blocks_))
|
||||
{
|
||||
auto const n = std::size(it->second);
|
||||
removed.resize(n);
|
||||
|
@ -228,13 +222,13 @@ std::vector<std::pair<tr_block_index_t, tr_peer*>> ActiveRequests::sentBefore(ti
|
|||
auto sent_before = std::vector<std::pair<tr_block_index_t, tr_peer*>>{};
|
||||
sent_before.reserve(std::size(impl_->blocks_));
|
||||
|
||||
for (auto& perblock : impl_->blocks_)
|
||||
for (auto& [block, peers_at] : impl_->blocks_)
|
||||
{
|
||||
for (auto& sent : perblock.second)
|
||||
for (auto& sent : peers_at)
|
||||
{
|
||||
if (sent.when < when)
|
||||
{
|
||||
sent_before.emplace_back(perblock.first, sent.peer);
|
||||
sent_before.emplace_back(block, sent.peer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue