Skip to content

Commit

Permalink
NULL, 0 -> nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
div72 committed Jun 13, 2021
1 parent 43a49cb commit 4c4f1f5
Show file tree
Hide file tree
Showing 97 changed files with 459 additions and 468 deletions.
4 changes: 2 additions & 2 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,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 @@ -201,11 +201,11 @@ class CAddrMan
protected:

// 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 found node is 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
3 changes: 1 addition & 2 deletions src/base58.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ inline bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet)
for (const char* p = psz; *p; p++)
{
const char* p1 = strchr(pszBase58, *p);
if (p1 == NULL)
{
if (p1 == nullptr) {
while (isspace(*p))
p++;
if (*p != '\0')
Expand Down
26 changes: 13 additions & 13 deletions src/bignum.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ class CAutoBN_CTX
CAutoBN_CTX()
{
pctx = BN_CTX_new();
if (pctx == NULL)
throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned NULL");
if (pctx == nullptr)
throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned nullptr");
}

~CAutoBN_CTX()
{
if (pctx != NULL)
if (pctx != nullptr)
BN_CTX_free(pctx);
}

operator BN_CTX*() { return pctx; }
BN_CTX& operator*() { return *pctx; }
BN_CTX** operator&() { return &pctx; }
bool operator!() { return (pctx == NULL); }
bool operator!() { return (pctx == nullptr); }
};

/* RAII wrapper for BIGNUM instance */
Expand All @@ -62,8 +62,8 @@ class CBigNumBase
CBigNumBase()
: pbn(BN_new())
{
if (pbn == NULL)
throw bignum_error("CBigNum : BN_new() returned NULL");
if (pbn == nullptr)
throw bignum_error("CBigNum : BN_new() returned nullptr");
}

~CBigNumBase()
Expand Down Expand Up @@ -214,7 +214,7 @@ class CBigNum : public CBigNumBase

uint64_t getuint64()
{
unsigned int nSize = BN_bn2mpi(pbn, NULL);
unsigned int nSize = BN_bn2mpi(pbn, nullptr);
if (nSize < 4)
return 0;
std::vector<unsigned char> vch(nSize);
Expand Down Expand Up @@ -284,7 +284,7 @@ class CBigNum : public CBigNumBase

uint256 getuint256() const
{
unsigned int nSize = BN_bn2mpi(pbn, NULL);
unsigned int nSize = BN_bn2mpi(pbn, nullptr);
if (nSize < 4)
return uint256();
std::vector<unsigned char> vch(nSize);
Expand Down Expand Up @@ -315,7 +315,7 @@ class CBigNum : public CBigNumBase

std::vector<unsigned char> getvch() const
{
unsigned int nSize = BN_bn2mpi(pbn, NULL);
unsigned int nSize = BN_bn2mpi(pbn, nullptr);
if (nSize <= 4)
return std::vector<unsigned char>();
std::vector<unsigned char> vch(nSize);
Expand All @@ -339,7 +339,7 @@ class CBigNum : public CBigNumBase

unsigned int GetCompact() const
{
unsigned int nSize = BN_bn2mpi(pbn, NULL);
unsigned int nSize = BN_bn2mpi(pbn, nullptr);
std::vector<unsigned char> vch(nSize);
nSize -= 4;
BN_bn2mpi(pbn, &vch[0]);
Expand Down Expand Up @@ -504,7 +504,7 @@ class CBigNum : public CBigNumBase
*/
static CBigNum generatePrime(const unsigned int numBits, bool safe = false) {
CBigNum ret;
if(!BN_generate_prime_ex(&ret, numBits, safe, NULL, NULL, NULL))
if (!BN_generate_prime_ex(&ret, numBits, safe, nullptr, nullptr, nullptr))
throw bignum_error("CBigNum::generatePrime*= :BN_generate_prime_ex");
return ret;
}
Expand All @@ -530,7 +530,7 @@ class CBigNum : public CBigNumBase
*/
bool isPrime(const int checks=BN_prime_checks) const {
CAutoBN_CTX pctx;
int ret = BN_is_prime_ex(pbn, checks, pctx, NULL);
int ret = BN_is_prime_ex(pbn, checks, pctx, nullptr);
if(ret < 0){
throw bignum_error("CBigNum::isPrime :BN_is_prime_ex");
}
Expand Down Expand Up @@ -688,7 +688,7 @@ inline const CBigNum operator/(const CBigNum& a, const CBigNum& b)
{
CAutoBN_CTX pctx;
CBigNum r;
if (!BN_div(&r, NULL, &a, &b, pctx))
if (!BN_div(&r, nullptr, &a, &b, pctx))
throw bignum_error("CBigNum::operator/ : BN_div failed");
return r;
}
Expand Down
4 changes: 2 additions & 2 deletions src/crypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector<unsigned
if(!ctx)
throw std::runtime_error("Error allocating cipher context");

if (fOk) fOk = EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, vchKey.data(), vchIV.data());
if (fOk) fOk = EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), nullptr, vchKey.data(), vchIV.data());
if (fOk) fOk = EVP_EncryptUpdate(ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen);
if (fOk) fOk = EVP_EncryptFinal_ex(ctx, (&vchCiphertext[0])+nCLen, &nFLen);
EVP_CIPHER_CTX_free(ctx);
Expand Down Expand Up @@ -101,7 +101,7 @@ bool CCrypter::Decrypt(const std::vector<unsigned char>& vchCiphertext, CKeyingM
if(!ctx)
throw std::runtime_error("Error allocating cipher context");

if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, vchKey.data(), vchIV.data());
if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), nullptr, vchKey.data(), vchIV.data());
if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen);
if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0])+nPLen, &nFLen);
EVP_CIPHER_CTX_free(ctx);
Expand Down
8 changes: 4 additions & 4 deletions src/gridcoin/scraper/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ std::string Http::GetEtag(
const std::string &url,
const std::string &userpass)
{
struct curl_slist* headers = NULL;
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, "Accept: */*");
headers = curl_slist_append(headers, "User-Agent: curl/7.63.0");
std::string header;
Expand Down Expand Up @@ -272,7 +272,7 @@ std::string Http::GetLatestVersionResponse()
std::string header;
std::string url = gArgs.GetArg("-updatecheckurl", "https://api.github.com/repos/gridcoin-community/Gridcoin-Research/releases/latest");

struct curl_slist* headers = NULL;
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, "Accept: */*");
headers = curl_slist_append(headers, "User-Agent: curl/7.63.0");

Expand Down Expand Up @@ -318,7 +318,7 @@ void Http::DownloadSnapshot()
std::string buffer;
std::string header;

struct curl_slist* headers = NULL;
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, "Accept: */*");
headers = curl_slist_append(headers, "User-Agent: curl/7.63.0");

Expand Down Expand Up @@ -385,7 +385,7 @@ std::string Http::GetSnapshotSHA256()
std::string header;
std::string url = gArgs.GetArg("-snapshotsha256url", "https://snapshot.gridcoin.us/snapshot.zip.sha256");

struct curl_slist* headers = NULL;
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, "Accept: */*");
headers = curl_slist_append(headers, "User-Agent: curl/7.63.0");

Expand Down
2 changes: 1 addition & 1 deletion src/gridcoin/scraper/scraper_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int CSplitBlob::addPartData(CDataStream&& vData)
/* missing data; use the supplied data */
/* prevent calling the Complete callback FIXME: make this look better */
cntPartsRcvd--;
CSplitBlob::RecvPart(0, vData);
CSplitBlob::RecvPart(nullptr, vData);
cntPartsRcvd++;
}
return n;
Expand Down
2 changes: 1 addition & 1 deletion src/gridcoin/staking/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static bool SelectBlockFromCandidates(
{
bool fSelected = false;
arith_uint256 hashBest = 0;
*pindexSelected = (const CBlockIndex*) 0;
*pindexSelected = nullptr;

for (auto const& item : vSortedByTimestamp)
{
Expand Down
4 changes: 2 additions & 2 deletions src/gridcoinresearchd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ bool AppInit(int argc, char* argv[])
} catch (...) {
LogPrintf("AppInit()Exception2");

PrintException(NULL, "AppInit()");
PrintException(nullptr, "AppInit()");
}
if(fRet)
{
while (!ShutdownRequested())
MilliSleep(500);
}

Shutdown(NULL);
Shutdown(nullptr);

// delete thread handler
threads->interruptAll();
Expand Down
6 changes: 3 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ bool AppInit2(ThreadHandlerPtr threads)
#ifdef _MSC_VER
// Turn off Microsoft heap dump noise
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
_CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, 0));
#endif
#if _MSC_VER >= 1400
// Disable confusing "helpful" text message on abort, Ctrl-C
Expand All @@ -733,7 +733,7 @@ bool AppInit2(ThreadHandlerPtr threads)
#endif
typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD);
PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy");
if (setProcDEPPol != NULL) setProcDEPPol(PROCESS_DEP_ENABLE);
if (setProcDEPPol != nullptr) setProcDEPPol(PROCESS_DEP_ENABLE);
#endif
#ifndef WIN32
umask(077);
Expand Down Expand Up @@ -1368,7 +1368,7 @@ bool AppInit2(ThreadHandlerPtr threads)
LogPrintf("mapAddressBook.size() = %" PRIszu, pwalletMain->mapAddressBook.size());
}

if (!threads->createThread(StartNode, NULL, "Start Thread"))
if (!threads->createThread(StartNode, nullptr, "Start Thread"))
InitError(_("Error: could not start node"));

if (fServer) StartRPCThreads();
Expand Down
Loading

0 comments on commit 4c4f1f5

Please sign in to comment.