parent
6b1594244e
commit
71c8669261
|
@ -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) {
|
||||||
|
while (!std::isalpha(*i)) {
|
||||||
|
if (*i == '*')
|
||||||
numFormat++;
|
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