From f75dfbc055ccf4e43b817ed5aa52898ff680e19e Mon Sep 17 00:00:00 2001 From: Kamoltat Date: Mon, 27 Jun 2022 19:00:09 +0000 Subject: [PATCH] mon/Elector: make paxos_size() an int MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We want to get rid of the warning: ‘int’ and ‘unsigned int’ [-Wsign-compare] if (rank_removed < paxos_size()) { ~~~~~~~~~~~~^~~~~~~~~~~~~ Also, according to google style guide, we should "try to avoid unsigned types and not use an unsigned type merely to assert that a variable is non-negative". https://google.github.io/styleguide/cppguide.html#Integer_Types Fixes: https://tracker.ceph.com/issues/56392 Signed-off-by: Kamoltat --- src/mon/ElectionLogic.h | 2 +- src/mon/Elector.cc | 4 ++-- src/mon/Elector.h | 2 +- src/test/mon/test_election.cc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mon/ElectionLogic.h b/src/mon/ElectionLogic.h index e2f2db82ac88..ed53e81b6187 100644 --- a/src/mon/ElectionLogic.h +++ b/src/mon/ElectionLogic.h @@ -90,7 +90,7 @@ public: * by making a paxos commit, but not by injecting values while * an election is ongoing.) */ - virtual unsigned paxos_size() const = 0; + virtual int paxos_size() const = 0; /** * Retrieve a set of ranks which are not allowed to become the leader. * Like paxos_size(), This set can change between elections, but not diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc index 42be292d4514..c9f9ed877eda 100644 --- a/src/mon/Elector.cc +++ b/src/mon/Elector.cc @@ -130,9 +130,9 @@ bool Elector::ever_participated() const return mon->has_ever_joined; } -unsigned Elector::paxos_size() const +int Elector::paxos_size() const { - return (unsigned)mon->monmap->size(); + return mon->monmap->size(); } void Elector::shutdown() diff --git a/src/mon/Elector.h b/src/mon/Elector.h index a581daa7ff5c..309d5a3b4346 100644 --- a/src/mon/Elector.h +++ b/src/mon/Elector.h @@ -240,7 +240,7 @@ class Elector : public ElectionOwner, RankProvider { /* Retrieve the Monitor::has_ever_joined member */ bool ever_participated() const; /* Retrieve monmap->size() */ - unsigned paxos_size() const; + int paxos_size() const; /* Right now we don't disallow anybody */ std::set disallowed_leaders; const std::set& get_disallowed_leaders() const { return disallowed_leaders; } diff --git a/src/test/mon/test_election.cc b/src/test/mon/test_election.cc index 188ec3323b9b..568cbcc3851e 100644 --- a/src/test/mon/test_election.cc +++ b/src/test/mon/test_election.cc @@ -147,7 +147,7 @@ struct Owner : public ElectionOwner, RankProvider { logic.start(); } bool ever_participated() const { return ever_joined; } - unsigned paxos_size() const { return parent->get_paxos_size(); } + int paxos_size() const { return parent->get_paxos_size(); } const set& get_disallowed_leaders() const { return parent->get_disallowed_leaders(); } -- 2.47.3