Fix some compiler warnings in checkio.cpp. Fix some (potential) multi-threading issues in checkinternal.cpp
This commit is contained in:
parent
a884362817
commit
eebb5b8c77
|
@ -118,7 +118,7 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
|
|||
// Check | usage: Count characters before the symbol
|
||||
char_count = 0;
|
||||
for (std::string::size_type pos = 0; pos < pattern.size(); ++pos) {
|
||||
char c = pattern[pos];
|
||||
const char c = pattern[pos];
|
||||
|
||||
if (c == ' ') {
|
||||
char_count = 0;
|
||||
|
@ -144,25 +144,25 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> magics = make_container< std::set<std::string> > ()
|
||||
"%any%"
|
||||
"%bool%"
|
||||
"%char%"
|
||||
"%comp%"
|
||||
"%num%"
|
||||
"%op%"
|
||||
"%cop%"
|
||||
"%or%"
|
||||
"%oror%"
|
||||
"%str%"
|
||||
"%type%"
|
||||
"%name%"
|
||||
"%varid%";
|
||||
}
|
||||
|
||||
void CheckInternal::checkMissingPercentCharacter()
|
||||
{
|
||||
static std::set<std::string> magics;
|
||||
if (magics.empty()) {
|
||||
magics.insert("%any%");
|
||||
magics.insert("%bool%");
|
||||
magics.insert("%char%");
|
||||
magics.insert("%comp%");
|
||||
magics.insert("%num%");
|
||||
magics.insert("%op%");
|
||||
magics.insert("%cop%");
|
||||
magics.insert("%or%");
|
||||
magics.insert("%oror%");
|
||||
magics.insert("%str%");
|
||||
magics.insert("%type%");
|
||||
magics.insert("%name%");
|
||||
magics.insert("%varid%");
|
||||
}
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (!Token::simpleMatch(tok, "Token :: Match (") && !Token::simpleMatch(tok, "Token :: findmatch ("))
|
||||
continue;
|
||||
|
@ -200,26 +200,26 @@ void CheckInternal::checkMissingPercentCharacter()
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> knownPatterns = make_container< std::set<std::string> > ()
|
||||
<< "%any%"
|
||||
<< "%bool%"
|
||||
<< "%char%"
|
||||
<< "%comp%"
|
||||
<< "%name%"
|
||||
<< "%num%"
|
||||
<< "%op%"
|
||||
<< "%cop%"
|
||||
<< "%or%"
|
||||
<< "%oror%"
|
||||
<< "%str%"
|
||||
<< "%type%"
|
||||
<< "%var%"
|
||||
<< "%varid%";
|
||||
}
|
||||
|
||||
void CheckInternal::checkUnknownPattern()
|
||||
{
|
||||
static std::set<std::string> knownPatterns;
|
||||
if (knownPatterns.empty()) {
|
||||
knownPatterns.insert("%any%");
|
||||
knownPatterns.insert("%bool%");
|
||||
knownPatterns.insert("%char%");
|
||||
knownPatterns.insert("%comp%");
|
||||
knownPatterns.insert("%name%");
|
||||
knownPatterns.insert("%num%");
|
||||
knownPatterns.insert("%op%");
|
||||
knownPatterns.insert("%cop%");
|
||||
knownPatterns.insert("%or%");
|
||||
knownPatterns.insert("%oror%");
|
||||
knownPatterns.insert("%str%");
|
||||
knownPatterns.insert("%type%");
|
||||
knownPatterns.insert("%var%");
|
||||
knownPatterns.insert("%varid%");
|
||||
}
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (!Token::simpleMatch(tok, "Token :: Match (") && !Token::simpleMatch(tok, "Token :: findmatch ("))
|
||||
continue;
|
||||
|
@ -238,9 +238,9 @@ void CheckInternal::checkUnknownPattern()
|
|||
else if (pattern[i] == ']')
|
||||
inBrackets = false;
|
||||
else if (pattern[i] == '%' && pattern[i+1] != ' ' && pattern[i+1] != '|' && !inBrackets) {
|
||||
std::string::size_type end = pattern.find('%', i+1);
|
||||
const std::string::size_type end = pattern.find('%', i+1);
|
||||
if (end != std::string::npos) {
|
||||
std::string s = pattern.substr(i, end-i+1);
|
||||
const std::string s = pattern.substr(i, end-i+1);
|
||||
if (knownPatterns.find(s) == knownPatterns.end())
|
||||
unknownPatternError(tok, s);
|
||||
}
|
||||
|
|
|
@ -1375,15 +1375,15 @@ void CheckIO::checkWrongPrintfScanfArguments()
|
|||
// We currently only support string literals, variables, and functions.
|
||||
/// @todo add non-string literals, and generic expressions
|
||||
|
||||
CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings, bool isCPP)
|
||||
: variableInfo(0)
|
||||
, typeToken(0)
|
||||
, functionInfo(0)
|
||||
CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings, bool _isCPP)
|
||||
: variableInfo(nullptr)
|
||||
, typeToken(nullptr)
|
||||
, functionInfo(nullptr)
|
||||
, element(false)
|
||||
, _template(false)
|
||||
, address(false)
|
||||
, tempToken(0)
|
||||
, isCPP(isCPP)
|
||||
, isCPP(_isCPP)
|
||||
, tempToken(nullptr)
|
||||
{
|
||||
if (tok) {
|
||||
if (tok->type() == Token::eString) {
|
||||
|
|
Loading…
Reference in New Issue