]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Elector: make paxos_size() an int 46862/head
authorKamoltat <ksirivad@redhat.com>
Mon, 27 Jun 2022 19:00:09 +0000 (19:00 +0000)
committerKamoltat <ksirivad@redhat.com>
Tue, 28 Jun 2022 13:01:22 +0000 (13:01 +0000)
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 <ksirivad@redhat.com>
src/mon/ElectionLogic.h
src/mon/Elector.cc
src/mon/Elector.h
src/test/mon/test_election.cc

index e2f2db82ac88fe54632e5977b26d65efa5e51e13..ed53e81b6187438e49aa5554ba79a4cedccc46d1 100644 (file)
@@ -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
index 42be292d45146a3f14c1eca3c030243735825ea0..c9f9ed877eda418413d494d172f45fd27b3a45b3 100644 (file)
@@ -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()
index a581daa7ff5cc882ab8b99b1f0630eaf05acecec..309d5a3b43467fac093e3c61b173c7f98345cef3 100644 (file)
@@ -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<int> disallowed_leaders;
   const std::set<int>& get_disallowed_leaders() const { return disallowed_leaders; }
index 188ec3323b9b254f01fdd96b92be611fd79023ef..568cbcc3851ee217614845c06789cb71618e0a5f 100644 (file)
@@ -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<int>& get_disallowed_leaders() const {
     return parent->get_disallowed_leaders();
   }