parent
6b1594244e
commit
71c8669261
|
@ -1066,7 +1066,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
|
||||||
|
|
||||||
// just taking the address?
|
// just taking the address?
|
||||||
const bool addr(tok2 && (tok2->str() == "&" ||
|
const bool addr(tok2 && (tok2->str() == "&" ||
|
||||||
Token::simpleMatch(tok2->previous(), "& (")));
|
Token::simpleMatch(tok2->previous(), "& (")));
|
||||||
|
|
||||||
// taking address of 1 past end?
|
// taking address of 1 past end?
|
||||||
if (addr && totalIndex == totalElements)
|
if (addr && totalIndex == totalElements)
|
||||||
|
|
|
@ -1229,12 +1229,6 @@ void CheckOther::invalidScanfError(const Token *tok)
|
||||||
|
|
||||||
void CheckOther::checkWrongPrintfScanfArguments()
|
void CheckOther::checkWrongPrintfScanfArguments()
|
||||||
{
|
{
|
||||||
// This check is experimental. See #3311, #3313, #3339
|
|
||||||
// TODO : fix tickets and remove this condition. When the condition
|
|
||||||
// is removed the classInfo and getErrorMessages must be updated
|
|
||||||
if (!_settings->experimental)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!_settings->isEnabled("style"))
|
if (!_settings->isEnabled("style"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1300,8 +1294,15 @@ void CheckOther::checkWrongPrintfScanfArguments()
|
||||||
}
|
}
|
||||||
if (i == formatString.end())
|
if (i == formatString.end())
|
||||||
break;
|
break;
|
||||||
} else if (percent && std::isalpha(*i)) {
|
} else if (percent) {
|
||||||
numFormat++;
|
while (!std::isalpha(*i)) {
|
||||||
|
if (*i == '*')
|
||||||
|
numFormat++;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
if (*i != 'm') // %m is a non-standard extension that requires no parameter
|
||||||
|
numFormat++;
|
||||||
|
|
||||||
percent = false;
|
percent = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,7 +353,7 @@ public:
|
||||||
c.bitwiseOnBooleanError(0, "varname", "&&");
|
c.bitwiseOnBooleanError(0, "varname", "&&");
|
||||||
c.comparisonOfBoolExpressionWithIntError(0);
|
c.comparisonOfBoolExpressionWithIntError(0);
|
||||||
c.SuspiciousSemicolonError(0);
|
c.SuspiciousSemicolonError(0);
|
||||||
//c.wrongPrintfScanfArgumentsError(0,"printf",3,2);
|
c.wrongPrintfScanfArgumentsError(0,"printf",3,2);
|
||||||
c.cctypefunctionCallError(0, "funname", "value");
|
c.cctypefunctionCallError(0, "funname", "value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ public:
|
||||||
"* sizeof for numeric given as function argument\n"
|
"* sizeof for numeric given as function argument\n"
|
||||||
"* incorrect length arguments for 'substr' and 'strncmp'\n"
|
"* incorrect length arguments for 'substr' and 'strncmp'\n"
|
||||||
"* invalid usage of output stream. For example: std::cout << std::cout;'\n"
|
"* invalid usage of output stream. For example: std::cout << std::cout;'\n"
|
||||||
//"* wrong number of arguments given to 'printf' or 'scanf;'\n"
|
"* wrong number of arguments given to 'printf' or 'scanf;'\n"
|
||||||
|
|
||||||
// style
|
// style
|
||||||
"* C-style pointer cast in cpp file\n"
|
"* C-style pointer cast in cpp file\n"
|
||||||
|
|
|
@ -1997,6 +1997,9 @@ private:
|
||||||
" printf(\"%\"PRId64\"\n\", 123);\n"
|
" printf(\"%\"PRId64\"\n\", 123);\n"
|
||||||
" fprintf(stderr,\"%\"PRId64\"\n\", 123);\n"
|
" fprintf(stderr,\"%\"PRId64\"\n\", 123);\n"
|
||||||
" snprintf(str,10,\"%\"PRId64\"\n\", 123);\n"
|
" snprintf(str,10,\"%\"PRId64\"\n\", 123);\n"
|
||||||
|
" fprintf(stderr, \"error: %m\n\");\n" // #3339
|
||||||
|
" printf(\"string: %.*s\n\", len, string);\n" // #3311
|
||||||
|
" fprintf(stderr, \"%*cText.\n\", indent, ' ');\n" // #3313
|
||||||
"}\n",
|
"}\n",
|
||||||
"test.cpp",
|
"test.cpp",
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in New Issue