fix: some sonarcloud warnings (#2189)
* fix: pass-large-object-by-reference-to-const warning Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0Gz8ze7dx8i2lkKEvq\&open\=AX0Gz8ze7dx8i2lkKEvq * fix: use-std-array-instead-of-C-array warning Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5B-\&open\=AX0L8qcgUnpKTxYiu5B- * fix: extract-assignment-from-expression Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5CH\&open\=AX0L8qcgUnpKTxYiu5CH * fix: move-include-directives-to-top Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qlYUnpKTxYiu5CQ\&open\=AX0L8qlYUnpKTxYiu5CQ * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5CK\&open\=AX0L8qcgUnpKTxYiu5CK * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlmBwxvzFbF6whWh\&open\=AX0WPlmBwxvzFbF6whWh * fix: ensure-move-constructor-is-noexcept https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlWzwxvzFbF6whWU\&open\=AX0WPlWzwxvzFbF6whWU * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP20jI_aUyxGBxCD\&open\=AX0bZP20jI_aUyxGBxCD * fix: replace-redundant-type-with-auto Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP0rjI_aUyxGBxCB\&open\=AX0bZP0rjI_aUyxGBxCB * fix: make-parameter-const Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0gkQqqPDVGqE4PY-io\&open\=AX0gkQqqPDVGqE4PY-io * fix: use-init-statement https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0rARJbfJ-O-YIDS9xM\&open\=AX0rARJbfJ-O-YIDS9xM * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlmBwxvzFbF6whWh\&open\=AX0WPlmBwxvzFbF6whWh * fix: explicitly-delete-copy-ctor Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0gkQr6PDVGqE4PY-i4\&open\=AX0gkQr6PDVGqE4PY-i4 * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP9wjI_aUyxGBxCF\&open\=AX0bZP9wjI_aUyxGBxCF
This commit is contained in:
parent
ec94c90da9
commit
f14e741052
|
@ -282,8 +282,7 @@ int tr_main(int argc, char* argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
auto sv = std::string_view{};
|
||||
if (tr_variantDictFindStrView(&settings, TR_KEY_download_dir, &sv))
|
||||
if (auto sv = std::string_view{}; tr_variantDictFindStrView(&settings, TR_KEY_download_dir, &sv))
|
||||
{
|
||||
// tr_sys_path_exists and tr_sys_dir_create need zero-terminated strs
|
||||
auto const sz_download_dir = std::string{ sv };
|
||||
|
|
|
@ -537,7 +537,7 @@ static void publishPeersPex(tr_tier* tier, int seeders, int leechers, tr_pex con
|
|||
|
||||
struct AnnTrackerInfo
|
||||
{
|
||||
AnnTrackerInfo(tr_tracker_info info_in, tr_url_parsed_t url_in)
|
||||
AnnTrackerInfo(tr_tracker_info const& info_in, tr_url_parsed_t const& url_in)
|
||||
: info{ info_in }
|
||||
, url{ url_in }
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
@ -27,7 +28,7 @@ using namespace std::literals;
|
|||
namespace bitzi
|
||||
{
|
||||
|
||||
int constexpr base32Lookup[] = {
|
||||
auto constexpr Base32Lookup = std::array<int, 80>{
|
||||
0xFF, 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, /* '0', '1', '2', '3', '4', '5', '6', '7' */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* '8', '9', ':', ';', '<', '=', '>', '?' */
|
||||
0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, /* '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G' */
|
||||
|
@ -61,7 +62,7 @@ void base32_to_sha1(uint8_t* out, char const* in, size_t const inlen)
|
|||
}
|
||||
|
||||
/* If this digit is not in the table, ignore it */
|
||||
int const digit = base32Lookup[lookup];
|
||||
int const digit = Base32Lookup[lookup];
|
||||
|
||||
if (digit == 0xFF)
|
||||
{
|
||||
|
@ -184,7 +185,8 @@ bool tr_magnet_metainfo::parseMagnet(std::string_view magnet_link, tr_error** er
|
|||
else if (key == "tr"sv || tr_strvStartsWith(key, "tr."sv))
|
||||
{
|
||||
// "tr." explanation @ https://trac.transmissionbt.com/ticket/3341
|
||||
addTracker(tier++, tr_urlPercentDecode(value));
|
||||
addTracker(tier, tr_urlPercentDecode(value));
|
||||
++tier;
|
||||
}
|
||||
else if (key == "ws"sv)
|
||||
{
|
||||
|
@ -235,8 +237,7 @@ bool tr_magnet_metainfo::convertAnnounceToScrape(std::string& out, std::string_v
|
|||
// the scrape convention. If it does, substitute 'scrape' for
|
||||
// 'announce' to find the scrape page.
|
||||
auto constexpr oldval = "/announce"sv;
|
||||
auto pos = in.rfind(oldval.front());
|
||||
if (pos != in.npos && in.find(oldval, pos) == pos)
|
||||
if (auto pos = in.rfind(oldval.front()); pos != in.npos && in.find(oldval, pos) == pos)
|
||||
{
|
||||
auto const prefix = in.substr(0, pos);
|
||||
auto const suffix = in.substr(pos + std::size(oldval));
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
struct tr_variant;
|
||||
|
||||
#include "transmission.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "quark.h"
|
||||
|
||||
struct tr_variant;
|
||||
|
||||
struct tr_magnet_metainfo
|
||||
{
|
||||
bool parseMagnet(std::string_view magnet_link, tr_error** error = nullptr);
|
||||
|
|
|
@ -483,13 +483,10 @@ static char const* tr_metainfoParseImpl(
|
|||
* from the Metainfo file. Note that the value will be a bencoded
|
||||
* dictionary, given the definition of the info key above. */
|
||||
tr_variant* infoDict = nullptr;
|
||||
bool b = tr_variantDictFindDict(meta, TR_KEY_info, &infoDict);
|
||||
|
||||
if (!b)
|
||||
if (bool b = tr_variantDictFindDict(meta, TR_KEY_info, &infoDict); !b)
|
||||
{
|
||||
/* no info dictionary... is this a magnet link? */
|
||||
tr_variant* d = nullptr;
|
||||
if (tr_variantDictFindDict(meta, TR_KEY_magnet_info, &d))
|
||||
if (tr_variant* d = nullptr; tr_variantDictFindDict(meta, TR_KEY_magnet_info, &d))
|
||||
{
|
||||
isMagnet = true;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ struct tr_metainfo_parsed
|
|||
|
||||
tr_metainfo_parsed() = default;
|
||||
|
||||
tr_metainfo_parsed(tr_metainfo_parsed&& that)
|
||||
tr_metainfo_parsed(tr_metainfo_parsed&& that) noexcept
|
||||
{
|
||||
std::swap(this->info, that.info);
|
||||
std::swap(this->pieces, that.pieces);
|
||||
|
|
|
@ -216,8 +216,7 @@ static std::string getblkdev(std::string_view path)
|
|||
{
|
||||
for (;;)
|
||||
{
|
||||
auto const* const device = getdev(path);
|
||||
if (device != nullptr)
|
||||
if (auto const* const device = getdev(path); device != nullptr)
|
||||
{
|
||||
return device;
|
||||
}
|
||||
|
|
|
@ -397,7 +397,7 @@ char const* tr_getDefaultDownloadDir(void)
|
|||
|
||||
/* read in user-dirs.dirs and look for the download dir entry */
|
||||
size_t content_len = 0;
|
||||
char* const content = (char*)tr_loadFile(config_file.c_str(), &content_len, nullptr);
|
||||
auto* const content = (char*)tr_loadFile(config_file.c_str(), &content_len, nullptr);
|
||||
|
||||
if (content != nullptr && content_len > 0)
|
||||
{
|
||||
|
|
|
@ -560,7 +560,7 @@ static bool isHostnameAllowed(tr_rpc_server const* server, struct evhttp_request
|
|||
[&hostname](auto const& str) { return tr_wildmat(hostname.c_str(), str.c_str()); });
|
||||
}
|
||||
|
||||
static bool test_session_id(tr_rpc_server* server, struct evhttp_request* req)
|
||||
static bool test_session_id(tr_rpc_server* server, evhttp_request const* req)
|
||||
{
|
||||
char const* ours = get_current_session_id(server);
|
||||
char const* theirs = evhttp_find_header(req->input_headers, TR_RPC_SESSION_ID_HEADER);
|
||||
|
|
|
@ -35,6 +35,11 @@ public:
|
|||
tr_rpc_server(tr_session* session, tr_variant* settings);
|
||||
~tr_rpc_server();
|
||||
|
||||
tr_rpc_server(tr_rpc_server&) = delete;
|
||||
tr_rpc_server(tr_rpc_server&&) = delete;
|
||||
tr_rpc_server& operator=(tr_rpc_server&) = delete;
|
||||
tr_rpc_server& operator=(tr_rpc_server&&) = delete;
|
||||
|
||||
z_stream stream = {};
|
||||
|
||||
std::list<std::string> hostWhitelist;
|
||||
|
|
|
@ -491,8 +491,7 @@ bool tr_sessionLoadSettings(tr_variant* dict, char const* configDir, char const*
|
|||
auto fileSettings = tr_variant{};
|
||||
auto const filename = tr_strvPath(configDir, "settings.json"sv);
|
||||
auto success = bool{};
|
||||
tr_error* error = nullptr;
|
||||
if (tr_variantFromFile(&fileSettings, TR_VARIANT_FMT_JSON, filename.c_str(), &error))
|
||||
if (tr_error* error = nullptr; tr_variantFromFile(&fileSettings, TR_VARIANT_FMT_JSON, filename.c_str(), &error))
|
||||
{
|
||||
tr_variantMergeDicts(dict, &fileSettings);
|
||||
tr_variantFree(&fileSettings);
|
||||
|
@ -2338,9 +2337,7 @@ static void loadBlocklists(tr_session* session)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto const path = tr_strvPath(dirname, name);
|
||||
|
||||
if (tr_strvEndsWith(path, ".bin"sv))
|
||||
if (auto const path = tr_strvPath(dirname, name); tr_strvEndsWith(path, ".bin"sv))
|
||||
{
|
||||
load = path;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue