@@ -118,6 +118,10 @@ class CppCheckExecutor::StdLogger : public ErrorLogger
118118 */
119119 void writeCheckersReport () const ;
120120
121+ bool hasCriticalErrors () const {
122+ return !mCriticalErrors .empty ();
123+ }
124+
121125private:
122126 /* *
123127 * Information about progress is directed here. This should be
@@ -288,9 +292,12 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck) const
288292
289293 mStdLogger ->writeCheckersReport ();
290294
295+ if (settings.safety && mStdLogger ->hasCriticalErrors ())
296+ return EXIT_FAILURE;
297+
291298 if (returnValue)
292299 return settings.exitCode ;
293- return 0 ;
300+ return EXIT_SUCCESS ;
294301}
295302
296303void CppCheckExecutor::StdLogger::writeCheckersReport () const
@@ -385,24 +392,29 @@ void CppCheckExecutor::StdLogger::reportProgress(const std::string &filename, co
385392
386393void CppCheckExecutor::StdLogger::reportErr (const ErrorMessage &msg)
387394{
388- if (msg.severity == Severity::none && (msg.id == " logChecker" || endsWith (msg.id , " -logChecker" ))) {
395+ if (msg.severity == Severity::internal && (msg.id == " logChecker" || endsWith (msg.id , " -logChecker" ))) {
389396 const std::string& checker = msg.shortMessage ();
390397 mActiveCheckers .emplace (checker);
391398 return ;
392399 }
393400
394- // TODO: we generate a different message here then we log below
395- // TODO: there should be no need for verbose and default messages here
396- // Alert only about unique errors
397- if (!mShownErrors .insert (msg.toString (mSettings .verbose )).second )
398- return ;
399-
400401 if (ErrorLogger::isCriticalErrorId (msg.id ) && mCriticalErrors .find (msg.id ) == std::string::npos) {
401402 if (!mCriticalErrors .empty ())
402403 mCriticalErrors += " , " ;
403404 mCriticalErrors += msg.id ;
405+ if (msg.severity == Severity::internal)
406+ mCriticalErrors += " (suppressed)" ;
404407 }
405408
409+ if (msg.severity == Severity::internal)
410+ return ;
411+
412+ // TODO: we generate a different message here then we log below
413+ // TODO: there should be no need for verbose and default messages here
414+ // Alert only about unique errors
415+ if (!mShownErrors .insert (msg.toString (mSettings .verbose )).second )
416+ return ;
417+
406418 if (mSettings .xml )
407419 reportErr (msg.toXML ());
408420 else
0 commit comments