Skip to content

Commit

Permalink
scripted-diff: Use the C++11 keyword nullptr to denote the pointer li…
Browse files Browse the repository at this point in the history
…teral 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-
  • Loading branch information
practicalswift committed Aug 7, 2017
1 parent a9dd111 commit 90d4d89
Show file tree
Hide file tree
Showing 104 changed files with 563 additions and 563 deletions.
4 changes: 2 additions & 2 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int* pnId)
{
std::map<CNetAddr, int>::iterator it = mapAddr.find(addr);
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 @@ -220,11 +220,11 @@ class CAddrMan
FastRandomContext insecure_rand;

//! Find an entry.
CAddrInfo* Find(const CNetAddr& addr, int *pnId = NULL);
CAddrInfo* Find(const CNetAddr& 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
12 changes: 6 additions & 6 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,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 @@ -210,7 +210,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 Expand Up @@ -370,7 +370,7 @@ int CommandLineRPC(int argc, char *argv[])
nRet = EXIT_FAILURE;
}
catch (...) {
PrintExceptionContinue(NULL, "CommandLineRPC()");
PrintExceptionContinue(nullptr, "CommandLineRPC()");
throw;
}

Expand All @@ -397,7 +397,7 @@ int main(int argc, char* argv[])
PrintExceptionContinue(&e, "AppInitRPC()");
return EXIT_FAILURE;
} catch (...) {
PrintExceptionContinue(NULL, "AppInitRPC()");
PrintExceptionContinue(nullptr, "AppInitRPC()");
return EXIT_FAILURE;
}

Expand All @@ -408,7 +408,7 @@ int main(int argc, char* argv[])
catch (const std::exception& e) {
PrintExceptionContinue(&e, "CommandLineRPC()");
} catch (...) {
PrintExceptionContinue(NULL, "CommandLineRPC()");
PrintExceptionContinue(nullptr, "CommandLineRPC()");
}
return ret;
}
6 changes: 3 additions & 3 deletions src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ static int CommandLineRawTx(int argc, char* argv[])
nRet = EXIT_FAILURE;
}
catch (...) {
PrintExceptionContinue(NULL, "CommandLineRawTx()");
PrintExceptionContinue(nullptr, "CommandLineRawTx()");
throw;
}

Expand All @@ -845,7 +845,7 @@ int main(int argc, char* argv[])
PrintExceptionContinue(&e, "AppInitRawTx()");
return EXIT_FAILURE;
} catch (...) {
PrintExceptionContinue(NULL, "AppInitRawTx()");
PrintExceptionContinue(nullptr, "AppInitRawTx()");
return EXIT_FAILURE;
}

Expand All @@ -856,7 +856,7 @@ int main(int argc, char* argv[])
catch (const std::exception& e) {
PrintExceptionContinue(&e, "CommandLineRawTx()");
} catch (...) {
PrintExceptionContinue(NULL, "CommandLineRawTx()");
PrintExceptionContinue(nullptr, "CommandLineRawTx()");
}
return ret;
}
2 changes: 1 addition & 1 deletion src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ bool AppInit(int argc, char* argv[])
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInit()");
} catch (...) {
PrintExceptionContinue(NULL, "AppInit()");
PrintExceptionContinue(nullptr, "AppInit()");
}

if (!fRet)
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 @@ -437,20 +437,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 @@ -465,12 +465,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 @@ -482,7 +482,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 @@ -26,7 +26,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
6 changes: 3 additions & 3 deletions src/consensus/merkle.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
#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 root of the witness transactions in a block.
* *mutated is set to true if a duplicated subtree was found.
*/
uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated = NULL);
uint256 BlockWitnessMerkleRoot(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 @@ -92,7 +92,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::Output(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
Loading

0 comments on commit 90d4d89

Please sign in to comment.