Fix some GCC warnings regarding the sign conversion.
This commit is contained in:
parent
f7fe665b00
commit
433f4640a9
|
@ -26,6 +26,7 @@
|
|||
#include <cstdlib> // EXIT_SUCCESS and EXIT_FAILURE
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
|
||||
#include "cmdlineparser.h"
|
||||
#include "filelister.h"
|
||||
|
@ -106,7 +107,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
|||
bool warned = false;
|
||||
std::vector<std::string> ignored = parser.GetIgnoredPaths();
|
||||
std::vector<std::string>::iterator iterIgnored = ignored.begin();
|
||||
for (int i = (int)ignored.size() - 1; i >= 0; i--) {
|
||||
for (unsigned int i = ignored.size() - 1; i != UINT_MAX; --i) {
|
||||
const std::string extension = Path::getFilenameExtension(ignored[i]);
|
||||
if (extension == ".h" || extension == ".hpp") {
|
||||
ignored.erase(iterIgnored + i);
|
||||
|
@ -120,14 +121,14 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
|||
|
||||
PathMatch matcher(parser.GetIgnoredPaths());
|
||||
std::vector<std::string>::iterator iterBegin = filenames.begin();
|
||||
for (int i = (int)filenames.size() - 1; i >= 0; i--) {
|
||||
for (unsigned int i = filenames.size() - 1; i != UINT_MAX; i--) {
|
||||
#if defined(_WIN32)
|
||||
// For Windows we want case-insensitive path matching
|
||||
const bool caseSensitive = false;
|
||||
#else
|
||||
const bool caseSensitive = true;
|
||||
#endif
|
||||
if (matcher.Match(filenames[(unsigned int)i], caseSensitive))
|
||||
if (matcher.Match(filenames[i], caseSensitive))
|
||||
filenames.erase(iterBegin + i);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1212,7 +1212,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
|
|||
|
||||
void CheckBufferOverrun::checkReadlinkBufferUsage(const Token* tok, const Token *scope_begin, const MathLib::bigint total_size, const bool is_readlinkat)
|
||||
{
|
||||
unsigned int param_offset = is_readlinkat ? 2 : 0;
|
||||
unsigned char param_offset = is_readlinkat ? 2 : 0;
|
||||
const std::string funcname = is_readlinkat ? "readlinkat" : "readlink";
|
||||
|
||||
const MathLib::bigint n = MathLib::toLongNumber(tok->strAt(6 + param_offset));
|
||||
|
|
|
@ -1353,24 +1353,24 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok)
|
|||
return false;
|
||||
}
|
||||
|
||||
static int countParameters(const Token *tok)
|
||||
static unsigned int countParameters(const Token *tok)
|
||||
{
|
||||
if (Token::Match(tok->tokAt(2), "void| )"))
|
||||
return 0;
|
||||
|
||||
int numpar = 1;
|
||||
int parlevel = 0;
|
||||
unsigned int numpar = 1;
|
||||
unsigned int parlevel = 0;
|
||||
for (; tok; tok = tok->next()) {
|
||||
if (tok->str() == "(")
|
||||
++parlevel;
|
||||
|
||||
else if (tok->str() == ")") {
|
||||
if (parlevel <= 1)
|
||||
if (!parlevel)
|
||||
break;
|
||||
--parlevel;
|
||||
}
|
||||
|
||||
else if (parlevel == 1 && tok->str() == ",") {
|
||||
else if (!parlevel && tok->str() == ",") {
|
||||
++numpar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
|
|||
// Check for [xyz] usage - but exclude standalone square brackets
|
||||
unsigned int char_count = 0;
|
||||
for (string::size_type pos = 0; pos < pattern.size(); ++pos) {
|
||||
unsigned char c = pattern[pos];
|
||||
char c = pattern[pos];
|
||||
|
||||
if (c == ' ') {
|
||||
char_count = 0;
|
||||
|
@ -99,7 +99,7 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
|
|||
// Check | usage: Count characters before the symbol
|
||||
char_count = 0;
|
||||
for (string::size_type pos = 0; pos < pattern.size(); ++pos) {
|
||||
unsigned char c = pattern[pos];
|
||||
char c = pattern[pos];
|
||||
|
||||
if (c == ' ') {
|
||||
char_count = 0;
|
||||
|
|
|
@ -1075,8 +1075,8 @@ void CheckStl::string_c_strError(const Token *tok)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckStl::checkAutoPointer()
|
||||
{
|
||||
std::set<int> autoPtrVarId;
|
||||
std::set<int>::const_iterator iter;
|
||||
std::set<unsigned int> autoPtrVarId;
|
||||
std::set<unsigned int>::const_iterator iter;
|
||||
static const char STL_CONTAINER_LIST[] = "bitset|deque|list|map|multimap|multiset|priority_queue|queue|set|stack|hash_map|hash_multimap|hash_set|vector";
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
|
|
@ -956,7 +956,7 @@ void Tokenizer::simplifyTypedef()
|
|||
Token *argFuncRetEnd = 0;
|
||||
Token *funcStart = 0;
|
||||
Token *funcEnd = 0;
|
||||
unsigned int offset = 1;
|
||||
unsigned short offset = 1;
|
||||
bool function = false;
|
||||
bool functionPtr = false;
|
||||
bool functionRef = false;
|
||||
|
|
|
@ -210,9 +210,10 @@ int main(int argc, char **argv)
|
|||
makeConditionalVariable(fout, "CXXFLAGS", "-O2 -DNDEBUG -Wall");
|
||||
} else {
|
||||
// TODO: add more compiler warnings.
|
||||
// -Wlogical-op : doesn't work on older GCC
|
||||
// -Wconversion : too many warnings
|
||||
// -Wsign-conversion : too many warnings
|
||||
// -Wlogical-op : doesn't work on older GCC
|
||||
// -Wconversion : too many warnings
|
||||
// -Wsign-conversion : too many warnings
|
||||
// -Wunreachable-code : some GCC versions report lots of warnings
|
||||
|
||||
// The _GLIBCXX_DEBUG doesn't work in cygwin
|
||||
makeConditionalVariable(fout, "CXXFLAGS",
|
||||
|
|
Loading…
Reference in New Issue