Merge pull request #4825

8d657a6 Fixing compiler warning C4800: 'type' forcing value to bool 'true' or 'false' (ENikS)
This commit is contained in:
Pieter Wuille 2014-09-16 04:43:49 +02:00
commit dc54e9db98
No known key found for this signature in database
GPG key ID: 8F653255C87992E0
9 changed files with 23 additions and 23 deletions

View file

@ -46,7 +46,7 @@ static inline size_t GetSystemPageSize()
bool MemoryPageLocker::Lock(const void *addr, size_t len) bool MemoryPageLocker::Lock(const void *addr, size_t len)
{ {
#ifdef WIN32 #ifdef WIN32
return VirtualLock(const_cast<void*>(addr), len); return VirtualLock(const_cast<void*>(addr), len) != 0;
#else #else
return mlock(addr, len) == 0; return mlock(addr, len) == 0;
#endif #endif
@ -55,7 +55,7 @@ bool MemoryPageLocker::Lock(const void *addr, size_t len)
bool MemoryPageLocker::Unlock(const void *addr, size_t len) bool MemoryPageLocker::Unlock(const void *addr, size_t len)
{ {
#ifdef WIN32 #ifdef WIN32
return VirtualUnlock(const_cast<void*>(addr), len); return VirtualUnlock(const_cast<void*>(addr), len) != 0;
#else #else
return munlock(addr, len) == 0; return munlock(addr, len) == 0;
#endif #endif

View file

@ -195,8 +195,8 @@ public:
::Unserialize(s, VARINT(nCode), nType, nVersion); ::Unserialize(s, VARINT(nCode), nType, nVersion);
fCoinBase = nCode & 1; fCoinBase = nCode & 1;
std::vector<bool> vAvail(2, false); std::vector<bool> vAvail(2, false);
vAvail[0] = nCode & 2; vAvail[0] = (nCode & 2) != 0;
vAvail[1] = nCode & 4; vAvail[1] = (nCode & 4) != 0;
unsigned int nMaskCode = (nCode / 8) + ((nCode & 6) != 0 ? 0 : 1); unsigned int nMaskCode = (nCode / 8) + ((nCode & 6) != 0 ? 0 : 1);
// spentness bitmask // spentness bitmask
while (nMaskCode > 0) { while (nMaskCode > 0) {

View file

@ -62,9 +62,9 @@ bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector<unsigned
bool fOk = true; bool fOk = true;
EVP_CIPHER_CTX_init(&ctx); EVP_CIPHER_CTX_init(&ctx);
if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0;
if (fOk) fOk = EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen); if (fOk) fOk = EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen) != 0;
if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0])+nCLen, &nFLen); if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0]) + nCLen, &nFLen) != 0;
EVP_CIPHER_CTX_cleanup(&ctx); EVP_CIPHER_CTX_cleanup(&ctx);
if (!fOk) return false; if (!fOk) return false;
@ -89,9 +89,9 @@ bool CCrypter::Decrypt(const std::vector<unsigned char>& vchCiphertext, CKeyingM
bool fOk = true; bool fOk = true;
EVP_CIPHER_CTX_init(&ctx); EVP_CIPHER_CTX_init(&ctx);
if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0;
if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen) != 0;
if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0])+nPLen, &nFLen); if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0]) + nPLen, &nFLen) != 0;
EVP_CIPHER_CTX_cleanup(&ctx); EVP_CIPHER_CTX_cleanup(&ctx);
if (!fOk) return false; if (!fOk) return false;

View file

@ -232,7 +232,7 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
if (pszFile == NULL) if (pszFile == NULL)
return; return;
bool fCreate = strchr(pszMode, 'c'); bool fCreate = strchr(pszMode, 'c') != NULL;
unsigned int nFlags = DB_THREAD; unsigned int nFlags = DB_THREAD;
if (fCreate) if (fCreate)
nFlags |= DB_CREATE; nFlags |= DB_CREATE;

View file

@ -198,7 +198,7 @@ bool static Bind(const CService &addr, unsigned int flags) {
if (!(flags & BF_EXPLICIT) && IsLimited(addr)) if (!(flags & BF_EXPLICIT) && IsLimited(addr))
return false; return false;
std::string strError; std::string strError;
if (!BindListenPort(addr, strError, flags & BF_WHITELIST)) { if (!BindListenPort(addr, strError, (flags & BF_WHITELIST) != 0)) {
if (flags & BF_REPORT_ERROR) if (flags & BF_REPORT_ERROR)
return InitError(strError); return InitError(strError);
return false; return false;
@ -694,7 +694,7 @@ bool AppInit2(boost::thread_group& threadGroup)
std::string strWalletFile = GetArg("-wallet", "wallet.dat"); std::string strWalletFile = GetArg("-wallet", "wallet.dat");
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
fIsBareMultisigStd = GetArg("-permitbaremultisig", true); fIsBareMultisigStd = GetArg("-permitbaremultisig", true) != 0;
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
// Sanity check // Sanity check

View file

@ -172,9 +172,9 @@ public:
bool ret; bool ret;
BIGNUM bn; BIGNUM bn;
BN_init(&bn); BN_init(&bn);
ret = BN_bin2bn(vch, 32, &bn); ret = BN_bin2bn(vch, 32, &bn) != NULL;
assert(ret); assert(ret);
ret = EC_KEY_regenerate_key(pkey, &bn); ret = EC_KEY_regenerate_key(pkey, &bn) != 0;
assert(ret); assert(ret);
BN_clear_free(&bn); BN_clear_free(&bn);
} }
@ -217,7 +217,7 @@ public:
bool SetPubKey(const CPubKey &pubkey) { bool SetPubKey(const CPubKey &pubkey) {
const unsigned char* pbegin = pubkey.begin(); const unsigned char* pbegin = pubkey.begin();
return o2i_ECPublicKey(&pkey, &pbegin, pubkey.size()); return o2i_ECPublicKey(&pkey, &pbegin, pubkey.size()) != NULL;
} }
bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) { bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) {
@ -553,7 +553,7 @@ bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned cha
if (vchSig.size() != 65) if (vchSig.size() != 65)
return false; return false;
int recid = (vchSig[0] - 27) & 3; int recid = (vchSig[0] - 27) & 3;
bool fComp = (vchSig[0] - 27) & 4; bool fComp = ((vchSig[0] - 27) & 4) != 0;
#ifdef USE_SECP256K1 #ifdef USE_SECP256K1
int pubkeylen = 65; int pubkeylen = 65;
if (!secp256k1_ecdsa_recover_compact((const unsigned char*)&hash, 32, &vchSig[1], (unsigned char*)begin(), &pubkeylen, fComp, recid)) if (!secp256k1_ecdsa_recover_compact((const unsigned char*)&hash, 32, &vchSig[1], (unsigned char*)begin(), &pubkeylen, fComp, recid))

View file

@ -1536,7 +1536,7 @@ Value gettransaction(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");
const CWalletTx& wtx = pwalletMain->mapWallet[hash]; const CWalletTx& wtx = pwalletMain->mapWallet[hash];
int64_t nCredit = wtx.GetCredit(filter); int64_t nCredit = wtx.GetCredit(filter != 0);
int64_t nDebit = wtx.GetDebit(filter); int64_t nDebit = wtx.GetDebit(filter);
int64_t nNet = nCredit - nDebit; int64_t nNet = nCredit - nDebit;
int64_t nFee = (wtx.IsFromMe(filter) ? wtx.GetValueOut() - nDebit : 0); int64_t nFee = (wtx.IsFromMe(filter) ? wtx.GetValueOut() - nDebit : 0);

View file

@ -495,7 +495,7 @@ bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
{ {
#ifdef WIN32 #ifdef WIN32
return MoveFileExA(src.string().c_str(), dest.string().c_str(), return MoveFileExA(src.string().c_str(), dest.string().c_str(),
MOVEFILE_REPLACE_EXISTING); MOVEFILE_REPLACE_EXISTING) != 0;
#else #else
int rc = std::rename(src.string().c_str(), dest.string().c_str()); int rc = std::rename(src.string().c_str(), dest.string().c_str());
return (rc == 0); return (rc == 0);

View file

@ -639,7 +639,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
{ {
{ {
AssertLockHeld(cs_wallet); AssertLockHeld(cs_wallet);
bool fExisted = mapWallet.count(tx.GetHash()); bool fExisted = mapWallet.count(tx.GetHash()) != 0;
if (fExisted && !fUpdate) return false; if (fExisted && !fUpdate) return false;
if (fExisted || IsMine(tx) || IsFromMe(tx)) if (fExisted || IsMine(tx) || IsFromMe(tx))
{ {
@ -1131,7 +1131,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO && if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
!IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 && !IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 &&
(!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i)))
vCoins.push_back(COutput(pcoin, i, nDepth, mine & ISMINE_SPENDABLE)); vCoins.push_back(COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO));
} }
} }
} }
@ -1657,7 +1657,7 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const string& strNam
if (!strPurpose.empty()) /* update purpose only if requested */ if (!strPurpose.empty()) /* update purpose only if requested */
mapAddressBook[address].purpose = strPurpose; mapAddressBook[address].purpose = strPurpose;
} }
NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address), NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address) != ISMINE_NO,
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) ); strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
if (!fFileBacked) if (!fFileBacked)
return false; return false;
@ -1683,7 +1683,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
mapAddressBook.erase(address); mapAddressBook.erase(address);
} }
NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address), "", CT_DELETED); NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address) != ISMINE_NO, "", CT_DELETED);
if (!fFileBacked) if (!fFileBacked)
return false; return false;