HomePhabricator

[backport#11577] Fix warnings (-Wsign-compare) when building with DEBUG_ADDRMAN

Description

[backport#11577] Fix warnings (-Wsign-compare) when building with DEBUG_ADDRMAN

Summary:
6eddd43 Fix warnings when building with DEBUG_ADDRMAN (practicalswift)

Pull request description:

Fix warnings when building with `DEBUG_ADDRMAN`.

Warnings prior to this commit:

```
addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (vRandom.size() != nTried + nNew)
        ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
        if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
                                   ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (setTried.size() != nTried)
        ~~~~~~~~~~~~~~~ ^  ~~~~~~
addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (mapNew.size() != nNew)
        ~~~~~~~~~~~~~ ^  ~~~~
4 warnings generated.
```

Backport of Core PR11577

Test Plan:
#define DEBUG_ADDRMAN 1 in src/addrman.h

ninja all check

get no warnings

Reviewers: #bitcoin_abc, PiRK

Reviewed By: PiRK

Differential Revision: https://reviews.bitcoinabc.org/D8206

Details

Provenance
Wladimir J. van der Laan <laanwj@gmail.com>Authored on Jan 29 2018, 13:26
majcostaCommitted on Oct 31 2020, 20:12
majcostaPushed on Oct 31 2020, 20:12
Reviewer
PiRK
Differential Revision
D8206: [backport#11577] Fix warnings (-Wsign-compare) when building with DEBUG_ADDRMAN
Parents
rABC01da54bc97c5: [backport#12187] [Docs] Updating benchmarkmarking.md with an updated sampleā€¦
Branches
Unknown
Tags
Unknown