Skip to content

Commit

Permalink
fix: compiler warnings (#3123)
Browse files Browse the repository at this point in the history
* fix: unused function warning tr_rpc_address_is_valid

* fix: unused variable warning old_byte_pop

* fix: method-can-be-made-static warning assertValidRules

* fix: signed-unsigned comparison warning

* fix: invalid case style warning for KBps

* chore: disable warning for static class member varaible
  • Loading branch information
ckerr committed May 23, 2022
1 parent c0bb2d4 commit 67a0784
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions libtransmission/bitfield.cc
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,13 @@ void tr_bitfield::set(size_t nth, bool value)

/* Already tested that val != nth bit so just swap */
auto& byte = flags_[nth >> 3U];
#ifdef TR_ENABLE_ASSERTS
auto const old_byte_pop = doPopcount(byte);
#endif
byte ^= 0x80 >> (nth & 7U);
#ifdef TR_ENABLE_ASSERTS
auto const new_byte_pop = doPopcount(byte);
#endif

if (value)
{
Expand Down
2 changes: 1 addition & 1 deletion libtransmission/blocklist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ size_t BlocklistFile::setContent(char const* filename)
}

#ifdef TR_ENABLE_ASSERTS
void BlocklistFile::assertValidRules(std::vector<IPv4Range>& ranges)
void BlocklistFile::assertValidRules(std::vector<IPv4Range> const& ranges)
{
for (auto const& r : ranges)
{
Expand Down
2 changes: 1 addition & 1 deletion libtransmission/blocklist.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct BlocklistFile

#ifdef TR_ENABLE_ASSERTS
/// @brief Sanity checks: make sure the rules are sorted in ascending order and don't overlap
void assertValidRules(std::vector<IPv4Range>& ranges);
static void assertValidRules(std::vector<IPv4Range> const& ranges);
#endif

bool is_enabled_;
Expand Down
2 changes: 2 additions & 0 deletions libtransmission/rpc-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ struct tr_rpc_address

static int constexpr DeflateLevel = 6; // medium / default

#ifdef TR_ENABLE_ASSERTS
static bool constexpr tr_rpc_address_is_valid(tr_rpc_address const& a)
{
return a.type == TR_RPC_AF_INET || a.type == TR_RPC_AF_INET6 || a.type == TR_RPC_AF_UNIX;
}
#endif

/***
****
Expand Down
1 change: 1 addition & 0 deletions qt/DetailsDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ class PeerItem : public QTreeWidgetItem
****
***/

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
int DetailsDialog::prev_tab_index_ = 0;

DetailsDialog::DetailsDialog(Session& session, Prefs& prefs, TorrentModel const& model, QWidget* parent)
Expand Down
6 changes: 3 additions & 3 deletions qt/MainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ QMenu* MainWindow::createOptionsMenu()

menu->addSeparator();

for (auto const KBps : { 50, 100, 250, 500, 1000, 2500, 5000, 10000 })
for (auto const kps : { 50, 100, 250, 500, 1000, 2500, 5000, 10000 })
{
auto* const action = menu->addAction(Formatter::get().speedToString(Speed::fromKBps(KBps)));
action->setProperty(PrefVariantsKey, QVariantList{ pref, KBps, enabled_pref, true });
auto* const action = menu->addAction(Formatter::get().speedToString(Speed::fromKBps(kps)));
action->setProperty(PrefVariantsKey, QVariantList{ pref, kps, enabled_pref, true });
connect(action, &QAction::triggered, this, qOverload<>(&MainWindow::onSetPrefs));
}
};
Expand Down
2 changes: 1 addition & 1 deletion tests/libtransmission/blocklist-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class BlocklistTest : public SessionTest

TEST_F(BlocklistTest, parsing)
{
EXPECT_EQ(0, tr_blocklistGetRuleCount(session_));
EXPECT_EQ(0U, tr_blocklistGetRuleCount(session_));

// init the blocklist
auto const path = tr_pathbuf{ tr_sessionGetConfigDir(session_), "/blocklists/level1" };
Expand Down

0 comments on commit 67a0784

Please sign in to comment.