Project

General

Profile

Cleanup #56581

mon: fix ElectionLogic warnings

Added by Laura Flores over 1 year ago. Updated over 1 year ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
-
% Done:

0%

Tags:
low-hanging-fruit
Backport:
Reviewed:
Affected Versions:
Component(RADOS):
Pull request ID:

Description

Problem: compilation warnings in the ElectionLogic code

../src/mon/ElectionLogic.cc: In member function ‘void ElectionLogic::end_election_period()’:
../src/mon/ElectionLogic.cc:173:23: warning: comparison of integer expressions of different signedness: ‘std::set<int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
       acked_me.size() > (elector->paxos_size() / 2)) {
       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/mon/ElectionLogic.cc: In member function ‘void ElectionLogic::propose_connectivity_handler(int, epoch_t, const ConnectionTracker*)’:
../src/mon/ElectionLogic.cc:338:28: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
     for (unsigned i = 0; i < elector->paxos_size(); ++i) {
                          ~~^~~~~~~~~~~~~~~~~~~~~~~
../src/mon/ElectionLogic.cc: In member function ‘void ElectionLogic::receive_ack(int, epoch_t)’:
../src/mon/ElectionLogic.cc:469:25: warning: comparison of integer expressions of different signedness: ‘std::set<int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
     if (acked_me.size() == elector->paxos_size()) {
         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

How to reproduce:

Build the monitor code by running:

cd ceph/build
ninja mon

You should see this output:

$ ninja mon
[0/1] Re-running CMake...
-- Building with ccache: /usr/bin/ccache, CCACHE_DIR=
 '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--disable-static' '--enable-symbol-hiding' '--enable-ipv6' '--enable-threaded-resolver' '--without-libmetalink' '--with-gssapi' '--with-nghttp2' '--with-ssl' '--with-ca-bundle=/etc/pki/tls/certs/ca-bundle.crt' '--enable-ldap' '--enable-ldaps' '--enable-manual' '--with-brotli' '--with-libidn2' '--with-libpsl' '--with-libssh' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' 'LDFLAGS=-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
-- libcurl is linked with openssl: explicitly setting locks
-- ssl soname: libssl.so.1.1
-- crypto soname: libcrypto.so.1.1
-- BUILDING Boost Libraries at j 1
-- boost will be downloaded...
-- Found nasm: best -- capable of assembling AVX512
-- Found the following ICU libraries:
--   uc (required)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- exclude following files under src: *.js;*.css;.tox;python-common/build;erasure-code/jerasure/jerasure;erasure-code/jerasure/gf-complete;rocksdb;googletest;spdk;xxHash;isa-l;zstd;crypto/isa-l/isa-l_crypto;blkin;rapidjson;dmclock;seastar;fmt;c-ares;spawn;pybind/mgr/rook/rook-client-python;s3select;libkmip;arrow;utf8proc;jaegertracing/opentelemetry-cpp
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lflores/ceph/build
[17/46] 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:734:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
     for (unsigned i = rank_removed + 1; i <= paxos_size() ; ++i) {
                                         ~~^~~~~~~~~~~~~~~
[36/46] Building CXX object src/mon/CMakeFiles/mon.dir/ElectionLogic.cc.o
../src/mon/ElectionLogic.cc: In member function ‘void ElectionLogic::end_election_period()’:
../src/mon/ElectionLogic.cc:173:23: warning: comparison of integer expressions of different signedness: ‘std::set<int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
       acked_me.size() > (elector->paxos_size() / 2)) {
       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/mon/ElectionLogic.cc: In member function ‘void ElectionLogic::propose_connectivity_handler(int, epoch_t, const ConnectionTracker*)’:
../src/mon/ElectionLogic.cc:338:28: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
     for (unsigned i = 0; i < elector->paxos_size(); ++i) {
                          ~~^~~~~~~~~~~~~~~~~~~~~~~
../src/mon/ElectionLogic.cc: In member function ‘void ElectionLogic::receive_ack(int, epoch_t)’:
../src/mon/ElectionLogic.cc:469:25: warning: comparison of integer expressions of different signedness: ‘std::set<int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
     if (acked_me.size() == elector->paxos_size()) {
         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
[46/46] Linking CXX static library lib/libmon.a

The relevant code is located in src/mon/ElectionLogic.cc: https://github.com/ceph/ceph/blob/main/src/mon/ElectionLogic.cc

History

#1 Updated by Laura Flores over 1 year ago

  • Tracker changed from Bug to Cleanup

#2 Updated by Laura Flores over 1 year ago

  • Status changed from New to Fix Under Review
  • Assignee set to Kefu Chai
  • Pull request ID set to 47034

#3 Updated by Kefu Chai over 1 year ago

  • Status changed from Fix Under Review to Resolved

Also available in: Atom PDF