From c37b297b252355d2d9277f7aec125f3ae7884866 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 17 Apr 2023 23:11:09 -0500 Subject: [PATCH] fix: minor warnings (#5409) * chore: fix readability-qualified-auto warnings * chore: fix clang-analyzer-core.uninitialized.Branch warning * fix: collision of key 'ERROR' in transmission-qt * chore: silence -Wshadow warning * chore: silence warning C4100: 'iter': unreferenced formal parameter * chore: fix warning C4127: conditional expression is constant warning --- gtk/Session.cc | 6 +++--- libtransmission/tr-dht.cc | 4 ++-- qt/Filters.h | 13 +++++++------ qt/Torrent.cc | 4 ++-- qt/Torrent.h | 8 ++------ 5 files changed, 16 insertions(+), 19 deletions(-) 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/tr-dht.cc b/libtransmission/tr-dht.cc index 3f223b614..3776356ab 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/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/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,