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 committed by GitHub
parent d4e500245b
commit a8e01ac38d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 24 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

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

View File

@ -378,7 +378,7 @@ public:
}
template<typename T>
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);

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

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

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

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

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,