From 7ec825cd5d146a7d6f69bcaaa70f17d81fdfc098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 15 Sep 2012 15:54:52 +0200 Subject: [PATCH] Cppcheck: Fixed Cppcheck warning about variable scope --- lib/checkother.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 5c1f78d8b..04127a087 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3401,7 +3401,6 @@ void CheckOther::avoidDeadEndInNestedIfs() if (scope->type == Scope::eIf && toke) { - int flag = 0; const Token *op1Tok, *op2Tok; op1Tok = scope->classDef->tokAt(2); op2Tok = scope->classDef->tokAt(4); @@ -3409,6 +3408,8 @@ void CheckOther::avoidDeadEndInNestedIfs() if (scope->classDef->strAt(6) == "{") { if (scope->classDef->strAt(3) == "==") { + int flag = 0; + for (const Token* tok = scope->classStart; tok != scope->classEnd && flag == 0; tok = tok->next()) { if ((tok->str() == op1Tok->str() || tok->str() == op2Tok->str()) && tok->strAt(1) == "=") break; @@ -3428,6 +3429,8 @@ void CheckOther::avoidDeadEndInNestedIfs() } } } else if (scope->classDef->strAt(3) == "!=") { + int flag = 0; + for (const Token* tok = scope->classStart; tok != scope->classEnd && flag == 0; tok = tok->next()) { if ((tok->str() == op1Tok->str() || tok->str() == op2Tok->str()) && tok->strAt(1) == "=") break; @@ -3447,6 +3450,8 @@ void CheckOther::avoidDeadEndInNestedIfs() } } } else if (scope->classDef->strAt(3) == "<") { + int flag = 0; + for (const Token* tok = scope->classStart; tok != scope->classEnd && flag == 0; tok = tok->next()) { if ((tok->str() == op1Tok->str() || tok->str() == op2Tok->str()) && tok->strAt(1) == "=") break; @@ -3466,6 +3471,8 @@ void CheckOther::avoidDeadEndInNestedIfs() } } } else if (scope->classDef->strAt(3) == "<=") { + int flag = 0; + for (const Token* tok = scope->classStart; tok != scope->classEnd && flag == 0; tok = tok->next()) { if ((tok->str() == op1Tok->str() || tok->str() == op2Tok->str()) && tok->strAt(1) == "=") break;