@@ -1097,8 +1097,10 @@ void Tokenizer::simplifyTypedef()
10971097
10981098 if (good) {
10991099 // remove any extra qualification if present
1100- while (count--)
1100+ while (count) {
11011101 tok2->tokAt (-3 )->deleteNext (2 );
1102+ --count;
1103+ }
11021104
11031105 // remove global namespace if present
11041106 if (tok2->strAt (-1 ) == " ::" ) {
@@ -1589,10 +1591,11 @@ void Tokenizer::simplifyMulAndParens()
15891591 Token::Match (tokbegin->tokAt (-2 ), " [;{}&(] * &" ) ||
15901592 Token::Match (tokbegin->tokAt (-3 ), " [;{}&(] * ( &" )) {
15911593 // remove the excessive parentheses around the variable
1592- while (openpars-- ) {
1594+ while (openpars) {
15931595 tok->deleteNext ();
15941596 tokbegin->deleteNext ();
15951597 --closedpars;
1598+ --openpars;
15961599 }
15971600 } else
15981601 break ;
@@ -4998,7 +5001,7 @@ void Tokenizer::simplifyCasts()
49985001 if (Token::Match (tok->next (), " ( %type% ) %num%" ) && tok->next ()->link ()->previous ()->isStandardType ()) {
49995002 const MathLib::bigint value = MathLib::toLongNumber (tok->next ()->link ()->next ()->str ());
50005003 unsigned int bits = 8 * _typeSize[tok->next ()->link ()->previous ()->str ()];
5001- if (!tok->tokAt (2 )->isUnsigned ())
5004+ if (!tok->tokAt (2 )->isUnsigned () && bits > 0 )
50025005 bits--;
50035006 if (bits < 31 && value >= 0 && value < (1LL << bits)) {
50045007 Token::eraseTokens (tok, tok->next ()->link ()->next ());
@@ -6525,8 +6528,8 @@ bool Tokenizer::simplifyKnownVariables()
65256528 const Token * const valueToken = tok2->tokAt (4 );
65266529 std::string value (valueToken->str ());
65276530 if (tok2->str () == " sprintf" ) {
6528- std::string::size_type n = std::string::npos ;
6529- while ((n = value.find (" %%" ,n+1 )) != std::string::npos) {
6531+ std::string::difference_type n = - 1 ;
6532+ while (static_cast <std::string::size_type> (n = value.find (" %%" ,n+1 )) != std::string::npos) {
65306533 value.replace (n,2 ," %" );
65316534 }
65326535 }
0 commit comments