Skip to content

Commit 70a67ea

Browse files
committed
Change some more 0 literals into nullptr.
1 parent 23efc68 commit 70a67ea

21 files changed

Lines changed: 71 additions & 71 deletions

lib/checkbufferoverrun.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void CheckBufferOverrun::arrayIndexOutOfBoundsError(const Token *tok, const Arra
7979
errmsg << " out of bounds.";
8080
}
8181

82-
const Token *condition = 0;
82+
const Token *condition = nullptr;
8383
for (unsigned int i = 0; i < index.size(); ++i) {
8484
if (condition == nullptr)
8585
condition = index[i].condition;
@@ -428,7 +428,7 @@ static bool for3(const Token * const tok,
428428
std::string &max_value,
429429
const bool maxMinFlipped)
430430
{
431-
assert(tok != 0);
431+
assert(tok != nullptr);
432432
if (Token::Match(tok, "%varid% = %num% + %varid% )", varid)) {
433433
if (!for_maxvalue(tok->tokAt(2), min_value, max_value))
434434
return false;
@@ -1498,7 +1498,7 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
14981498
std::string type;
14991499

15001500
// varid : The variable id for the array
1501-
const Variable *var = 0;
1501+
const Variable *var = nullptr;
15021502

15031503
// nextTok : number of tokens used in variable declaration - used to skip to next statement.
15041504
int nextTok = 0;

lib/checkclass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,8 @@ void CheckClass::checkMemset()
917917
continue;
918918

919919

920-
const Token *typeTok = 0;
921-
const Scope *type = 0;
920+
const Token *typeTok = nullptr;
921+
const Scope *type = nullptr;
922922
if (Token::Match(arg3, "sizeof ( %type% ) )"))
923923
typeTok = arg3->tokAt(2);
924924
else if (Token::Match(arg3, "sizeof ( %type% :: %type% ) )"))
@@ -1252,7 +1252,7 @@ bool CheckClass::hasAllocation(const Function *func, const Scope* scope)
12521252
return true;
12531253

12541254
// check for deallocating memory
1255-
const Token *var = 0;
1255+
const Token *var = nullptr;
12561256
if (Token::Match(tok, "free ( %var%"))
12571257
var = tok->tokAt(2);
12581258
else if (Token::Match(tok, "delete [ ] %var%"))
@@ -1395,7 +1395,7 @@ void CheckClass::virtualDestructor()
13951395

13961396
// Find the destructor declaration for the base class.
13971397
const Function *base_destructor = derivedFromScope->getDestructor();
1398-
const Token *base = 0;
1398+
const Token *base = nullptr;
13991399
if (base_destructor)
14001400
base = base_destructor->token;
14011401

lib/checkexceptionsafety.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void CheckExceptionSafety::deallocThrow()
9898
const unsigned int varid(tok->varId());
9999

100100
// Token where throw occurs
101-
const Token *ThrowToken = 0;
101+
const Token *ThrowToken = nullptr;
102102

103103
// is there a throw after the deallocation?
104104
const Token* const end2 = tok->scope()->classEnd;

lib/checkio.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void CheckIO::invalidScanf()
318318
for (std::size_t j = 0; j < functions; ++j) {
319319
const Scope * scope = symbolDatabase->functionScopes[j];
320320
for (const Token *tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
321-
const Token *formatToken = 0;
321+
const Token *formatToken = nullptr;
322322
if (Token::Match(tok, "scanf|vscanf ( %str% ,"))
323323
formatToken = tok->tokAt(2);
324324
else if (Token::Match(tok, "sscanf|vsscanf|fscanf|vfscanf (")) {
@@ -424,7 +424,7 @@ static bool findFormat(unsigned int arg, const Token *firstArg,
424424
argTok->variable()->dimensionKnown(0) &&
425425
argTok->variable()->dimension(0) != 0)))) {
426426
*formatArgTok = argTok->nextArgument();
427-
*formatStringTok = 0;
427+
*formatStringTok = nullptr;
428428
if (argTok->variable()) {
429429
const Token *varTok = argTok->variable()->nameToken();
430430
if (Token::Match(varTok, "%var% ; %var% = %str% ;") &&
@@ -1330,7 +1330,7 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings)
13301330
tok = tok->tokAt(2);
13311331
if (!tok || !(tok->type() == Token::eVariable || tok->type() == Token::eFunction))
13321332
return;
1333-
const Token *varTok = 0;
1333+
const Token *varTok = nullptr;
13341334
const Token *tok1 = tok->next();
13351335
for (; tok1; tok1 = tok1->next()) {
13361336
if (tok1->str() == "," || tok1->str() == ")") {

lib/checkmemoryleak.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
629629

630630
Token *ftok = getcode(func->functionScope->classStart->next(), callstack, 0, alloctype, dealloctype, false, 1);
631631
simplifycode(ftok);
632-
const char *ret = 0;
632+
const char *ret = nullptr;
633633
if (Token::simpleMatch(ftok, "; alloc ; }"))
634634
ret = "alloc";
635635
else if (Token::simpleMatch(ftok, "; dealloc ; }"))
@@ -688,7 +688,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
688688
while (func_ && func_->str() == ";")
689689
func_ = func_->next();
690690

691-
const char *ret = 0;
691+
const char *ret = nullptr;
692692
/** @todo handle "goto" */
693693
if (Token::findsimplematch(func_, "dealloc"))
694694
ret = "dealloc";
@@ -782,7 +782,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
782782
;
783783

784784
else {
785-
const Token *skipToToken = 0;
785+
const Token *skipToToken = nullptr;
786786

787787
// scan statement for interesting keywords / varid
788788
for (tok2 = tok->next(); tok2; tok2 = tok2->next()) {

lib/checknullpointer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
629629
continue;
630630

631631
// vartok : token for the variable
632-
const Token *vartok = 0;
633-
const Token *checkConditionStart = 0;
632+
const Token *vartok = nullptr;
633+
const Token *checkConditionStart = nullptr;
634634
if (Token::Match(tok, "( ! %var% )|&&")) {
635635
vartok = tok->tokAt(2);
636636
checkConditionStart = vartok->next();
@@ -892,7 +892,7 @@ void CheckNullPointer::nullConstantDereference()
892892
}
893893
}
894894

895-
const Variable *ovar = 0;
895+
const Variable *ovar = nullptr;
896896
if (Token::Match(tok, "0 ==|!= %var% !!."))
897897
ovar = tok->tokAt(2)->variable();
898898
else if (Token::Match(tok, "%var% ==|!= 0"))

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ void CheckOther::invalidPointerCast()
514514
continue;
515515

516516
// Find casted variable
517-
const Variable *var = 0;
517+
const Variable *var = nullptr;
518518
bool allocation = false;
519519
bool ref = false;
520520
if (Token::Match(nextTok, "new %type%"))

lib/checksizeof.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void CheckSizeof::checkSizeofForPointerSize()
113113
for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
114114
const Token *tokVar;
115115
const Token *variable;
116-
const Token *variable2 = 0;
116+
const Token *variable2 = nullptr;
117117

118118
// Find any function that may use sizeof on a pointer
119119
// Once leaving those tests, it is mandatory to have:

lib/checkstl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ void CheckStl::pushback()
655655
if (varId == 0)
656656
continue;
657657

658-
const Token *pushbackTok = 0;
658+
const Token *pushbackTok = nullptr;
659659

660660
// Count { and } for tok3
661661
const Token *tok3 = tok2->tokAt(20);
@@ -1077,7 +1077,7 @@ void CheckStl::missingComparison()
10771077
break;
10781078
}
10791079

1080-
const Token *incrementToken = 0;
1080+
const Token *incrementToken = nullptr;
10811081

10821082
// Parse loop..
10831083
for (const Token *tok3 = i->classStart; tok3 != i->classEnd; tok3 = tok3->next()) {

lib/checkunusedfunctions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
5151
if (tok->previous() && tok->previous()->str() == ">")
5252
continue;
5353

54-
const Token *funcname = 0;
54+
const Token *funcname = nullptr;
5555

5656
if (Token::Match(tok, "%type% %var% ("))
5757
funcname = tok->next();
@@ -188,7 +188,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
188188
}
189189

190190

191-
const Token *funcname = 0;
191+
const Token *funcname = nullptr;
192192

193193
if (Token::Match(tok->next(), "%var% (")) {
194194
funcname = tok->next();

0 commit comments

Comments
 (0)