Prefer 'unsigned int' for loop index variables tested against ::size()

C++ STL ::size() generally returns unsigned, which implies that "int idx"
style of loop variable will generate a signed-vs-unsigned comparison warning
when testing the loop exit condition "idx < blah.size()"

Update areas of the bitcoin code where loop variables may be more properly and
correctly defined as unsigned.
This commit is contained in:
Jeff Garzik
2012-04-22 13:22:39 -04:00
committed by Jeff Garzik
parent 457661f640
commit faf705a42a
3 changed files with 14 additions and 14 deletions

View File

@@ -222,7 +222,7 @@ public:
if (vch.size() > 4)
vch[4] &= 0x7f;
uint256 n = 0;
for (int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
((unsigned char*)&n)[i] = vch[j];
return n;
}