Page MenuHomePhabricator

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

Authored by majcosta on Oct 31 2020, 01:20.

Details

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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable