From e3af34101250095febe11520d67c6e0070ef3181 Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Mon, 29 Dec 2014 10:01:42 +0300 Subject: [PATCH] addrman.h, main.h: fix msvc warnings --- src/addrman.h | 2 +- src/main.h | 14 ++++++++------ src/net.cpp | 2 +- src/net.h | 14 +++++++------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/addrman.h b/src/addrman.h index 5f5bf79..beb543a 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -569,7 +569,7 @@ public: // Return the number of (unique) addresses in all tables. int size() { - return vRandom.size(); + return (int) vRandom.size(); } // Consistency check diff --git a/src/main.h b/src/main.h index 0c54e7e..2cb3ea7 100644 --- a/src/main.h +++ b/src/main.h @@ -471,7 +471,7 @@ public: void SetNull() { nVersion = CTransaction::CURRENT_VERSION; - nTime = GetAdjustedTime(); + nTime = (uint32_t) GetAdjustedTime(); vin.clear(); vout.clear(); nLockTime = 0; @@ -619,6 +619,7 @@ public: filein >> *this; } catch (std::exception &e) { + (void)e; return error("%s() : deserialize or I/O error", BOOST_CURRENT_FUNCTION); } @@ -975,7 +976,7 @@ public: hashSig >>= 159; // take the first bit of the hash if (fDebug && GetBoolArg("-printstakemodifier")) printf(" entropybit=%" PRId64 "\n", hashSig.Get64()); - return hashSig.Get64(); + return (unsigned int)hashSig.Get64(); } // ppcoin: two types of block: proof-of-work or proof-of-stake @@ -1009,7 +1010,7 @@ public: BOOST_FOREACH(const CTransaction& tx, vtx) vMerkleTree.push_back(tx.GetHash()); int j = 0; - for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) + for (int nSize = (int)vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { for (int i = 0; i < nSize; i += 2) { @@ -1028,7 +1029,7 @@ public: BuildMerkleTree(); std::vector vMerkleBranch; int j = 0; - for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) + for (int nSize = (int)vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { int i = std::min(nIndex^1, nSize-1); vMerkleBranch.push_back(vMerkleTree[j+i]); @@ -1096,6 +1097,7 @@ public: filein >> *this; } catch (std::exception &e) { + (void)e; return error("%s() : deserialize or I/O error", BOOST_CURRENT_FUNCTION); } @@ -1354,7 +1356,7 @@ public: bool GeneratedStakeModifier() const { - return (nFlags & BLOCK_STAKE_MODIFIER); + return (nFlags & BLOCK_STAKE_MODIFIER) != 0; } void SetStakeModifier(uint64_t nModifier, bool fGeneratedStakeModifier) @@ -1634,7 +1636,7 @@ public: void clear(); void queryHashes(std::vector& vtxid); - unsigned long size() + size_t size() { LOCK(cs); return mapTx.size(); diff --git a/src/net.cpp b/src/net.cpp index 941bcd8..55d761e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -804,7 +804,7 @@ void ThreadSocketHandler2(void* parg) if (lockRecv) { CDataStream& vRecv = pnode->vRecv; - unsigned int nPos = vRecv.size(); + uint64_t nPos = vRecv.size(); if (nPos > ReceiveBufferSize()) { if (!pnode->fDisconnect) diff --git a/src/net.h b/src/net.h index 60c5274..2d635fa 100644 --- a/src/net.h +++ b/src/net.h @@ -29,8 +29,8 @@ extern int nBestHeight; -inline unsigned int ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } -inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); } +inline uint64_t ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } +inline uint64_t SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); } void AddOneShot(std::string strDest); bool RecvLine(SOCKET hSocket, std::string& strLine); @@ -251,7 +251,7 @@ public: fGetAddr = false; nMisbehavior = 0; hashCheckpointKnown = 0; - setInventoryKnown.max_size(SendBufferSize() / 1000); + setInventoryKnown.max_size((size_t)SendBufferSize() / 1000); // Be shy and don't send version until we hear if (hSocket != INVALID_SOCKET && !fInbound) @@ -359,9 +359,9 @@ public: ENTER_CRITICAL_SECTION(cs_vSend); if (nHeaderStart != -1) AbortMessage(); - nHeaderStart = vSend.size(); + nHeaderStart = (int32_t)vSend.size(); vSend << CMessageHeader(pszCommand, 0); - nMessageStart = vSend.size(); + nMessageStart = (uint32_t)vSend.size(); if (fDebug) printf("sending: %s ", pszCommand); } @@ -392,7 +392,7 @@ public: return; // Set the size - uint32_t nSize = vSend.size() - nMessageStart; + uint32_t nSize = (uint32_t) vSend.size() - nMessageStart; memcpy((char*)&vSend[nHeaderStart] + CMessageHeader::MESSAGE_SIZE_OFFSET, &nSize, sizeof(nSize)); // Set the checksum @@ -415,7 +415,7 @@ public: { if (nHeaderStart < 0) return; - int nSize = vSend.size() - nMessageStart; + int nSize = (int) vSend.size() - nMessageStart; if (nSize > 0) EndMessage(); else -- 1.7.1