Skip to content

Commit 09fccf9

Browse files
committed
Revert "aseert ofstream good() after close()"
This reverts commit ad0bc6c.
1 parent 11654ad commit 09fccf9

File tree

7 files changed

+1
-40
lines changed

7 files changed

+1
-40
lines changed

cli/cppcheckexecutor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ CppCheckExecutor::~CppCheckExecutor()
8080
try
8181
{
8282
mErrorOutput->close();
83-
assert(mErrorOutput->good());
8483
}
8584
catch (const std::ios_base::failure&)
8685
{

gui/checkthread.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,11 @@ static bool executeCommand(std::string exe, std::vector<std::string> args, std::
7676
output = process.readAllStandardOutput().toStdString();
7777

7878
if (redirect.compare(0,3,"2> ") == 0) {
79-
std::ofstream fout;
79+
std::ofstream fout();
8080
fout.exceptions(std::ios_base::failbit | std::ios_base::badbit);
8181
fout.open(redirect.substr(3));
8282
assert(fout.is_open()); // If we ever disable exceptions, catch issues ASAP
8383
fout << process.readAllStandardError().toStdString();
84-
fout.close();
85-
assert(fout.good());
8684
}
8785
return process.exitCode() == 0;
8886
}

lib/analyzerinfo.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,13 @@ void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::
8080
const std::string afile = getFilename(fs.filename);
8181
fout << afile << ".a" << (++fileCount[afile]) << ":" << fs.cfg << ":" << Path::simplifyPath(Path::fromNativeSeparators(fs.filename)) << std::endl;
8282
}
83-
84-
assert(fout.good());
8583
}
8684

8785
void AnalyzerInformation::close()
8886
{
8987
if (mOutputStream.is_open()) {
9088
mOutputStream << "</analyzerinfo>\n";
91-
9289
mOutputStream.close();
93-
assert(mOutputStream.good());
9490
}
9591
}
9692

lib/cppcheck.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ static void createDumpFile(const Settings& settings,
288288
fout.exceptions(std::ios_base::failbit | std::ios_base::badbit);
289289
fout.open(getCtuInfoFileName(dumpFile));
290290
assert(fout.is_open()); // If we ever disable exceptions, catch issues ASAP
291-
fout.close();
292-
assert(fout.good()); // If we ever disable exceptions, catch issues ASAP
293291
}
294292

295293
std::string language;
@@ -423,7 +421,6 @@ CppCheck::~CppCheck()
423421
try
424422
{
425423
mPlistFile.close();
426-
assert(mPlistFile.good()); // If we ever disable exceptions, catch issues ASAP
427424
}
428425
catch (const std::ios_base::failure&)
429426
{
@@ -531,8 +528,6 @@ unsigned int CppCheck::check(const std::string &path)
531528
fout.open(clangcmd);
532529
assert(fout.is_open()); // If we ever disable exceptions, catch issues ASAP
533530
fout << exe << " " << args2 << " " << redirect2 << std::endl;
534-
fout.close();
535-
assert(fout.good()); // If we ever disable exceptions, catch issues ASAP
536531
} else if (mSettings.verbose && !mSettings.quiet) {
537532
mErrorLogger.reportOut(exe + " " + args2);
538533
}
@@ -567,8 +562,6 @@ unsigned int CppCheck::check(const std::string &path)
567562
fout.open(clangAst);
568563
assert(fout.is_open()); // If we ever disable exceptions, catch issues ASAP
569564
fout << output2 << std::endl;
570-
fout.close();
571-
assert(fout.good()); // If we ever disable exceptions, catch issues ASAP
572565
}
573566

574567
try {
@@ -602,7 +595,6 @@ unsigned int CppCheck::check(const std::string &path)
602595
fdump << "</dump>" << std::endl;
603596
fdump << "</dumps>" << std::endl;
604597
fdump.close();
605-
assert(fdump.good()); // If we ever disable exceptions, catch issues ASAP
606598
}
607599

608600
// run addons
@@ -698,9 +690,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
698690

699691
if (mPlistFile.is_open()) {
700692
mPlistFile << ErrorLogger::plistFooter();
701-
702693
mPlistFile.close();
703-
assert(mPlistFile.good()); // If we ever disable exceptions, catch issues ASAP
704694
}
705695

706696
CheckUnusedFunctions checkUnusedFunctions(nullptr, nullptr, nullptr);
@@ -1041,7 +1031,6 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
10411031
if (fdump.is_open()) {
10421032
fdump << "</dumps>" << std::endl;
10431033
fdump.close();
1044-
assert(fdump.good()); // If we ever disable exceptions, catch issues ASAP
10451034
}
10461035

10471036
executeAddons(dumpFile);
@@ -1470,9 +1459,6 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
14701459

14711460
for (const std::string& f: files)
14721461
fout << f << std::endl;
1473-
1474-
fout.close();
1475-
assert(fout.good()); // If we ever disable exceptions, catch issues ASAP
14761462
}
14771463

14781464
for (const std::string &addon : mSettings.addons) {
@@ -1736,9 +1722,6 @@ void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings)
17361722
assert(fcmd.is_open()); // If we ever disable exceptions, catch issues ASAP
17371723

17381724
fcmd << istr.str();
1739-
1740-
fcmd.close();
1741-
assert(fcmd.good()); // If we ever disable exceptions, catch issues ASAP
17421725
}
17431726

17441727
while (std::getline(istr, line)) {

lib/summaries.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ std::string Summaries::create(const Tokenizer *tokenizer, const std::string &cfg
9292
assert(fout.is_open()); // If we ever disable exceptions, catch issues ASAP
9393

9494
fout << ostr.str();
95-
96-
fout.close();
97-
assert(fout.good()); // If we ever disable exceptions, catch issues ASAP
9895
}
9996
}
10097

test/helpers.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ ScopedFile::ScopedFile(std::string name, const std::string &content, std::string
6060
assert(of.is_open()); // If we ever disable exceptions, catch issues ASAP
6161

6262
of << content;
63-
64-
of.close();
65-
assert(of.good()); // If we ever disable exceptions, catch issues ASAP
6663
}
6764

6865
ScopedFile::~ScopedFile() {

tools/dmake.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ static int write_vcxproj(const std::string &proj_name, const std::function<void(
223223

224224
out << outstr;
225225

226-
out.close();
227-
assert(out.good()); // If we ever disable exceptions, catch issues ASAP
228-
229226
return EXIT_SUCCESS;
230227
}
231228

@@ -424,9 +421,6 @@ int main(int argc, char **argv)
424421
fout1 << " \\\n" << std::string(11, ' ');
425422
}
426423
fout1 << "\n";
427-
428-
fout1.close();
429-
assert(fout1.good()); // If we ever disable exceptions, catch issues ASAP
430424
}
431425

432426
static const char makefile[] = "Makefile";
@@ -768,8 +762,5 @@ int main(int argc, char **argv)
768762
compilefiles(fout, extfiles, emptyString);
769763
compilefiles(fout, toolsfiles, "${INCLUDE_FOR_LIB}");
770764

771-
fout.close();
772-
assert(fout.good()); // If we ever disable exceptions, catch issues ASAP
773-
774765
return 0;
775766
}

0 commit comments

Comments
 (0)