diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index a60e30405423..a39685f03f44 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -311,7 +311,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const stdLogger.reportErr(ErrorMessage::getXMLFooter()); } - if (settings.safety && (stdLogger.hasCriticalErrors() || returnValue != 0)) + if (settings.safety && stdLogger.hasCriticalErrors()) return EXIT_FAILURE; if (returnValue) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index cc85659a3de5..4c3bcb7d0b69 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1635,8 +1635,9 @@ void CppCheck::reportErr(const ErrorMessage &msg) if (!mSettings.buildDir.empty()) mAnalyzerInformation.reportErr(msg); - if (!mSettings.supprs.nofail.isSuppressed(errorMessage) && !mSettings.supprs.nomsg.isSuppressed(errorMessage)) - mExitCode = mSettings.exitCode; + if (!mSettings.supprs.nofail.isSuppressed(errorMessage) && !mSettings.supprs.nomsg.isSuppressed(errorMessage)) { + mExitCode = 1; + } std::string remark; if (!msg.callStack.empty()) {