Skip to content

Commit

Permalink
Fix a few "Uninitialized scalar field" warnings
Browse files Browse the repository at this point in the history
Fix a few warnings reported by Coverity.
None of these is critical, but making sure that class fields are
initialized can avoid heisenbugs.
  • Loading branch information
laanwj committed Aug 28, 2014
1 parent 11a8994 commit 8bdd287
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bloom.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CBloomFilter
// It should generally always be a random value (and is largely only exposed for unit testing)
// nFlags should be one of the BLOOM_UPDATE_* enums (not _MASK)
CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak, unsigned char nFlagsIn);
CBloomFilter() : isFull(true) {}
CBloomFilter() : isFull(true), isEmpty(false), nHashFuncs(0), nTweak(0), nFlags(0) {}

IMPLEMENT_SERIALIZE
(
Expand Down
2 changes: 1 addition & 1 deletion src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
pdb(NULL), activeTxn(NULL)
{
int ret;
fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));
if (pszFile == NULL)
return;

fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));
bool fCreate = strchr(pszMode, 'c');
unsigned int nFlags = DB_THREAD;
if (fCreate)
Expand Down
2 changes: 1 addition & 1 deletion src/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class CKey {
public:

// Construct an invalid private key.
CKey() : fValid(false) {
CKey() : fValid(false), fCompressed(false) {
LockObject(vch);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class CScriptCheck
int nHashType;

public:
CScriptCheck() {}
CScriptCheck(): ptxTo(0), nIn(0), nFlags(0), nHashType(0) {}
CScriptCheck(const CCoins& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, int nHashTypeIn) :
scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey),
ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), nHashType(nHashTypeIn) { }
Expand Down Expand Up @@ -876,7 +876,7 @@ class CValidationState {
unsigned char chRejectCode;
bool corruptionPossible;
public:
CValidationState() : mode(MODE_VALID), nDoS(0), corruptionPossible(false) {}
CValidationState() : mode(MODE_VALID), nDoS(0), chRejectCode(0), corruptionPossible(false) {}
bool DoS(int level, bool ret = false,
unsigned char chRejectCodeIn=0, std::string strRejectReasonIn="",
bool corruptionIn=false) {
Expand Down
7 changes: 5 additions & 2 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

using namespace std;

CTxMemPoolEntry::CTxMemPoolEntry()
CTxMemPoolEntry::CTxMemPoolEntry():
nFee(0), nTxSize(0), nTime(0), dPriority(0.0)
{
nHeight = MEMPOOL_HEIGHT;
}
Expand Down Expand Up @@ -345,7 +346,9 @@ class CMinerPolicyEstimator
};


CTxMemPool::CTxMemPool(const CFeeRate& _minRelayFee) : minRelayFee(_minRelayFee)
CTxMemPool::CTxMemPool(const CFeeRate& _minRelayFee) :
nTransactionsUpdated(0),
minRelayFee(_minRelayFee)
{
// Sanity checks off by default for performance, because otherwise
// accepting transactions becomes O(N^2) where N is the number
Expand Down
1 change: 1 addition & 0 deletions src/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ class CAccountingEntry
strOtherAccount.clear();
strComment.clear();
nOrderPos = -1;
nEntryNo = 0;
}

IMPLEMENT_SERIALIZE
Expand Down

0 comments on commit 8bdd287

Please sign in to comment.