From: fsb4000 Date: Tue, 27 Jan 2015 10:07:31 +0000 (+0600) Subject: устранил предупреждения компилятора X-Git-Tag: nvc-v0.5.3~124^2 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=532b9005ab4fc02db3db424b4631fe395e0b9071 устранил предупреждения компилятора 4267: https://msdn.microsoft.com/ru-ru/library/6kck0s93.aspx 4244: https://msdn.microsoft.com/ru-ru/library/th7a07tz.aspx 4800: https://msdn.microsoft.com/ru-ru/library/b6801kcy.aspx --- diff --git a/src/base58.h b/src/base58.h index 5675c04..8c0ced7 100644 --- a/src/base58.h +++ b/src/base58.h @@ -94,7 +94,7 @@ inline bool DecodeBase58(const char* psz, std::vector& vchRet) return false; break; } - bnChar.setuint32(p1 - pszBase58); + bnChar.setuint32((uint32_t)(p1 - pszBase58)); if (!BN_mul(&bn, &bn, &bn58, pctx)) throw bignum_error("DecodeBase58 : BN_mul failed"); bn += bnChar; diff --git a/src/bignum.h b/src/bignum.h index 3570840..7f02fd5 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -188,7 +188,7 @@ public: pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, (int)(p - pch), this); } uint64_t getuint64() diff --git a/src/init.cpp b/src/init.cpp index 1c80723..296369d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -373,10 +373,10 @@ bool AppInit2() // ********************************************************* Step 2: parameter interactions - nNodeLifespan = GetArg("-addrlifespan", 7); + nNodeLifespan = (unsigned int)(GetArg("-addrlifespan", 7)); fUseFastIndex = GetBoolArg("-fastindex", true); fUseMemoryLog = GetBoolArg("-memorylog", true); - nMinerSleep = GetArg("-minersleep", 500); + nMinerSleep = (unsigned int)(GetArg("-minersleep", 500)); // Ping and address broadcast intervals nPingInterval = max(10 * 60, GetArg("-keepalive", 30 * 60)); @@ -439,7 +439,7 @@ bool AppInit2() // ********************************************************* Step 3: parameter-to-internal-flags // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency - nScriptCheckThreads = GetArg("-par", 0); + nScriptCheckThreads = (int)(GetArg("-par", 0)); if (nScriptCheckThreads == 0) nScriptCheckThreads = boost::thread::hardware_concurrency(); if (nScriptCheckThreads <= 1) @@ -478,7 +478,7 @@ bool AppInit2() if (mapArgs.count("-timeout")) { - int nNewTimeout = GetArg("-timeout", 5000); + int nNewTimeout = (int)(GetArg("-timeout", 5000)); if (nNewTimeout > 0 && nNewTimeout < 600000) nConnectTimeout = nNewTimeout; } @@ -603,7 +603,7 @@ bool AppInit2() // ********************************************************* Step 6: network initialization - int nSocksVersion = GetArg("-socks", 5); + int nSocksVersion = (int)(GetArg("-socks", 5)); if (nSocksVersion != 4 && nSocksVersion != 5) return InitError(strprintf(_("Unknown -socks proxy version requested: %i"), nSocksVersion)); @@ -844,7 +844,7 @@ bool AppInit2() if (GetBoolArg("-upgradewallet", fFirstRun)) { - int nMaxVersion = GetArg("-upgradewallet", 0); + int nMaxVersion = (int)(GetArg("-upgradewallet", 0)); if (nMaxVersion == 0) // the -upgradewallet without argument case { printf("Performing wallet upgrade to %i\n", FEATURE_LATEST); diff --git a/src/kernelrecord.cpp b/src/kernelrecord.cpp index 3212ace..bf05268 100644 --- a/src/kernelrecord.cpp +++ b/src/kernelrecord.cpp @@ -3,6 +3,9 @@ #include "wallet.h" #include "base58.h" +#ifdef _MSC_VER +#pragma warning( disable : 4345) +#endif using namespace std; @@ -87,7 +90,7 @@ uint64_t KernelRecord::getCoinDay() const int64_t KernelRecord::getPoSReward(int nBits, int minutes) { - double PoSReward; + int64_t PoSReward; int64_t nWeight = GetAdjustedTime() - nTime + minutes * 60; if( nWeight < nStakeMinAge) return 0; @@ -103,7 +106,7 @@ double KernelRecord::getProbToMintStake(double difficulty, int timeOffset) const //int dayWeight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64_t)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge) / 86400; //uint64_t coinAge = max(nValue * dayWeight / COIN, (int64_t)0); //return target * coinAge / pow(static_cast(2), 256); - int Weight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64_t)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge); + int64_t Weight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64_t)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge); uint64_t coinAge = max(nValue * Weight / (COIN * 86400), (int64_t)0); return coinAge / (pow(static_cast(2),32) * difficulty); } diff --git a/src/main.cpp b/src/main.cpp index 9d38e93..9370ffa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1059,7 +1059,7 @@ int64_t GetProofOfWorkReward(unsigned int nBits, int64_t nFees) } // miner's coin stake reward based on nBits and coin age spent (coin-days) -int64_t GetProofOfStakeReward(int64_t nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly) +int64_t GetProofOfStakeReward(int64_t nCoinAge, unsigned int nBits, int64_t nTime, bool bCoinYearOnly) { int64_t nRewardCoinYear, nSubsidy, nSubsidyLimit = 10 * COIN; diff --git a/src/main.h b/src/main.h index 8ee3d31..b553d6c 100644 --- a/src/main.h +++ b/src/main.h @@ -126,7 +126,7 @@ void ThreadScriptCheckQuit(); bool CheckProofOfWork(uint256 hash, unsigned int nBits); unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake); int64_t GetProofOfWorkReward(unsigned int nBits, int64_t nFees=0); -int64_t GetProofOfStakeReward(int64_t nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly=false); +int64_t GetProofOfStakeReward(int64_t nCoinAge, unsigned int nBits, int64_t nTime, bool bCoinYearOnly=false); unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime); unsigned int ComputeMinStake(unsigned int nBase, int64_t nTime, unsigned int nBlockTime); int GetNumBlocksOfPeers(); diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 586f046..ec66cc3 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -52,7 +52,7 @@ int ClientModel::getNumConnections(uint8_t flags) const { LOCK(cs_vNodes); if (flags == CONNECTIONS_ALL) // Shortcut if we want total - return vNodes.size(); + return (int)(vNodes.size()); int nNum = 0; BOOST_FOREACH(CNode* pnode, vNodes) diff --git a/src/qt/multisigdialog.cpp b/src/qt/multisigdialog.cpp index e8ad839..52eb978 100644 --- a/src/qt/multisigdialog.cpp +++ b/src/qt/multisigdialog.cpp @@ -24,6 +24,10 @@ #include "txdb-bdb.h" #endif +#ifdef _MSC_VER +#pragma warning( disable : 4101) +#endif + MultisigDialog::MultisigDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MultisigDialog), model(0) { ui->setupUi(this); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index baa8e7e..ff2dae3 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -75,7 +75,7 @@ int WalletModel::getNumTransactions() const int numTransactions = 0; { LOCK(wallet->cs_wallet); - numTransactions = wallet->mapWallet.size(); + numTransactions = (int)(wallet->mapWallet.size()); } return numTransactions; } diff --git a/src/script.cpp b/src/script.cpp index f30f3a2..61ca851 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1707,7 +1707,7 @@ static CScript CombineMultisig(CScript scriptPubKey, const CTransaction& txTo, u // Build a map of pubkey -> signature by matching sigs to pubkeys: assert(vSolutions.size() > 1); unsigned int nSigsRequired = vSolutions.front()[0]; - unsigned int nPubKeys = vSolutions.size()-2; + unsigned int nPubKeys = (unsigned int)(vSolutions.size()-2); map sigs; BOOST_FOREACH(const valtype& sig, allsigs) { @@ -1923,5 +1923,5 @@ void CScript::SetMultisig(int nRequired, const std::vector& keys) *this << EncodeOP_N(nRequired); BOOST_FOREACH(const CKey& key, keys) *this << key.GetPubKey(); - *this << EncodeOP_N(keys.size()) << OP_CHECKMULTISIG; + *this << EncodeOP_N((int)(keys.size())) << OP_CHECKMULTISIG; } diff --git a/src/serialize.h b/src/serialize.h index 31a2883..f579c58 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -230,20 +230,20 @@ void WriteCompactSize(Stream& os, uint64_t nSize) { if (nSize < 253) { - unsigned char chSize = nSize; + unsigned char chSize = (unsigned char)nSize; WRITEDATA(os, chSize); } else if (nSize <= std::numeric_limits::max()) { unsigned char chSize = 253; - unsigned short xSize = nSize; + unsigned short xSize = (unsigned short)nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } else if (nSize <= std::numeric_limits::max()) { unsigned char chSize = 254; - unsigned int xSize = nSize; + unsigned int xSize = (unsigned int)nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } @@ -376,13 +376,13 @@ public: unsigned int GetSerializeSize(int, int=0) const { - return pend - pbegin; + return (unsigned int)(pend - pbegin); } template void Serialize(Stream& s, int, int=0) const { - s.write(pbegin, pend - pbegin); + s.write(pbegin, (int)(pend - pbegin)); } template @@ -506,7 +506,7 @@ inline void Unserialize(Stream& is, T& a, long nType, int nVersion) template unsigned int GetSerializeSize(const std::basic_string& str, int, int) { - return GetSizeOfCompactSize(str.size()) + str.size() * sizeof(str[0]); + return (unsigned int)(GetSizeOfCompactSize(str.size()) + str.size() * sizeof(str[0])); } template @@ -514,13 +514,13 @@ void Serialize(Stream& os, const std::basic_string& str, int, int) { WriteCompactSize(os, str.size()); if (!str.empty()) - os.write((char*)&str[0], str.size() * sizeof(str[0])); + os.write((char*)&str[0], (int)(str.size() * sizeof(str[0]))); } template void Unserialize(Stream& is, std::basic_string& str, int, int) { - unsigned int nSize = ReadCompactSize(is); + unsigned int nSize = (unsigned int)(ReadCompactSize(is)); str.resize(nSize); if (nSize != 0) is.read((char*)&str[0], nSize * sizeof(str[0])); @@ -534,7 +534,7 @@ void Unserialize(Stream& is, std::basic_string& str, int, int) template unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const boost::true_type&) { - return (GetSizeOfCompactSize(v.size()) + v.size() * sizeof(T)); + return (unsigned int)(GetSizeOfCompactSize(v.size()) + v.size() * sizeof(T)); } template @@ -558,7 +558,7 @@ void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVers { WriteCompactSize(os, v.size()); if (!v.empty()) - os.write((char*)&v[0], v.size() * sizeof(T)); + os.write((char*)&v[0], (int)(v.size() * sizeof(T))); } template @@ -581,7 +581,7 @@ void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, { // Limit size per read so bogus size value won't cause out of memory v.clear(); - unsigned int nSize = ReadCompactSize(is); + unsigned int nSize = (unsigned int)(ReadCompactSize(is)); unsigned int i = 0; while (i < nSize) { @@ -596,7 +596,7 @@ template void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const boost::false_type&) { v.clear(); - unsigned int nSize = ReadCompactSize(is); + unsigned int nSize = (unsigned int)(ReadCompactSize(is)); unsigned int i = 0; unsigned int nMid = 0; while (nMid < nSize) @@ -754,7 +754,7 @@ template void Unserialize(Stream& is, std::map& m, int nType, int nVersion) { m.clear(); - unsigned int nSize = ReadCompactSize(is); + unsigned int nSize = (unsigned int)(ReadCompactSize(is)); typename std::map::iterator mi = m.begin(); for (unsigned int i = 0; i < nSize; i++) { @@ -958,7 +958,7 @@ public: if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) { // special case for inserting at the front when there's room - nReadPos -= (last - first); + nReadPos -= (unsigned int)(last - first); memcpy(&vch[nReadPos], &first[0], last - first); } else @@ -988,7 +988,7 @@ public: if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) { // special case for inserting at the front when there's room - nReadPos -= (last - first); + nReadPos -= (unsigned int)(last - first); memcpy(&vch[nReadPos], &first[0], last - first); } else @@ -1025,7 +1025,7 @@ public: } else { - nReadPos = (last - vch.begin()); + nReadPos = (unsigned int)(last - vch.begin()); return last; } } @@ -1044,7 +1044,7 @@ public: // Rewind by n characters if the buffer hasn't been compacted yet if (n > nReadPos) return false; - nReadPos -= n; + nReadPos -= (unsigned int)n; return true; } @@ -1060,13 +1060,13 @@ public: } bool eof() const { return size() == 0; } - bool fail() const { return state & (std::ios::badbit | std::ios::failbit); } + bool fail() const { return (state & (std::ios::badbit | std::ios::failbit)) != 0; } bool good() const { return !eof() && (state == 0); } void clear(short n) { state = n; } // name conflict with vector clear() short exceptions() { return exceptmask; } short exceptions(short mask) { short prev = exceptmask; exceptmask = mask; setstate(0, "CDataStream"); return prev; } CDataStream* rdbuf() { return this; } - int in_avail() { return size(); } + int in_avail() { return (int)(size()); } void SetType(int n) { nType = n; } int GetType() { return nType; } @@ -1086,7 +1086,7 @@ public: { setstate(std::ios::failbit, "CDataStream::read() : end of data"); memset(pch, 0, nSize); - nSize = vch.size() - nReadPos; + nSize = (int)(vch.size() - nReadPos); } memcpy(pch, &vch[nReadPos], nSize); nReadPos = 0; @@ -1108,7 +1108,7 @@ public: if (nReadPosNext > vch.size()) { setstate(std::ios::failbit, "CDataStream::ignore() : end of data"); - nSize = vch.size() - nReadPos; + nSize = (int)(vch.size() - nReadPos); } nReadPos = 0; vch.clear(); @@ -1228,7 +1228,7 @@ public: throw std::ios_base::failure(psz); } - bool fail() const { return state & (std::ios::badbit | std::ios::failbit); } + bool fail() const { return (state & (std::ios::badbit | std::ios::failbit)) != 0; } bool good() const { return state == 0; } void clear(short n = 0) { state = n; } short exceptions() { return exceptmask; } @@ -1312,9 +1312,9 @@ protected: // read data from the source to fill the buffer bool Fill() { - unsigned int pos = nSrcPos % vchBuf.size(); - unsigned int readNow = vchBuf.size() - pos; - unsigned int nAvail = vchBuf.size() - (nSrcPos - nReadPos) - nRewind; + unsigned int pos = (unsigned int)(nSrcPos % vchBuf.size()); + unsigned int readNow = (unsigned int)(vchBuf.size() - pos); + unsigned int nAvail = (unsigned int)(vchBuf.size() - (nSrcPos - nReadPos) - nRewind); if (nAvail < readNow) readNow = nAvail; if (readNow == 0) @@ -1357,7 +1357,7 @@ public: while (nSize > 0) { if (nReadPos == nSrcPos) Fill(); - unsigned int pos = nReadPos % vchBuf.size(); + unsigned int pos = (unsigned int)(nReadPos % vchBuf.size()); size_t nNow = nSize; if (nNow + pos > vchBuf.size()) nNow = vchBuf.size() - pos; @@ -1391,7 +1391,7 @@ public: } bool Seek(uint64_t nPos) { - long nLongPos = nPos; + long nLongPos = (long)nPos; if (nPos != (uint64_t)nLongPos) return false; if (fseek(src, nLongPos, SEEK_SET)) diff --git a/src/wallet.h b/src/wallet.h index c1a987e..9dfc56e 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -328,7 +328,7 @@ public: unsigned int GetKeyPoolSize() { - return setKeyPool.size(); + return (unsigned int)(setKeyPool.size()); } bool GetTransaction(const uint256 &hashTx, CWalletTx& wtx);