From e9a7ddf7f941046715e19b29a167efe17170e12e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 5 Jul 2022 18:32:30 -0500 Subject: [PATCH] fix: minor warnings (#3413) * fix: signed-unsigned comparison warning * fix: readability-implicit-bool-conversion warning * fix: signed-unsigned comparison warning --- libtransmission/torrent-magnet.cc | 2 +- tests/libtransmission/blocklist-test.cc | 12 ++++++------ tests/libtransmission/torrent-metainfo-test.cc | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libtransmission/torrent-magnet.cc b/libtransmission/torrent-magnet.cc index c34ec077d..1806b533b 100644 --- a/libtransmission/torrent-magnet.cc +++ b/libtransmission/torrent-magnet.cc @@ -254,7 +254,7 @@ bool tr_torrentUseMetainfoFromFile( // tor should keep this metainfo tor->setMetainfo(*metainfo); - if (tor->incompleteMetadata) + if (tor->incompleteMetadata != nullptr) { incompleteMetadataFree(tor->incompleteMetadata); tor->incompleteMetadata = nullptr; diff --git a/tests/libtransmission/blocklist-test.cc b/tests/libtransmission/blocklist-test.cc index 169cc8803..2065736d1 100644 --- a/tests/libtransmission/blocklist-test.cc +++ b/tests/libtransmission/blocklist-test.cc @@ -73,7 +73,7 @@ TEST_F(BlocklistTest, parsing) createFileWithContents(path, Contents1); tr_sessionReloadBlocklists(session_); EXPECT_TRUE(tr_blocklistExists(session_)); - EXPECT_EQ(5, tr_blocklistGetRuleCount(session_)); + EXPECT_EQ(size_t{ 5 }, tr_blocklistGetRuleCount(session_)); // enable the blocklist EXPECT_FALSE(tr_blocklistIsEnabled(session_)); @@ -108,27 +108,27 @@ TEST_F(BlocklistTest, updating) auto const path = tr_pathbuf{ tr_sessionGetConfigDir(session_), "/blocklists/level1" }; // no blocklist to start with... - EXPECT_EQ(0, tr_blocklistGetRuleCount(session_)); + EXPECT_EQ(0U, tr_blocklistGetRuleCount(session_)); // test that updated source files will get loaded createFileWithContents(path, Contents1); tr_sessionReloadBlocklists(session_); - EXPECT_EQ(5, tr_blocklistGetRuleCount(session_)); + EXPECT_EQ(5U, tr_blocklistGetRuleCount(session_)); // test that updated source files will get loaded createFileWithContents(path, Contents2); tr_sessionReloadBlocklists(session_); - EXPECT_EQ(6, tr_blocklistGetRuleCount(session_)); + EXPECT_EQ(6U, tr_blocklistGetRuleCount(session_)); // test that updated source files will get loaded createFileWithContents(path, Contents1); tr_sessionReloadBlocklists(session_); - EXPECT_EQ(5, tr_blocklistGetRuleCount(session_)); + EXPECT_EQ(5U, tr_blocklistGetRuleCount(session_)); // ensure that new files, if bad, get skipped createFileWithContents(path, "# nothing useful\n"); tr_sessionReloadBlocklists(session_); - EXPECT_EQ(5, tr_blocklistGetRuleCount(session_)); + EXPECT_EQ(5U, tr_blocklistGetRuleCount(session_)); // cleanup } diff --git a/tests/libtransmission/torrent-metainfo-test.cc b/tests/libtransmission/torrent-metainfo-test.cc index fa7043b7b..2253d417c 100644 --- a/tests/libtransmission/torrent-metainfo-test.cc +++ b/tests/libtransmission/torrent-metainfo-test.cc @@ -227,7 +227,7 @@ TEST_F(TorrentMetainfoTest, HoffmanStyleWebseeds) auto const src_filename = tr_pathbuf{ LIBTRANSMISSION_TEST_ASSETS_DIR, "/debian-11.2.0-amd64-DVD-1.iso.torrent"sv }; auto tm = tr_torrent_metainfo{}; EXPECT_TRUE(tm.parseTorrentFile(src_filename)); - EXPECT_EQ(2, tm.webseedCount()); + EXPECT_EQ(size_t{ 2 }, tm.webseedCount()); EXPECT_EQ( "https://cdimage.debian.org/cdimage/release/11.2.0//srv/cdbuilder.debian.org/dst/deb-cd/weekly-builds/amd64/iso-dvd/debian-11.2.0-amd64-DVD-1.iso"sv, tm.webseed(0)); @@ -241,7 +241,7 @@ TEST_F(TorrentMetainfoTest, GetRightStyleWebseedList) auto const src_filename = tr_pathbuf{ LIBTRANSMISSION_TEST_ASSETS_DIR, "/webseed-getright-list.torrent"sv }; auto tm = tr_torrent_metainfo{}; EXPECT_TRUE(tm.parseTorrentFile(src_filename)); - EXPECT_EQ(2, tm.webseedCount()); + EXPECT_EQ(size_t{ 2 }, tm.webseedCount()); EXPECT_EQ("http://www.webseed-one.com/"sv, tm.webseed(0)); EXPECT_EQ("http://webseed-two.com/"sv, tm.webseed(1)); } @@ -251,7 +251,7 @@ TEST_F(TorrentMetainfoTest, GetRightStyleWebseedString) auto const src_filename = tr_pathbuf{ LIBTRANSMISSION_TEST_ASSETS_DIR, "/webseed-getright-string.torrent"sv }; auto tm = tr_torrent_metainfo{}; EXPECT_TRUE(tm.parseTorrentFile(src_filename)); - EXPECT_EQ(1, tm.webseedCount()); + EXPECT_EQ(size_t{ 1 }, tm.webseedCount()); EXPECT_EQ("http://www.webseed-one.com/"sv, tm.webseed(0)); }