Skip to content

Commit c0ae864

Browse files
committed
Merge #11577: Fix warnings (-Wsign-compare) when building with 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
2 parents f3c7062 + 6eddd43 commit c0ae864

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/addrman.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ int CAddrMan::Check_()
387387
std::set<int> setTried;
388388
std::map<int, int> mapNew;
389389

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

393393
for (const auto& entry : mapInfo) {
@@ -408,17 +408,17 @@ int CAddrMan::Check_()
408408
}
409409
if (mapAddr[info] != n)
410410
return -5;
411-
if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
411+
if (info.nRandomPos < 0 || (size_t)info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
412412
return -14;
413413
if (info.nLastTry < 0)
414414
return -6;
415415
if (info.nLastSuccess < 0)
416416
return -8;
417417
}
418418

419-
if (setTried.size() != nTried)
419+
if (setTried.size() != (size_t)nTried)
420420
return -9;
421-
if (mapNew.size() != nNew)
421+
if (mapNew.size() != (size_t)nNew)
422422
return -10;
423423

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

0 commit comments

Comments
 (0)