From faf705a42a05197d89abfc31672ced94d268767f Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 22 Apr 2012 13:22:39 -0400 Subject: [PATCH 1/6] 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. --- src/bignum.h | 2 +- src/script.cpp | 22 +++++++++++----------- src/wallet.cpp | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/bignum.h b/src/bignum.h index 0d57dc8a8..b6ae32fec 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -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; } diff --git a/src/script.cpp b/src/script.cpp index fc0a5b3ea..00c9990b8 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -38,7 +38,7 @@ CBigNum CastToBigNum(const valtype& vch) bool CastToBool(const valtype& vch) { - for (int i = 0; i < vch.size(); i++) + for (unsigned int i = 0; i < vch.size(); i++) { if (vch[i] != 0) { @@ -655,7 +655,7 @@ bool EvalScript(vector >& stack, const CScript& script, co if (stack.size() < 1) return false; valtype& vch = stacktop(-1); - for (int i = 0; i < vch.size(); i++) + for (unsigned int i = 0; i < vch.size(); i++) vch[i] = ~vch[i]; } break; @@ -672,17 +672,17 @@ bool EvalScript(vector >& stack, const CScript& script, co MakeSameSize(vch1, vch2); if (opcode == OP_AND) { - for (int i = 0; i < vch1.size(); i++) + for (unsigned int i = 0; i < vch1.size(); i++) vch1[i] &= vch2[i]; } else if (opcode == OP_OR) { - for (int i = 0; i < vch1.size(); i++) + for (unsigned int i = 0; i < vch1.size(); i++) vch1[i] |= vch2[i]; } else if (opcode == OP_XOR) { - for (int i = 0; i < vch1.size(); i++) + for (unsigned int i = 0; i < vch1.size(); i++) vch1[i] ^= vch2[i]; } popstack(stack); @@ -939,7 +939,7 @@ bool EvalScript(vector >& stack, const CScript& script, co { // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool) - int i = 1; + unsigned int i = 1; if (stack.size() < i) return false; @@ -1050,7 +1050,7 @@ uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int scriptCode.FindAndDelete(CScript(OP_CODESEPARATOR)); // Blank out other inputs' signatures - for (int i = 0; i < txTmp.vin.size(); i++) + for (unsigned int i = 0; i < txTmp.vin.size(); i++) txTmp.vin[i].scriptSig = CScript(); txTmp.vin[nIn].scriptSig = scriptCode; @@ -1061,7 +1061,7 @@ uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int txTmp.vout.clear(); // Let the others update at will - for (int i = 0; i < txTmp.vin.size(); i++) + for (unsigned int i = 0; i < txTmp.vin.size(); i++) if (i != nIn) txTmp.vin[i].nSequence = 0; } @@ -1075,11 +1075,11 @@ uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int return 1; } txTmp.vout.resize(nOut+1); - for (int i = 0; i < nOut; i++) + for (unsigned int i = 0; i < nOut; i++) txTmp.vout[i].SetNull(); // Let the others update at will - for (int i = 0; i < txTmp.vin.size(); i++) + for (unsigned int i = 0; i < txTmp.vin.size(); i++) if (i != nIn) txTmp.vin[i].nSequence = 0; } @@ -1449,7 +1449,7 @@ bool ExtractAddresses(const CScript& scriptPubKey, txnouttype& typeRet, vector Date: Mon, 23 Apr 2012 14:14:03 -0400 Subject: [PATCH 2/6] SigOp and orphan-tx constants and counts are always unsigned. Fixes several sign-comparison warnings. --- src/main.cpp | 22 +++++++++++----------- src/main.h | 8 ++++---- src/script.cpp | 10 +++++----- src/script.h | 4 ++-- src/test/DoS_tests.cpp | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 78d84d906..7edd87a1e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -195,9 +195,9 @@ void static EraseOrphanTx(uint256 hash) mapOrphanTransactions.erase(hash); } -int LimitOrphanTxSize(int nMaxOrphans) +unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) { - int nEvicted = 0; + unsigned int nEvicted = 0; while (mapOrphanTransactions.size() > nMaxOrphans) { // Evict a random orphan: @@ -328,10 +328,10 @@ bool CTransaction::AreInputsStandard(const MapPrevTx& mapInputs) const return true; } -int +unsigned int CTransaction::GetLegacySigOpCount() const { - int nSigOps = 0; + unsigned int nSigOps = 0; BOOST_FOREACH(const CTxIn& txin, vin) { nSigOps += txin.scriptSig.GetSigOpCount(false); @@ -1079,12 +1079,12 @@ int64 CTransaction::GetValueIn(const MapPrevTx& inputs) const } -int CTransaction::GetP2SHSigOpCount(const MapPrevTx& inputs) const +unsigned int CTransaction::GetP2SHSigOpCount(const MapPrevTx& inputs) const { if (IsCoinBase()) return 0; - int nSigOps = 0; + unsigned int nSigOps = 0; for (unsigned int i = 0; i < vin.size(); i++) { const CTxOut& prevout = GetOutputFor(vin[i], inputs); @@ -1284,7 +1284,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex) map mapQueuedChanges; int64 nFees = 0; - int nSigOps = 0; + unsigned int nSigOps = 0; BOOST_FOREACH(CTransaction& tx, vtx) { nSigOps += tx.GetLegacySigOpCount(); @@ -1645,7 +1645,7 @@ bool CBlock::CheckBlock() const if (!tx.CheckTransaction()) return DoS(tx.nDoS, error("CheckBlock() : CheckTransaction failed")); - int nSigOps = 0; + unsigned int nSigOps = 0; BOOST_FOREACH(const CTransaction& tx, vtx) { nSigOps += tx.GetLegacySigOpCount(); @@ -2583,9 +2583,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) AddOrphanTx(vMsg); // DoS prevention: do not allow mapOrphanTransactions to grow unbounded - int nEvicted = LimitOrphanTxSize(MAX_ORPHAN_TRANSACTIONS); + unsigned int nEvicted = LimitOrphanTxSize(MAX_ORPHAN_TRANSACTIONS); if (nEvicted > 0) - printf("mapOrphan overflow, removed %d tx\n", nEvicted); + printf("mapOrphan overflow, removed %u tx\n", nEvicted); } if (tx.nDoS) pfrom->Misbehaving(tx.nDoS); } @@ -3209,7 +3209,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) continue; // Legacy limits on sigOps: - int nTxSigOps = tx.GetLegacySigOpCount(); + unsigned int nTxSigOps = tx.GetLegacySigOpCount(); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) continue; diff --git a/src/main.h b/src/main.h index a814092ac..034911ac2 100644 --- a/src/main.h +++ b/src/main.h @@ -28,8 +28,8 @@ class CNode; static const unsigned int MAX_BLOCK_SIZE = 1000000; static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2; -static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; -static const int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100; +static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; +static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100; static const int64 MIN_TX_FEE = 50000; static const int64 MIN_RELAY_TX_FEE = 10000; static const int64 MAX_MONEY = 21000000 * COIN; @@ -495,7 +495,7 @@ public: @return number of sigops this transaction's outputs will produce when spent @see CTransaction::FetchInputs */ - int GetLegacySigOpCount() const; + unsigned int GetLegacySigOpCount() const; /** Count ECDSA signature operations in pay-to-script-hash inputs. @@ -503,7 +503,7 @@ public: @return maximum number of sigops required to validate this transaction's inputs @see CTransaction::FetchInputs */ - int GetP2SHSigOpCount(const MapPrevTx& mapInputs) const; + unsigned int GetP2SHSigOpCount(const MapPrevTx& mapInputs) const; /** Amount of bitcoins spent by this transaction. @return sum of all outputs (note: does not include fees) diff --git a/src/script.cpp b/src/script.cpp index 00c9990b8..eb8200bcc 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1360,9 +1360,9 @@ bool IsStandard(const CScript& scriptPubKey) } -int HaveKeys(const vector& pubkeys, const CKeyStore& keystore) +unsigned int HaveKeys(const vector& pubkeys, const CKeyStore& keystore) { - int nResult = 0; + unsigned int nResult = 0; BOOST_FOREACH(const valtype& pubkey, pubkeys) { CBitcoinAddress address; @@ -1566,9 +1566,9 @@ bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsig return true; } -int CScript::GetSigOpCount(bool fAccurate) const +unsigned int CScript::GetSigOpCount(bool fAccurate) const { - int n = 0; + unsigned int n = 0; const_iterator pc = begin(); opcodetype lastOpcode = OP_INVALIDOPCODE; while (pc < end()) @@ -1590,7 +1590,7 @@ int CScript::GetSigOpCount(bool fAccurate) const return n; } -int CScript::GetSigOpCount(const CScript& scriptSig) const +unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const { if (!IsPayToScriptHash()) return GetSigOpCount(true); diff --git a/src/script.h b/src/script.h index b13734be4..52922af16 100644 --- a/src/script.h +++ b/src/script.h @@ -491,11 +491,11 @@ public: // CHECKMULTISIGs serialized in scriptSigs are // counted more accurately, assuming they are of the form // ... OP_N CHECKMULTISIG ... - int GetSigOpCount(bool fAccurate) const; + unsigned int GetSigOpCount(bool fAccurate) const; // Accurately count sigOps, including sigOps in // pay-to-script-hash transactions: - int GetSigOpCount(const CScript& scriptSig) const; + unsigned int GetSigOpCount(const CScript& scriptSig) const; bool IsPayToScriptHash() const; diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index c0b00102a..e5a8b4f68 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -14,7 +14,7 @@ // Tests this internal-to-main.cpp method: extern void AddOrphanTx(const CDataStream& vMsg); -extern int LimitOrphanTxSize(int nMaxOrphans); +extern unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans); extern std::map mapOrphanTransactions; extern std::multimap mapOrphanTransactionsByPrev; From c0a0a93d02251390b482d4a147531989641c5a98 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 22 Apr 2012 13:44:12 -0400 Subject: [PATCH 3/6] Test ScriptSigArgsExpected() for error, before accumulating return value --- src/main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7edd87a1e..2480d2659 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -297,6 +297,8 @@ bool CTransaction::AreInputsStandard(const MapPrevTx& mapInputs) const if (!Solver(prevScript, whichType, vSolutions)) return false; int nArgsExpected = ScriptSigArgsExpected(whichType, vSolutions); + if (nArgsExpected < 0) + return false; // Transactions with extra stuff in their scriptSigs are // non-standard. Note that this EvalScript() call will @@ -318,10 +320,15 @@ bool CTransaction::AreInputsStandard(const MapPrevTx& mapInputs) const return false; if (whichType2 == TX_SCRIPTHASH) return false; - nArgsExpected += ScriptSigArgsExpected(whichType2, vSolutions2); + + int tmpExpected; + tmpExpected = ScriptSigArgsExpected(whichType2, vSolutions2); + if (tmpExpected < 0) + return false; + nArgsExpected += tmpExpected; } - if (stack.size() != nArgsExpected) + if (stack.size() != (unsigned int)nArgsExpected) return false; } From 1d8c7a9557d596d4c7edee801a724db7a908bce5 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 22 Apr 2012 13:51:16 -0400 Subject: [PATCH 4/6] Add casts for unavoidable signed/unsigned comparisons At these code sites, it is preferable to cast rather than change a variable's type. --- src/bignum.h | 4 ++-- src/bitcoinrpc.cpp | 10 ++++++---- src/main.cpp | 10 +++++----- src/main.h | 2 +- src/protocol.cpp | 2 +- src/script.cpp | 8 ++++---- src/script.h | 2 +- src/util.cpp | 2 +- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/bignum.h b/src/bignum.h index b6ae32fec..f0971e885 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -117,9 +117,9 @@ public: { unsigned long n = BN_get_word(this); if (!BN_is_negative(this)) - return (n > std::numeric_limits::max() ? std::numeric_limits::max() : n); + return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::max() : n); else - return (n > std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); + return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); } void setint64(int64 n) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 206347faf..226292391 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -999,7 +999,7 @@ Value addmultisigaddress(const Array& params, bool fHelp) strAccount = AccountFromValue(params[2]); // Gather public keys - if (nRequired < 1 || keys.size() < nRequired) + if ((nRequired < 1) || ((int)keys.size() < nRequired)) throw runtime_error( strprintf("wrong number of keys" "(got %d, need at least %d)", keys.size(), nRequired)); @@ -1331,8 +1331,10 @@ Value listtransactions(const Array& params, bool fHelp) } // ret is newest to oldest - if (nFrom > ret.size()) nFrom = ret.size(); - if (nFrom+nCount > ret.size()) nCount = ret.size()-nFrom; + if (nFrom > (int)ret.size()) + nFrom = ret.size(); + if ((nFrom + nCount) > (int)ret.size()) + nCount = ret.size() - nFrom; Array::iterator first = ret.begin(); std::advance(first, nFrom); Array::iterator last = ret.begin(); @@ -2202,7 +2204,7 @@ int ReadHTTP(std::basic_istream& stream, map& mapHeadersRe // Read header int nLen = ReadHTTPHeader(stream, mapHeadersRet); - if (nLen < 0 || nLen > MAX_SIZE) + if (nLen < 0 || nLen > (int)MAX_SIZE) return 500; // Read message diff --git a/src/main.cpp b/src/main.cpp index 2480d2659..e5d110d8e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -376,10 +376,10 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock) hashBlock = pblock->GetHash(); // Locate the transaction - for (nIndex = 0; nIndex < pblock->vtx.size(); nIndex++) + for (nIndex = 0; nIndex < (int)pblock->vtx.size(); nIndex++) if (pblock->vtx[nIndex] == *(CTransaction*)this) break; - if (nIndex == pblock->vtx.size()) + if (nIndex == (int)pblock->vtx.size()) { vMerkleBranch.clear(); nIndex = -1; @@ -2750,7 +2750,7 @@ bool ProcessMessages(CNode* pfrom) int nHeaderSize = vRecv.GetSerializeSize(CMessageHeader()); if (vRecv.end() - pstart < nHeaderSize) { - if (vRecv.size() > nHeaderSize) + if ((int)vRecv.size() > nHeaderSize) { printf("\n\nPROCESSMESSAGE MESSAGESTART NOT FOUND\n\n"); vRecv.erase(vRecv.begin(), vRecv.end() - nHeaderSize); @@ -3084,7 +3084,7 @@ unsigned int static ScanHash_CryptoPP(char* pmidstate, char* pdata, char* phash1 if ((nNonce & 0xffff) == 0) { nHashesDone = 0xffff+1; - return -1; + return (unsigned int) -1; } } } @@ -3461,7 +3461,7 @@ void static BitcoinMiner(CWallet *pwallet) (char*)&hash, nHashesDone); // Check if something found - if (nNonceFound != -1) + if (nNonceFound != (unsigned int) -1) { for (unsigned int i = 0; i < sizeof(hash)/4; i++) ((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]); diff --git a/src/main.h b/src/main.h index 034911ac2..423891c3b 100644 --- a/src/main.h +++ b/src/main.h @@ -437,7 +437,7 @@ public: nBlockHeight = nBestHeight; if (nBlockTime == 0) nBlockTime = GetAdjustedTime(); - if ((int64)nLockTime < (nLockTime < LOCKTIME_THRESHOLD ? (int64)nBlockHeight : nBlockTime)) + if ((int64)nLockTime < ((int64)nLockTime < LOCKTIME_THRESHOLD ? (int64)nBlockHeight : nBlockTime)) return true; BOOST_FOREACH(const CTxIn& txin, vin) if (!txin.IsFinal()) diff --git a/src/protocol.cpp b/src/protocol.cpp index 06306cf8e..fda31966f 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -128,7 +128,7 @@ bool operator<(const CInv& a, const CInv& b) bool CInv::IsKnownType() const { - return (type >= 1 && type < ARRAYLEN(ppszTypeName)); + return (type >= 1 && type < (int)ARRAYLEN(ppszTypeName)); } const char* CInv::GetCommand() const diff --git a/src/script.cpp b/src/script.cpp index eb8200bcc..660023ef4 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -536,7 +536,7 @@ bool EvalScript(vector >& stack, const CScript& script, co return false; int n = CastToBigNum(stacktop(-1)).getint(); popstack(stack); - if (n < 0 || n >= stack.size()) + if (n < 0 || n >= (int)stack.size()) return false; valtype vch = stacktop(-n-1); if (opcode == OP_ROLL) @@ -604,9 +604,9 @@ bool EvalScript(vector >& stack, const CScript& script, co int nEnd = nBegin + CastToBigNum(stacktop(-1)).getint(); if (nBegin < 0 || nEnd < nBegin) return false; - if (nBegin > vch.size()) + if (nBegin > (int)vch.size()) nBegin = vch.size(); - if (nEnd > vch.size()) + if (nEnd > (int)vch.size()) nEnd = vch.size(); vch.erase(vch.begin() + nEnd, vch.end()); vch.erase(vch.begin(), vch.begin() + nBegin); @@ -625,7 +625,7 @@ bool EvalScript(vector >& stack, const CScript& script, co int nSize = CastToBigNum(stacktop(-1)).getint(); if (nSize < 0) return false; - if (nSize > vch.size()) + if (nSize > (int)vch.size()) nSize = vch.size(); if (opcode == OP_LEFT) vch.erase(vch.begin() + nSize, vch.end()); diff --git a/src/script.h b/src/script.h index 52922af16..e41e09b6b 100644 --- a/src/script.h +++ b/src/script.h @@ -467,7 +467,7 @@ public: opcodetype opcode; do { - while (end() - pc >= b.size() && memcmp(&pc[0], &b[0], b.size()) == 0) + while (end() - pc >= (long)b.size() && memcmp(&pc[0], &b[0], b.size()) == 0) { erase(pc, pc + b.size()); ++nFound; diff --git a/src/util.cpp b/src/util.cpp index 9f2de3449..016e9deb0 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -283,7 +283,7 @@ int my_snprintf(char* buffer, size_t limit, const char* format, ...) va_start(arg_ptr, format); int ret = _vsnprintf(buffer, limit, format, arg_ptr); va_end(arg_ptr); - if (ret < 0 || ret >= limit) + if (ret < 0 || ret >= (int)limit) { ret = limit - 1; buffer[limit-1] = 0; From 5aa0b2382515eb92fe249a106059f3b6a9328d26 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 22 Apr 2012 13:59:24 -0400 Subject: [PATCH 5/6] CBlock::WriteToDisk() properly checks ftell(3) for error return Rather than storing ftell(3)'s return value -- a long -- in an unsigned int, we store and check a properly typed temp. Then, assured a non-negative value, we store in nBlockPosRet. --- src/main.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.h b/src/main.h index 423891c3b..262e77e80 100644 --- a/src/main.h +++ b/src/main.h @@ -944,9 +944,10 @@ public: fileout << FLATDATA(pchMessageStart) << nSize; // Write block - nBlockPosRet = ftell(fileout); - if (nBlockPosRet == -1) + long fileOutPos = ftell(fileout); + if (fileOutPos < 0) return error("CBlock::WriteToDisk() : ftell failed"); + nBlockPosRet = fileOutPos; fileout << *this; // Flush stdio buffers and commit to disk before returning From 735a60698c845f257a0f7e9b617d50669d9179d4 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 22 Apr 2012 14:01:25 -0400 Subject: [PATCH 6/6] Change signed->unsigned at 3 code sites This resolves signed/unsigned comparison warnings. --- src/db.cpp | 2 +- src/net.cpp | 2 +- src/util.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 39a41894d..53da378fe 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -648,7 +648,7 @@ bool CTxDB::LoadBlockIndex() } } // check level 4: check whether spent txouts were spent within the main chain - int nOutput = 0; + unsigned int nOutput = 0; if (nCheckLevel>3) { BOOST_FOREACH(const CDiskTxPos &txpos, txindex.vSpent) diff --git a/src/net.cpp b/src/net.cpp index 38c0d3d58..d218dcfb5 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -498,7 +498,7 @@ void ThreadSocketHandler2(void* parg) { printf("ThreadSocketHandler started\n"); list vNodesDisconnected; - int nPrevNodeCount = 0; + unsigned int nPrevNodeCount = 0; loop { diff --git a/src/util.h b/src/util.h index fe8ca60b4..d9d8151b7 100644 --- a/src/util.h +++ b/src/util.h @@ -579,9 +579,9 @@ template class CMedianFilter private: std::vector vValues; std::vector vSorted; - int nSize; + unsigned int nSize; public: - CMedianFilter(int size, T initial_value): + CMedianFilter(unsigned int size, T initial_value): nSize(size) { vValues.reserve(size);