Skip to content

Commit

Permalink
Merge bitcoin#11577: Fix warnings (-Wsign-compare) when building with…
Browse files Browse the repository at this point in the history
… DEBUG_ADDRMAN

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.
  ```

Tree-SHA512: 0316faecfe95066d2c9a0b6b3960086e43824f21a67086a895ea45fbce1327f8d6df5945fe923c2dbe4efce430bc1384d515d317c3930d97d24965e507cf734d
  • Loading branch information
laanwj authored and PastaPastaPasta committed Jan 26, 2020
1 parent 94e9944 commit fccf28b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/addrman.cpp
Expand Up @@ -404,7 +404,7 @@ int CAddrMan::Check_()
std::set<int> setTried;
std::map<int, int> mapNew;

if (vRandom.size() != nTried + nNew)
if (vRandom.size() != (size_t)(nTried + nNew))
return -7;

for (std::map<int, CAddrInfo>::iterator it = mapInfo.begin(); it != mapInfo.end(); it++) {
Expand All @@ -425,17 +425,17 @@ int CAddrMan::Check_()
}
if (mapAddr[info] != n)
return -5;
if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
if (info.nRandomPos < 0 || (size_t)info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
return -14;
if (info.nLastTry < 0)
return -6;
if (info.nLastSuccess < 0)
return -8;
}

if (setTried.size() != nTried)
if (setTried.size() != (size_t)nTried)
return -9;
if (mapNew.size() != nNew)
if (mapNew.size() != (size_t)nNew)
return -10;

for (int n = 0; n < ADDRMAN_TRIED_BUCKET_COUNT; n++) {
Expand Down

0 comments on commit fccf28b

Please sign in to comment.