diff --git a/gtk/OptionsDialog.cc b/gtk/OptionsDialog.cc index 0e0bef436..c7fb4a2a1 100644 --- a/gtk/OptionsDialog.cc +++ b/gtk/OptionsDialog.cc @@ -468,7 +468,7 @@ void TorrentUrlChooserDialog::onOpenURLResponse(int response, Glib::RefPtr(get_data("url-entry")); + auto const* const e = static_cast(get_data("url-entry")); auto const url = gtr_str_strip(e->get_text()); if (url.empty()) diff --git a/libtransmission/magnet-metainfo.cc b/libtransmission/magnet-metainfo.cc index 5273ddcf4..ae123a5f3 100644 --- a/libtransmission/magnet-metainfo.cc +++ b/libtransmission/magnet-metainfo.cc @@ -215,16 +215,12 @@ bool tr_magnet_metainfo::parseMagnet(std::string_view magnet_link, tr_error** er this->webseed_urls_.emplace_back(url_sv); } } - else if (key == "xt"sv) + else if (auto constexpr ValPrefix = "urn:btih:"sv; key == "xt"sv && tr_strvStartsWith(value, ValPrefix)) { - auto constexpr ValPrefix = "urn:btih:"sv; - if (tr_strvStartsWith(value, ValPrefix)) + if (auto const hash = parseHash(value.substr(std::size(ValPrefix))); hash) { - if (auto const hash = parseHash(value.substr(std::size(ValPrefix))); hash) - { - this->info_hash_ = *hash; - got_hash = true; - } + this->info_hash_ = *hash; + got_hash = true; } } } diff --git a/libtransmission/session.h b/libtransmission/session.h index 72dd83dca..1e01d5702 100644 --- a/libtransmission/session.h +++ b/libtransmission/session.h @@ -233,7 +233,7 @@ public: peer_congestion_algorithm_ = algorithm; } - void setSocketTOS(tr_socket_t sock, tr_address_type type) + void setSocketTOS(tr_socket_t sock, tr_address_type type) const { tr_netSetTOS(sock, peer_socket_tos_, type); } diff --git a/libtransmission/web-utils.cc b/libtransmission/web-utils.cc index 84b0798a6..45db112b4 100644 --- a/libtransmission/web-utils.cc +++ b/libtransmission/web-utils.cc @@ -315,21 +315,19 @@ std::string_view getSiteName(std::string_view host) } // is it a registered name? - char* lower = nullptr; - if (PSL_SUCCESS == psl_str_to_utf8lower(szhost.c_str(), nullptr, nullptr, &lower)) + if (char* lower = nullptr; psl_str_to_utf8lower(szhost.c_str(), nullptr, nullptr, &lower) == PSL_SUCCESS) { // www.example.com -> example.com - char const* const top = psl_registrable_domain(psl_builtin(), lower); - if (top != nullptr) + if (char const* const top = psl_registrable_domain(psl_builtin(), lower); top != nullptr) { host.remove_prefix(top - lower); } + psl_free_string(lower); } // example.com -> example - auto const dot_pos = host.find('.'); - if (dot_pos != std::string_view::npos) + if (auto const dot_pos = host.find('.'); dot_pos != std::string_view::npos) { host = host.substr(0, dot_pos); } diff --git a/libtransmission/web.cc b/libtransmission/web.cc index 299805168..2bb2649cb 100644 --- a/libtransmission/web.cc +++ b/libtransmission/web.cc @@ -302,7 +302,7 @@ static CURL* createEasy(tr_session* s, struct tr_web* web, struct tr_web_task* t if (web->curl_proxy_ssl_verify) { - if (web->curl_ca_bundle != NULL) + if (web->curl_ca_bundle != nullptr) { curl_easy_setopt(e, CURLOPT_PROXY_CAINFO, web->curl_ca_bundle); } diff --git a/qt/FaviconCache.cc b/qt/FaviconCache.cc index 9a03eea49..64356440c 100644 --- a/qt/FaviconCache.cc +++ b/qt/FaviconCache.cc @@ -129,8 +129,7 @@ void FaviconCache::add(QString const& sitename, QString const& url_str) // Try to download a favicon if we don't have one. // Add a placeholder to prevent repeat downloads. - auto const already_had_it = !pixmaps_.try_emplace(sitename).second; - if (already_had_it) + if (auto const already_had_it = !pixmaps_.try_emplace(sitename).second; already_had_it) { return; } diff --git a/utils/create.cc b/utils/create.cc index 7c9ae5b2b..c5eca082d 100644 --- a/utils/create.cc +++ b/utils/create.cc @@ -226,9 +226,9 @@ int tr_main(int argc, char* argv[]) b, options.outfile.c_str(), std::data(options.trackers), - std::size(options.trackers), + static_cast(std::size(options.trackers)), std::data(options.webseeds), - std::size(options.webseeds), + static_cast(std::size(options.webseeds)), options.comment, options.is_private, options.source); diff --git a/web/src/torrent.js b/web/src/torrent.js index 1bc915bfc..647b8435e 100644 --- a/web/src/torrent.js +++ b/web/src/torrent.js @@ -393,17 +393,9 @@ export class Torrent extends EventTarget { // maybe filter by labels... if (pass) { - for (const l of labels) { - let m = false; - for (let j = 0; j < this.getLabels().length; j++) { - if (l === this.getLabels()[j]) { - m = true; - break; - } - } - - pass = pass && m; - } + // pass if this torrent has any of these labels + const torrent_labels = this.getLabels(); + pass = labels.some((label) => torrent_labels.includes(label)); } // maybe filter by tracker...