From fec0c46af0054c5fcd715b15fca63ed99f6645a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 30 Jul 2017 14:53:58 +0200 Subject: [PATCH] Refactoring, use continue in loop --- lib/checkbufferoverrun.cpp | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 0d05d9876..14dcaab7a 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1198,30 +1198,30 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable() for (std::list::const_iterator scope = symbolDatabase->scopeList.cbegin(); scope != symbolDatabase->scopeList.cend(); ++scope) { std::map arrayInfos; for (std::list::const_iterator var = scope->varlist.cbegin(); var != scope->varlist.cend(); ++var) { - if (var->isArray() && var->dimension(0) > 0) { - _errorLogger->reportProgress(_tokenizer->list.getSourceFilePath(), - "Check (BufferOverrun::checkGlobalAndLocalVariable 1)", - var->nameToken()->progressValue()); + if (!var->isArray() || var->dimension(0) <= 0) + continue; + _errorLogger->reportProgress(_tokenizer->list.getSourceFilePath(), + "Check (BufferOverrun::checkGlobalAndLocalVariable 1)", + var->nameToken()->progressValue()); - if (_tokenizer->isMaxTime()) - return; + if (_tokenizer->isMaxTime()) + return; - const Token *tok = var->nameToken(); - do { - if (tok->str() == "{") { - if (Token::simpleMatch(tok->previous(), "= {")) - tok = tok->link(); - else - break; - } - tok = tok->next(); - } while (tok && tok->str() != ";"); - if (!tok) - break; - if (tok->str() == "{") - tok = tok->next(); - arrayInfos[var->declarationId()] = ArrayInfo(&*var, symbolDatabase, var->declarationId()); - } + const Token *tok = var->nameToken(); + do { + if (tok->str() == "{") { + if (Token::simpleMatch(tok->previous(), "= {")) + tok = tok->link(); + else + break; + } + tok = tok->next(); + } while (tok && tok->str() != ";"); + if (!tok) + break; + if (tok->str() == "{") + tok = tok->next(); + arrayInfos[var->declarationId()] = ArrayInfo(&*var, symbolDatabase, var->declarationId()); } if (!arrayInfos.empty()) checkScope(scope->classStart ? scope->classStart : _tokenizer->tokens(), arrayInfos);