Skip to content

Commit

Permalink
bitcoin#10483 scripted-diff: Use the C++11 keyword nullptr to denote…
Browse files Browse the repository at this point in the history
… the pointer literal instead of the macro NULL

-BEGIN VERIFY SCRIPT-
sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
-END VERIFY SCRIPT-

Signed-off-by: Pasta <pasta@dashboost.org>
  • Loading branch information
PastaPastaPasta committed Aug 7, 2019
1 parent b4e54e9 commit 33e1687
Show file tree
Hide file tree
Showing 111 changed files with 577 additions and 577 deletions.
4 changes: 2 additions & 2 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ CAddrInfo* CAddrMan::Find(const CService& addr, int* pnId)

std::map<CService, int>::iterator it = mapAddr.find(addr2);
if (it == mapAddr.end())
return NULL;
return nullptr;
if (pnId)
*pnId = (*it).second;
std::map<int, CAddrInfo>::iterator it2 = mapInfo.find((*it).second);
if (it2 != mapInfo.end())
return &(*it2).second;
return NULL;
return nullptr;
}

CAddrInfo* CAddrMan::Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId)
Expand Down
4 changes: 2 additions & 2 deletions src/addrman.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ class CAddrMan
FastRandomContext insecure_rand;

//! Find an entry.
CAddrInfo* Find(const CService& addr, int *pnId = NULL);
CAddrInfo* Find(const CService& addr, int *pnId = nullptr);

//! find an entry, creating it if necessary.
//! nTime and nServices of the found node are updated, if necessary.
CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = NULL);
CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = nullptr);

//! Swap two elements in vRandom.
void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2);
Expand Down
2 changes: 1 addition & 1 deletion src/arith_uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class arith_uint256 : public base_uint<256> {
* complexities of the sign bit and using base 256 are probably an
* implementation accident.
*/
arith_uint256& SetCompact(uint32_t nCompact, bool *pfNegative = NULL, bool *pfOverflow = NULL);
arith_uint256& SetCompact(uint32_t nCompact, bool *pfNegative = nullptr, bool *pfOverflow = nullptr);
uint32_t GetCompact(bool fNegative = false) const;

friend uint256 ArithToUint256(const arith_uint256 &);
Expand Down
2 changes: 1 addition & 1 deletion src/base58.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch)
while (*psz && !isspace(*psz)) {
// Decode base58 character
const char* ch = strchr(pszBase58, *psz);
if (ch == NULL)
if (ch == nullptr)
return false;
// Apply "b256 = b256 * 58 + ch".
int carry = ch - pszBase58;
Expand Down
4 changes: 2 additions & 2 deletions src/base58.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/**
* Encode a byte sequence as a base58-encoded string.
* pbegin and pend cannot be NULL, unless both are.
* pbegin and pend cannot be nullptr, unless both are.
*/
std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend);

Expand All @@ -38,7 +38,7 @@ std::string EncodeBase58(const std::vector<unsigned char>& vch);
/**
* Decode a base58-encoded string (psz) into a byte vector (vchRet).
* return true if decoding is successful.
* psz cannot be NULL.
* psz cannot be nullptr.
*/
bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet);

Expand Down
2 changes: 1 addition & 1 deletion src/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ benchmark::BenchRunner::BenchmarkMap &benchmark::BenchRunner::benchmarks() {

static double gettimedouble(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
gettimeofday(&tv, nullptr);
return tv.tv_usec * 0.000001 + tv.tv_sec;
}

Expand Down
14 changes: 7 additions & 7 deletions src/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* CChain implementation
*/
void CChain::SetTip(CBlockIndex *pindex) {
if (pindex == NULL) {
if (pindex == nullptr) {
vChain.clear();
return;
}
Expand Down Expand Up @@ -49,8 +49,8 @@ CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
}

const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const {
if (pindex == NULL) {
return NULL;
if (pindex == nullptr) {
return nullptr;
}
if (pindex->nHeight > Height())
pindex = pindex->GetAncestor(Height());
Expand All @@ -63,7 +63,7 @@ CBlockIndex* CChain::FindEarliestAtLeast(int64_t nTime) const
{
std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(vChain.begin(), vChain.end(), nTime,
[](CBlockIndex* pBlock, const int64_t& time) -> bool { return pBlock->GetBlockTimeMax() < time; });
return (lower == vChain.end() ? NULL : *lower);
return (lower == vChain.end() ? nullptr : *lower);
}

/** Turn the lowest '1' bit in the binary representation of a number into a '0'. */
Expand All @@ -83,14 +83,14 @@ int static inline GetSkipHeight(int height) {
CBlockIndex* CBlockIndex::GetAncestor(int height)
{
if (height > nHeight || height < 0)
return NULL;
return nullptr;

CBlockIndex* pindexWalk = this;
int heightWalk = nHeight;
while (heightWalk > height) {
int heightSkip = GetSkipHeight(heightWalk);
int heightSkipPrev = GetSkipHeight(heightWalk - 1);
if (pindexWalk->pskip != NULL &&
if (pindexWalk->pskip != nullptr &&
(heightSkip == height ||
(heightSkip > height && !(heightSkipPrev < heightSkip - 2 &&
heightSkipPrev >= height)))) {
Expand Down Expand Up @@ -150,7 +150,7 @@ int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& fr
}

/** Find the last common ancestor two blocks have.
* Both pa and pb must be non-NULL. */
* Both pa and pb must be non-nullptr. */
const CBlockIndex* LastCommonAncestor(const CBlockIndex* pa, const CBlockIndex* pb) {
if (pa->nHeight > pb->nHeight) {
pa = pa->GetAncestor(pb->nHeight);
Expand Down
24 changes: 12 additions & 12 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ class CBlockIndex

void SetNull()
{
phashBlock = NULL;
pprev = NULL;
pskip = NULL;
phashBlock = nullptr;
pprev = nullptr;
pskip = nullptr;
nHeight = 0;
nFile = 0;
nDataPos = 0;
Expand Down Expand Up @@ -444,20 +444,20 @@ class CChain {
std::vector<CBlockIndex*> vChain;

public:
/** Returns the index entry for the genesis block of this chain, or NULL if none. */
/** Returns the index entry for the genesis block of this chain, or nullptr if none. */
CBlockIndex *Genesis() const {
return vChain.size() > 0 ? vChain[0] : NULL;
return vChain.size() > 0 ? vChain[0] : nullptr;
}

/** Returns the index entry for the tip of this chain, or NULL if none. */
/** Returns the index entry for the tip of this chain, or nullptr if none. */
CBlockIndex *Tip() const {
return vChain.size() > 0 ? vChain[vChain.size() - 1] : NULL;
return vChain.size() > 0 ? vChain[vChain.size() - 1] : nullptr;
}

/** Returns the index entry at a particular height in this chain, or NULL if no such height exists. */
/** Returns the index entry at a particular height in this chain, or nullptr if no such height exists. */
CBlockIndex *operator[](int nHeight) const {
if (nHeight < 0 || nHeight >= (int)vChain.size())
return NULL;
return nullptr;
return vChain[nHeight];
}

Expand All @@ -472,12 +472,12 @@ class CChain {
return (*this)[pindex->nHeight] == pindex;
}

/** Find the successor of a block in this chain, or NULL if the given index is not found or is the tip. */
/** Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip. */
CBlockIndex *Next(const CBlockIndex *pindex) const {
if (Contains(pindex))
return (*this)[pindex->nHeight + 1];
else
return NULL;
return nullptr;
}

/** Return the maximal height in the chain. Is equal to chain.Tip() ? chain.Tip()->nHeight : -1. */
Expand All @@ -489,7 +489,7 @@ class CChain {
void SetTip(CBlockIndex *pindex);

/** Return a CBlockLocator that refers to a block in this chain (by default the tip). */
CBlockLocator GetLocator(const CBlockIndex *pindex = NULL) const;
CBlockLocator GetLocator(const CBlockIndex *pindex = nullptr) const;

/** Find the last common block between this chain and a block index entry. */
const CBlockIndex *FindFork(const CBlockIndex *pindex) const;
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Checkpoints {
if (t != mapBlockIndex.end())
return t->second;
}
return NULL;
return nullptr;
}

} // namespace Checkpoints
10 changes: 5 additions & 5 deletions src/checkqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ class CCheckQueueControl
CCheckQueueControl& operator=(const CCheckQueueControl&) = delete;
explicit CCheckQueueControl(CCheckQueue<T> * const pqueueIn) : pqueue(pqueueIn), fDone(false)
{
// passed queue is supposed to be unused, or NULL
if (pqueue != NULL) {
// passed queue is supposed to be unused, or nullptr
if (pqueue != nullptr) {
ENTER_CRITICAL_SECTION(pqueue->ControlMutex);
}
}

bool Wait()
{
if (pqueue == NULL)
if (pqueue == nullptr)
return true;
bool fRet = pqueue->Wait();
fDone = true;
Expand All @@ -200,15 +200,15 @@ class CCheckQueueControl

void Add(std::vector<T>& vChecks)
{
if (pqueue != NULL)
if (pqueue != nullptr)
pqueue->Add(vChecks);
}

~CCheckQueueControl()
{
if (!fDone)
Wait();
if (pqueue != NULL) {
if (pqueue != nullptr) {
LEAVE_CRITICAL_SECTION(pqueue->ControlMutex);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/consensus/merkle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot

uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated) {
uint256 hash;
MerkleComputation(leaves, &hash, mutated, -1, NULL);
MerkleComputation(leaves, &hash, mutated, -1, nullptr);
return hash;
}

std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position) {
std::vector<uint256> ret;
MerkleComputation(leaves, NULL, NULL, position, &ret);
MerkleComputation(leaves, nullptr, nullptr, position, &ret);
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions src/consensus/merkle.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
#include "primitives/block.h"
#include "uint256.h"

uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated = NULL);
uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated = nullptr);
std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position);
uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint256>& branch, uint32_t position);

/*
* Compute the Merkle root of the transactions in a block.
* *mutated is set to true if a duplicated subtree was found.
*/
uint256 BlockMerkleRoot(const CBlock& block, bool* mutated = NULL);
uint256 BlockMerkleRoot(const CBlock& block, bool* mutated = nullptr);

/*
* Compute the Merkle branch for the tree of transactions in a block, for a
Expand Down
2 changes: 1 addition & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco
// this won't decode correctly formatted public keys in Pubkey or Multisig scripts due to
// the restrictions on the pubkey formats (see IsCompressedOrUncompressedPubKey) being incongruous with the
// checks in CheckSignatureEncoding.
if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, NULL)) {
if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, nullptr)) {
const unsigned char chSigHashType = vch.back();
if (mapSigHashTypes.count(chSigHashType)) {
strSigHashDecode = "[" + mapSigHashTypes.find(chSigHashType)->second + "]";
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/chacha20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void ChaCha20::Keystream(unsigned char* c, size_t bytes)
{
uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
uint32_t j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
unsigned char *ctarget = NULL;
unsigned char *ctarget = nullptr;
unsigned char tmp[64];
unsigned int i;

Expand Down
6 changes: 3 additions & 3 deletions src/dash-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ static void http_request_done(struct evhttp_request *req, void *ctx)
{
HTTPReply *reply = static_cast<HTTPReply*>(ctx);

if (req == NULL) {
/* If req is NULL, it means an error occurred while connecting: the
if (req == nullptr) {
/* If req is nullptr, it means an error occurred while connecting: the
* error code will have been passed to http_error_cb.
*/
reply->status = 0;
Expand Down Expand Up @@ -223,7 +223,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)

HTTPReply response;
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
if (req == NULL)
if (req == nullptr)
throw std::runtime_error("create http request failed");
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
evhttp_request_set_error_cb(req.get(), http_error_cb);
Expand Down
12 changes: 6 additions & 6 deletions src/dbwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static leveldb::Options GetOptions(size_t nCacheSize)

CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bool fWipe, bool obfuscate)
{
penv = NULL;
penv = nullptr;
readoptions.verify_checksums = true;
iteroptions.verify_checksums = true;
iteroptions.fill_cache = false;
Expand Down Expand Up @@ -144,15 +144,15 @@ CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bo
CDBWrapper::~CDBWrapper()
{
delete pdb;
pdb = NULL;
pdb = nullptr;
delete options.filter_policy;
options.filter_policy = NULL;
options.filter_policy = nullptr;
delete options.info_log;
options.info_log = NULL;
options.info_log = nullptr;
delete options.block_cache;
options.block_cache = NULL;
options.block_cache = nullptr;
delete penv;
options.env = NULL;
options.env = nullptr;
}

bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync)
Expand Down
2 changes: 1 addition & 1 deletion src/dbwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class CDBWrapper
{
friend const std::vector<unsigned char>& dbwrapper_private::GetObfuscateKey(const CDBWrapper &w);
private:
//! custom environment this database is using (may be NULL in case of default environment)
//! custom environment this database is using (may be nullptr in case of default environment)
leveldb::Env* penv;

//! database options used
Expand Down
2 changes: 1 addition & 1 deletion src/dsnotificationinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
void CDSNotificationInterface::InitializeCurrentBlockTip()
{
LOCK(cs_main);
UpdatedBlockTip(chainActive.Tip(), NULL, IsInitialBlockDownload());
UpdatedBlockTip(chainActive.Tip(), nullptr, IsInitialBlockDownload());
}

void CDSNotificationInterface::AcceptedBlockHeader(const CBlockIndex *pindexNew)
Expand Down
2 changes: 1 addition & 1 deletion src/evo/providertx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ bool CheckProUpServTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CVa
}
}

// we can only check the signature if pindexPrev != NULL and the MN is known
// we can only check the signature if pindexPrev != nullptr and the MN is known
if (!CheckInputsHash(tx, ptx, state)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/evo/simplifiedmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CSimplifiedMNList
CSimplifiedMNList(const std::vector<CSimplifiedMNListEntry>& smlEntries);
CSimplifiedMNList(const CDeterministicMNList& dmnList);

uint256 CalcMerkleRoot(bool* pmutated = NULL) const;
uint256 CalcMerkleRoot(bool* pmutated = nullptr) const;
};

/// P2P messages
Expand Down
4 changes: 2 additions & 2 deletions src/governance/governance-classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void CGovernanceTriggerManager::CleanAndRemove()
CGovernanceObject* pObj = nullptr;
CSuperblock_sptr& pSuperblock = it->second;
if (!pSuperblock) {
LogPrint(BCLog::GOBJECT, "CGovernanceTriggerManager::CleanAndRemove -- NULL superblock marked for removal\n");
LogPrint(BCLog::GOBJECT, "CGovernanceTriggerManager::CleanAndRemove -- nullptr superblock marked for removal\n");
remove = true;
} else {
pObj = governance.FindGovernanceObject(it->first);
Expand All @@ -170,7 +170,7 @@ void CGovernanceTriggerManager::CleanAndRemove()
LogPrint(BCLog::GOBJECT, "CGovernanceTriggerManager::CleanAndRemove -- %smarked for removal\n", remove ? "" : "NOT ");

if (remove) {
std::string strDataAsPlainString = "NULL";
std::string strDataAsPlainString = "nullptr";
if (pObj) {
strDataAsPlainString = pObj->GetDataAsPlainString();
}
Expand Down
Loading

0 comments on commit 33e1687

Please sign in to comment.