]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon&test: resolve warning about inconsistent variable types 54116/head
authorcuiming_yewu <cuiming_yewu@cmss.chinamobile.com>
Fri, 20 Oct 2023 04:59:05 +0000 (12:59 +0800)
committercuiming <cuiming_yewu@cmss.chinamobile.com>
Wed, 3 Jan 2024 02:30:43 +0000 (10:30 +0800)
resolve a warning issue about inconsistent variable types with
Building CXX object src/mon/CMakeFiles/mon.dir/Elector.cc.o
../src/mon/Elector.cc: In member function 'void Elector::
notify_rank_removed(int)':
../src/mon/Elector.cc:765:15: warning: comparison of integer
expressions of different signedness: 'int' and 'unsigned int'
[-Wsign-compare] if (rank_removed < paxos_size()) {
warning:comparison of integer expressions of different
signedness: 'unsigned int' and 'const int'
[-Wsign-compare] if (total < NR_ROUNDS)

Fixes: https://tracker.ceph.com/issues/63917
Signed-off-by: cuiming <cuiming_yewu@cmss.chinamobile.com>
src/mon/Elector.cc
src/test/common/test_fair_mutex.cc

index a7221ebfb196410d04ba1ab223ac88bd43fd298d..5ad30ff225c82cf8f9b1576c3465e395c805b160 100644 (file)
@@ -762,7 +762,7 @@ void Elector::notify_rank_removed(unsigned rank_removed, unsigned new_rank)
      In the case where we are removing the highest rank,
      we erase the removed rank from all sets.
    */
-  if (rank_removed < paxos_size()) {
+  if (std::cmp_less(rank_removed, paxos_size())) {
     for (unsigned i = rank_removed + 1; i <= paxos_size() ; ++i) {
       if (live_pinging.count(i)) {
         dead_pinging.erase(i-1);
index 10ba835a2ddb4b9479e8a152bda258712231c057..4b9997706ba77928076f2e6e1efb87f6928f19d1 100644 (file)
@@ -47,7 +47,7 @@ TEST(FairMutex, fair)
                                        scoreboard.end(),
                                        0);
       for (unsigned score : scoreboard) {
-        if (total < NR_ROUNDS) {
+        if (std::cmp_less(total, NR_ROUNDS)) {
           // not quite statistically significant. to reduce the false positive,
           // just consider it fair
           continue;