diff --git a/gtk/Session.cc b/gtk/Session.cc index 92bef94ad..36fdb1ed7 100644 --- a/gtk/Session.cc +++ b/gtk/Session.cc @@ -645,7 +645,7 @@ void Session::Impl::on_torrent_metadata_changed(tr_torrent* raw_torrent) [this, core = get_core_ptr(), torrent_id = tr_torrentId(raw_torrent)]() { /* update the torrent's collated name */ - if (auto const [torrent, position] = find_torrent_by_id(torrent_id); torrent != nullptr) + if (auto const& [torrent, position] = find_torrent_by_id(torrent_id); torrent) { torrent->update(); } @@ -912,7 +912,7 @@ void Session::Impl::torrents_added() void Session::torrent_changed(tr_torrent_id_t id) { - if (auto const [torrent, position] = impl_->find_torrent_by_id(id); torrent != nullptr) + if (auto const& [torrent, position] = impl_->find_torrent_by_id(id); torrent) { torrent->update(); } @@ -920,7 +920,7 @@ void Session::torrent_changed(tr_torrent_id_t id) void Session::remove_torrent(tr_torrent_id_t id, bool delete_files) { - if (auto const [torrent, position] = impl_->find_torrent_by_id(id); torrent != nullptr) + if (auto const& [torrent, position] = impl_->find_torrent_by_id(id); torrent) { /* remove from the gui */ impl_->get_raw_model()->remove(position); diff --git a/libtransmission/peer-msgs.cc b/libtransmission/peer-msgs.cc index 8edef65f5..7a2d711d6 100644 --- a/libtransmission/peer-msgs.cc +++ b/libtransmission/peer-msgs.cc @@ -254,7 +254,7 @@ void updateDesiredRequestCount(tr_peerMsgsImpl* msgs); #define myLogMacro(msgs, level, text) \ do \ { \ - if (true || tr_logLevelIsActive(level)) \ + if (tr_logLevelIsActive(level)) \ { \ tr_logAddMessage( \ __FILE__, \ diff --git a/libtransmission/tr-buffer.h b/libtransmission/tr-buffer.h index d998492ea..43578a6f4 100644 --- a/libtransmission/tr-buffer.h +++ b/libtransmission/tr-buffer.h @@ -378,7 +378,7 @@ public: } template - void insert(Iterator iter, T const* const begin, T const* const end) + void insert([[maybe_unused]] Iterator iter, T const* const begin, T const* const end) { TR_ASSERT(iter == this->end()); // tr_buffer only supports appending evbuffer_add(buf_.get(), begin, end - begin); diff --git a/libtransmission/tr-dht.cc b/libtransmission/tr-dht.cc index c9a844033..ea7b52b5c 100644 --- a/libtransmission/tr-dht.cc +++ b/libtransmission/tr-dht.cc @@ -379,11 +379,11 @@ private: static auto remove_bad_pex(std::vector&& pex) { - static constexpr auto IsBadPex = [](tr_pex const& pex) + static constexpr auto IsBadPex = [](tr_pex const& candidate) { // paper over a bug in some DHT implementation that gives port 1. // Xref: https://github.com/transmission/transmission/issues/527 - return pex.port.host() == 1; + return candidate.port == tr_port::fromHost(1); }; pex.erase(std::remove_if(std::begin(pex), std::end(pex), IsBadPex), std::end(pex)); diff --git a/qt/DetailsDialog.cc b/qt/DetailsDialog.cc index 99d74f156..33f71e6b5 100644 --- a/qt/DetailsDialog.cc +++ b/qt/DetailsDialog.cc @@ -1311,7 +1311,7 @@ void DetailsDialog::onIdleModeChanged(int index) void DetailsDialog::onIdleLimitChanged() { //: Spin box format, "Stop seeding if idle for: [ 5 minutes ]" - auto const units_format = QT_TRANSLATE_N_NOOP("DetailsDialog", "%1 minute(s)"); + auto const* const units_format = QT_TRANSLATE_N_NOOP("DetailsDialog", "%1 minute(s)"); auto const placeholder = QStringLiteral("%1"); Utils::updateSpinBoxFormat(ui_.idleSpin, "DetailsDialog", units_format, placeholder); } diff --git a/qt/Filters.h b/qt/Filters.h index 3313055b9..e47eed30b 100644 --- a/qt/Filters.h +++ b/qt/Filters.h @@ -37,12 +37,13 @@ public: /* The Torrent properties that can affect this filter. When one of these changes, it's time to refilter. */ - static Torrent::fields_t constexpr TorrentFields = // - (uint64_t(1) << Torrent::ERROR) | // - (uint64_t(1) << Torrent::IS_FINISHED) | // - (uint64_t(1) << Torrent::PEERS_GETTING_FROM_US) | // - (uint64_t(1) << Torrent::PEERS_SENDING_TO_US) | // - (uint64_t(1) << Torrent::STATUS); + static constexpr auto TorrentFields = Torrent::fields_t{ + (uint64_t{ 1 } << Torrent::TORRENT_ERROR) | // + (uint64_t{ 1 } << Torrent::IS_FINISHED) | // + (uint64_t{ 1 } << Torrent::PEERS_GETTING_FROM_US) | // + (uint64_t{ 1 } << Torrent::PEERS_SENDING_TO_US) | // + (uint64_t{ 1 } << Torrent::STATUS) // + }; static bool test(Torrent const& tor, int mode); diff --git a/qt/PrefsDialog.cc b/qt/PrefsDialog.cc index 4065c14a2..996b4c78e 100644 --- a/qt/PrefsDialog.cc +++ b/qt/PrefsDialog.cc @@ -550,7 +550,7 @@ void PrefsDialog::initPrivacyTab() void PrefsDialog::onIdleLimitChanged() { //: Spin box format, "Stop seeding if idle for: [ 5 minutes ]" - auto const units_format = QT_TRANSLATE_N_NOOP("PrefsDialog", "%1 minute(s)"); + auto const* const units_format = QT_TRANSLATE_N_NOOP("PrefsDialog", "%1 minute(s)"); auto const placeholder = QStringLiteral("%1"); Utils::updateSpinBoxFormat(ui_.idleLimitSpin, "PrefsDialog", units_format, placeholder); } @@ -576,7 +576,7 @@ void PrefsDialog::initSeedingTab() void PrefsDialog::onQueueStalledMinutesChanged() { //: Spin box format, "Download is inactive if data sharing stopped: [ 5 minutes ago ]" - auto const units_format = QT_TRANSLATE_N_NOOP("PrefsDialog", "%1 minute(s) ago"); + auto const* const units_format = QT_TRANSLATE_N_NOOP("PrefsDialog", "%1 minute(s) ago"); auto const placeholder = QStringLiteral("%1"); Utils::updateSpinBoxFormat(ui_.queueStalledMinutesSpin, "PrefsDialog", units_format, placeholder); } diff --git a/qt/Torrent.cc b/qt/Torrent.cc index 78fe3d081..e959bbe8a 100644 --- a/qt/Torrent.cc +++ b/qt/Torrent.cc @@ -210,7 +210,7 @@ Torrent::fields_t Torrent::update(tr_quark const* keys, tr_variant const* const* HANDLE_KEY(downloadLimited, download_limited, DOWNLOAD_LIMITED) HANDLE_KEY(downloadedEver, downloaded_ever, DOWNLOADED_EVER) HANDLE_KEY(editDate, edit_date, EDIT_DATE) - HANDLE_KEY(error, error, ERROR) + HANDLE_KEY(error, error, TORRENT_ERROR) HANDLE_KEY(eta, eta, ETA) HANDLE_KEY(fileStats, files, FILES) HANDLE_KEY(files, files, FILES) @@ -269,7 +269,7 @@ Torrent::fields_t Torrent::update(tr_quark const* keys, tr_variant const* const* HANDLE_KEY(comment, comment, COMMENT) HANDLE_KEY(creator, creator, CREATOR) HANDLE_KEY(downloadDir, download_dir, DOWNLOAD_DIR) - HANDLE_KEY(errorString, error_string, ERROR_STRING) + HANDLE_KEY(errorString, error_string, TORRENT_ERROR_STRING) #undef HANDLE_KEY default: diff --git a/qt/Torrent.h b/qt/Torrent.h index affbcd580..ebc795678 100644 --- a/qt/Torrent.h +++ b/qt/Torrent.h @@ -27,10 +27,6 @@ #include "IconCache.h" #include "Speed.h" -#ifdef ERROR -#undef ERROR -#endif - class QPixmap; class Prefs; @@ -572,8 +568,8 @@ public: DOWNLOAD_LIMITED, DOWNLOAD_SPEED, EDIT_DATE, - ERROR, - ERROR_STRING, + TORRENT_ERROR, + TORRENT_ERROR_STRING, ETA, FAILED_EVER, FILE_COUNT,