Fixed false positive #5578
This commit is contained in:
parent
af161fc361
commit
3a4b7e5c07
|
@ -250,7 +250,7 @@ void CheckIO::checkFileUsage()
|
||||||
case Filepointer::POSITIONING:
|
case Filepointer::POSITIONING:
|
||||||
if (f.mode == CLOSED)
|
if (f.mode == CLOSED)
|
||||||
useClosedFileError(tok);
|
useClosedFileError(tok);
|
||||||
else if (f.append_mode == Filepointer::APPEND && _settings->isEnabled("warning"))
|
else if (f.append_mode == Filepointer::APPEND && tok->str() != "fflush" && _settings->isEnabled("warning"))
|
||||||
seekOnAppendedFileError(tok);
|
seekOnAppendedFileError(tok);
|
||||||
break;
|
break;
|
||||||
case Filepointer::READ:
|
case Filepointer::READ:
|
||||||
|
|
|
@ -550,6 +550,12 @@ private:
|
||||||
" fseek(f, 0, SEEK_SET);\n"
|
" fseek(f, 0, SEEK_SET);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Repositioning operation performed on a file opened in append mode has no effect.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (warning) Repositioning operation performed on a file opened in append mode has no effect.\n", errout.str());
|
||||||
|
|
||||||
|
check("void foo() {\n"
|
||||||
|
" FILE* f = fopen(\"\", \"a\");\n"
|
||||||
|
" fflush(f);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str()); // #5578
|
||||||
}
|
}
|
||||||
|
|
||||||
void fflushOnInputStream() {
|
void fflushOnInputStream() {
|
||||||
|
|
Loading…
Reference in New Issue