From 4c8f7fa7fbf67e4a5901c507b05e9ff52903c31c Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sat, 10 Oct 2009 22:54:58 +0300 Subject: [PATCH 1/3] Get rid of a compiler warning. conversion from 'size_t' to 'int', possible loss of data --- src/tokenize.cpp | 18 +++++++++--------- src/tokenize.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tokenize.cpp b/src/tokenize.cpp index f37287d54..b0b5bb679 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -123,7 +123,7 @@ void Tokenizer::addtoken(const char str[], const unsigned int lineno, const unsi -int Tokenizer::sizeOfType(const Token *type) const +unsigned int Tokenizer::sizeOfType(const Token *type) const { if (!type || !type->strAt(0)) return 0; @@ -1435,8 +1435,8 @@ void Tokenizer::simplifySizeof() Token::Match(tok->tokAt(-2), "[;{}(,] %type% %var% [;),]") || Token::Match(tok->tokAt(-3), "[;{}(,] const %type% %var% [;),]")) { - const int size = sizeOfType(tok->previous()); - if (size <= 0) + const unsigned int size = sizeOfType(tok->previous()); + if (size == 0) { continue; } @@ -1447,8 +1447,8 @@ void Tokenizer::simplifySizeof() else if (Token::Match(tok->tokAt(-1), "%type% %var% [ %num% ] [;=]") || Token::Match(tok->tokAt(-2), "%type% * %var% [ %num% ] [;=]")) { - int size = sizeOfType(tok->tokAt(-1)); - if (size <= 0) + unsigned int size = sizeOfType(tok->tokAt(-1)); + if (size == 0) continue; sizeOfVar[varId] = MathLib::toString(size * MathLib::toLongNumber(tok->strAt(2))); @@ -1464,8 +1464,8 @@ void Tokenizer::simplifySizeof() else if (Token::Match(tok->tokAt(-1), "%type% %var% [ ] = %str% ;")) { - int size = sizeOfType(tok->tokAt(4)); - if (size <= 0) + unsigned int size = sizeOfType(tok->tokAt(4)); + if (size == 0) continue; sizeOfVar[varId] = MathLib::toString(size); @@ -1574,7 +1574,7 @@ void Tokenizer::simplifySizeof() else if (Token::Match(tok, "sizeof ( %type% )")) { - int size = sizeOfType(tok->tokAt(2)); + unsigned int size = sizeOfType(tok->tokAt(2)); if (size > 0) { tok->str(MathLib::toString(size)); @@ -1585,7 +1585,7 @@ void Tokenizer::simplifySizeof() else if (Token::Match(tok, "sizeof ( * %var% )") || Token::Match(tok, "sizeof ( %var% [ %num% ] )")) { // Some default value.. - int sz = 100; + unsigned int sz = 100; unsigned int varid = tok->tokAt((tok->tokAt(2)->str() == "*") ? 3 : 2)->varId(); if (varid != 0) diff --git a/src/tokenize.h b/src/tokenize.h index de0b46cd3..a3ad6990b 100644 --- a/src/tokenize.h +++ b/src/tokenize.h @@ -90,7 +90,7 @@ public: * @param type Token which will contain e.g. "int", "*", or string. * @return sizeof for given type, or 0 if it can't be calculated. */ - int sizeOfType(const Token *type) const; + unsigned int sizeOfType(const Token *type) const; const std::vector *getFiles() const; From efbe65dad6630f0a44030b1bf88b7db0c10bed20 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sat, 10 Oct 2009 22:58:45 +0300 Subject: [PATCH 2/3] Get rid of compiler warning warning C4127: conditional expression is constant --- src/preprocessor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preprocessor.cpp b/src/preprocessor.cpp index 9a216c3db..8ee0f0ece 100644 --- a/src/preprocessor.cpp +++ b/src/preprocessor.cpp @@ -1027,7 +1027,7 @@ std::string Preprocessor::getcode(const std::string &filedata, std::string cfg, std::map cfgmap; { std::string::size_type pos = 0; - while (true) + for (;;) { std::string::size_type pos2 = cfg.find_first_of(";=", pos); if (pos2 == std::string::npos) From a7547f15e31521dd955ee2608c5507b5526401ed Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sat, 10 Oct 2009 23:01:33 +0300 Subject: [PATCH 3/3] Fix compiler warning warning C4512: 'PreprocessorMacro' : assignment operator could not be generated --- src/preprocessor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/preprocessor.cpp b/src/preprocessor.cpp index 8ee0f0ece..337be9ed9 100644 --- a/src/preprocessor.cpp +++ b/src/preprocessor.cpp @@ -1314,6 +1314,8 @@ private: /** The macro has parantheses but no parameters.. "AAA()" */ bool _nopar; + /** disabled assignment operator */ + void operator=(const PreprocessorMacro &); public: /** * @param macro The code after #define, until end of line,