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
This commit is contained in:
Charles Kerr 2023-04-17 23:11:09 -05:00
parent 256fd698d7
commit c37b297b25
5 changed files with 16 additions and 19 deletions

View File

@ -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);

View File

@ -379,11 +379,11 @@ private:
static auto remove_bad_pex(std::vector<tr_pex>&& 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));

View File

@ -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);

View File

@ -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:

View File

@ -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,