X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fserialize.h;h=03187b96b3e956bc7eb61de72efa70f2b35f6ce1;hb=0a18ce8f4cd1a723f50333945d94c84b45c8d56b;hp=f579c5864e97e4b54aa1b7e1a2e6149759c8397b;hpb=532b9005ab4fc02db3db424b4631fe395e0b9071;p=novacoin.git diff --git a/src/serialize.h b/src/serialize.h index f579c58..03187b9 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -58,7 +58,7 @@ enum // modifiers SER_SKIPSIG = (1 << 16), - SER_BLOCKHEADERONLY = (1 << 17), + SER_BLOCKHEADERONLY = (1 << 17) }; @@ -1106,10 +1106,7 @@ public: if (nReadPosNext >= vch.size()) { if (nReadPosNext > vch.size()) - { setstate(std::ios::failbit, "CDataStream::ignore() : end of data"); - nSize = (int)(vch.size() - nReadPos); - } nReadPos = 0; vch.clear(); return (*this); @@ -1334,7 +1331,7 @@ public: int nVersion; CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn) : - src(fileIn), nSrcPos(0), nReadPos(0), nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0), + src(fileIn), nSrcPos(0), nReadPos(0), nReadLimit(std::numeric_limits::max()), nRewind(nRewindIn), vchBuf(nBufSize, 0), state(0), exceptmask(std::ios_base::badbit | std::ios_base::failbit), nType(nTypeIn), nVersion(nVersionIn) { } @@ -1362,7 +1359,7 @@ public: if (nNow + pos > vchBuf.size()) nNow = vchBuf.size() - pos; if (nNow + nReadPos > nSrcPos) - nNow = nSrcPos - nReadPos; + nNow = (size_t)(nSrcPos - nReadPos); memcpy(pch, &vchBuf[pos], nNow); nReadPos += nNow; pch += nNow; @@ -1405,7 +1402,7 @@ public: // prevent reading beyond a certain position // no argument removes the limit - bool SetLimit(uint64_t nPos = (uint64_t)(-1)) { + bool SetLimit(uint64_t nPos = std::numeric_limits::max()) { if (nPos < nReadPos) return false; nReadLimit = nPos; @@ -1421,7 +1418,7 @@ public: // search for a given byte in the stream, and remain positioned on it void FindByte(char ch) { - while (true) { + for ( ; ; ) { if (nReadPos == nSrcPos) Fill(); if (vchBuf[nReadPos % vchBuf.size()] == ch)