Skip to content

Commit 99dd370

Browse files
committed
remove always true if statements
1 parent cf03e17 commit 99dd370

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

lib/cppcheck.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -561,19 +561,17 @@ unsigned int CppCheck::check(const std::string &path)
561561
fdump.exceptions(std::ios_base::failbit | std::ios_base::badbit);
562562
std::string dumpFile;
563563
createDumpFile(mSettings, path, fdump, dumpFile);
564-
if (fdump.is_open()) {
565-
fdump << "<dump cfg=\"\">" << std::endl;
566-
for (const ErrorMessage& errmsg: compilerWarnings)
567-
fdump << " <clang-warning file=\"" << toxml(errmsg.callStack.front().getfile()) << "\" line=\"" << errmsg.callStack.front().line << "\" column=\"" << errmsg.callStack.front().column << "\" message=\"" << toxml(errmsg.shortMessage()) << "\"/>\n";
568-
fdump << " <standards>" << std::endl;
569-
fdump << " <c version=\"" << mSettings.standards.getC() << "\"/>" << std::endl;
570-
fdump << " <cpp version=\"" << mSettings.standards.getCPP() << "\"/>" << std::endl;
571-
fdump << " </standards>" << std::endl;
572-
tokenizer.dump(fdump);
573-
fdump << "</dump>" << std::endl;
574-
fdump << "</dumps>" << std::endl;
575-
fdump.close();
576-
}
564+
fdump << "<dump cfg=\"\">" << std::endl;
565+
for (const ErrorMessage& errmsg: compilerWarnings)
566+
fdump << " <clang-warning file=\"" << toxml(errmsg.callStack.front().getfile()) << "\" line=\"" << errmsg.callStack.front().line << "\" column=\"" << errmsg.callStack.front().column << "\" message=\"" << toxml(errmsg.shortMessage()) << "\"/>\n";
567+
fdump << " <standards>" << std::endl;
568+
fdump << " <c version=\"" << mSettings.standards.getC() << "\"/>" << std::endl;
569+
fdump << " <cpp version=\"" << mSettings.standards.getCPP() << "\"/>" << std::endl;
570+
fdump << " </standards>" << std::endl;
571+
tokenizer.dump(fdump);
572+
fdump << "</dump>" << std::endl;
573+
fdump << "</dumps>" << std::endl;
574+
fdump.close();
577575

578576
// run addons
579577
executeAddons(dumpFile);
@@ -780,10 +778,8 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
780778
fdump.exceptions(std::ios_base::failbit | std::ios_base::badbit);
781779
std::string dumpFile;
782780
createDumpFile(mSettings, filename, fdump, dumpFile);
783-
if (fdump.is_open()) {
784-
fdump << dumpProlog.str();
785-
dumpProlog.str("");
786-
}
781+
fdump << dumpProlog.str();
782+
dumpProlog.str("");
787783

788784
// Get directives
789785
preprocessor.setDirectives(tokens1);

tools/dmake.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -397,26 +397,25 @@ int main(int argc, char **argv)
397397
{
398398
std::ofstream fout1("lib/lib.pri");
399399
fout1.exceptions(std::ios_base::failbit | std::ios_base::badbit);
400-
if (fout1.is_open()) {
401-
fout1 << "# no manual edits - this file is autogenerated by dmake\n\n";
402-
fout1 << "include($$PWD/pcrerules.pri)\n";
403-
fout1 << "include($$PWD/../externals/externals.pri)\n";
404-
fout1 << "INCLUDEPATH += $$PWD\n";
405-
fout1 << "HEADERS += ";
406-
for (const std::string &libfile_h : libfiles_h) {
407-
fout1 << "$${PWD}/" << libfile_h;
408-
if (libfile_h != libfiles_h.back())
409-
fout1 << " \\\n" << std::string(11, ' ');
410-
}
411-
fout1 << "\n\nSOURCES += ";
412-
for (const std::string &libfile : libfiles) {
413-
fout1 << "$${PWD}/" << libfile.substr(4);
414-
if (libfile != libfiles.back())
415-
fout1 << " \\\n" << std::string(11, ' ');
416-
}
417-
fout1 << "\n";
400+
401+
fout1 << "# no manual edits - this file is autogenerated by dmake\n\n";
402+
fout1 << "include($$PWD/pcrerules.pri)\n";
403+
fout1 << "include($$PWD/../externals/externals.pri)\n";
404+
fout1 << "INCLUDEPATH += $$PWD\n";
405+
fout1 << "HEADERS += ";
406+
for (const std::string &libfile_h : libfiles_h) {
407+
fout1 << "$${PWD}/" << libfile_h;
408+
if (libfile_h != libfiles_h.back())
409+
fout1 << " \\\n" << std::string(11, ' ');
418410
}
419-
}
411+
fout1 << "\n\nSOURCES += ";
412+
for (const std::string &libfile : libfiles) {
413+
fout1 << "$${PWD}/" << libfile.substr(4);
414+
if (libfile != libfiles.back())
415+
fout1 << " \\\n" << std::string(11, ' ');
416+
}
417+
fout1 << "\n";
418+
}
420419

421420
static const char makefile[] = "Makefile";
422421
std::ofstream fout(makefile, std::ios_base::trunc);

0 commit comments

Comments
 (0)