X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fmain.cpp;h=7d0ce9869724940ed815616d7d3dbe3e809579c4;hb=refs%2Fpull%2F253%2Fhead;hp=b3c35043bcd25434852c4f268fe35399ad4b57f9;hpb=f9b0c909fcd5c7840dce02568aa4da9078cfb2b3;p=novacoin.git diff --git a/src/main.cpp b/src/main.cpp index b3c3504..7d0ce98 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2675,7 +2675,7 @@ static filesystem::path BlockFilePath(unsigned int nFile) FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode) { - if ((nFile < 1) || (nFile == (unsigned int) -1)) + if ((nFile < 1) || (nFile == std::numeric_limits::max())) return NULL; FILE* file = fopen(BlockFilePath(nFile).string().c_str(), pszMode); if (!file) @@ -2942,7 +2942,7 @@ bool LoadExternalBlockFile(FILE* fileIn) try { CAutoFile blkdat(fileIn, SER_DISK, CLIENT_VERSION); unsigned int nPos = 0; - while (nPos != (unsigned int)-1 && blkdat.good() && !fRequestShutdown) + while (nPos != std::numeric_limits::max() && blkdat.good() && !fRequestShutdown) { unsigned char pchData[65536]; do { @@ -2950,7 +2950,7 @@ bool LoadExternalBlockFile(FILE* fileIn) int nRead = fread(pchData, 1, sizeof(pchData), blkdat); if (nRead <= 8) { - nPos = (unsigned int)-1; + nPos = std::numeric_limits::max(); break; } void* nFind = memchr(pchData, pchMessageStart[0], nRead+1-sizeof(pchMessageStart)); @@ -2966,7 +2966,7 @@ bool LoadExternalBlockFile(FILE* fileIn) else nPos += sizeof(pchData) - sizeof(pchMessageStart) + 1; } while(!fRequestShutdown); - if (nPos == (unsigned int)-1) + if (nPos == std::numeric_limits::max()) break; fseek(blkdat, nPos, SEEK_SET); unsigned int nSize; @@ -3335,7 +3335,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } // find last block in inv vector - unsigned int nLastBlock = (unsigned int)(-1); + unsigned int nLastBlock = std::numeric_limits::max(); for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { if (vInv[vInv.size() - 1 - nInv].type == MSG_BLOCK) { nLastBlock = vInv.size() - 1 - nInv;