gcc: Fixed some compiler warnings when using -Wsign-conversion. Ticket: #1487

This commit is contained in:
Daniel Marjamäki 2010-08-06 18:42:55 +02:00
parent 7fb44d1995
commit 146465a6ad
1 changed files with 8 additions and 7 deletions

View File

@ -2200,7 +2200,7 @@ void Tokenizer::simplifyTemplates()
break; break;
// get the position of the template name // get the position of the template name
unsigned int namepos = 0; unsigned char namepos = 0;
if (Token::Match(tok, "> class|struct %type% {|:")) if (Token::Match(tok, "> class|struct %type% {|:"))
namepos = 2; namepos = 2;
else if (Token::Match(tok, "> %type% *|&| %type% (")) else if (Token::Match(tok, "> %type% *|&| %type% ("))
@ -4840,7 +4840,7 @@ void Tokenizer::simplifyVarDecl()
{ {
Token *eq = tok2; Token *eq = tok2;
int parlevel = 0; unsigned int parlevel = 0;
while (tok2) while (tok2)
{ {
if (Token::Match(tok2, "[{(<]")) if (Token::Match(tok2, "[{(<]"))
@ -4850,7 +4850,7 @@ void Tokenizer::simplifyVarDecl()
else if (Token::Match(tok2, "[})>]")) else if (Token::Match(tok2, "[})>]"))
{ {
if (parlevel <= 0) if (parlevel == 0)
break; break;
--parlevel; --parlevel;
} }
@ -4858,7 +4858,7 @@ void Tokenizer::simplifyVarDecl()
else if (parlevel == 0 && strchr(";,", tok2->str()[0])) else if (parlevel == 0 && strchr(";,", tok2->str()[0]))
{ {
// "type var =" => "type var; var =" // "type var =" => "type var; var ="
Token *VarTok = type0->tokAt(typelen); Token *VarTok = type0->tokAt((int)typelen);
while (Token::Match(VarTok, "*|const")) while (Token::Match(VarTok, "*|const"))
VarTok = VarTok->next(); VarTok = VarTok->next();
insertTokens(eq, VarTok, 2); insertTokens(eq, VarTok, 2);
@ -7352,16 +7352,17 @@ std::string Tokenizer::simplifyString(const std::string &source)
// Hex value // Hex value
if (str[i+1] == '0' && str[i+2] == '0') if (str[i+1] == '0' && str[i+2] == '0')
str.replace(i, 3, "0"); str.replace(i, 3, "0");
else else if (i > 0)
{ {
// We will replace all other character as 'a' // We will replace all other character as 'a'
// If that causes problems in the future, this can // If that causes problems in the future, this can
// be improved. But for now, this should be OK. // be improved. But for now, this should be OK.
int n = 1; unsigned char n = 1;
while (n < 2 && std::isxdigit(str[i+1+n])) while (n < 2 && std::isxdigit(str[i+1+n]))
++n; ++n;
--i; --i;
str.replace(i, 2 + n, "a"); n += 2;
str.replace(i, n, "a");
} }
} }
else if (MathLib::isOctalDigit(str[i])) else if (MathLib::isOctalDigit(str[i]))