diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 8df27824d..7aa6e5c4f 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -914,13 +914,15 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha if (settings.jointSuppressionReport && !settings.checkLibrary) { for (std::map::const_iterator i = _files.begin(); i != _files.end(); ++i) { - reportUnmatchedSuppressions(settings.nomsg.getUnmatchedLocalSuppressions(i->first, enableUnusedFunctionCheck)); - if (returnValue == 0) + const bool err = reportUnmatchedSuppressions(settings.nomsg.getUnmatchedLocalSuppressions(i->first, enableUnusedFunctionCheck)); + if (err && returnValue == 0) returnValue = settings.exitCode; } } - reportUnmatchedSuppressions(settings.nomsg.getUnmatchedGlobalSuppressions(enableUnusedFunctionCheck)); + const bool err = reportUnmatchedSuppressions(settings.nomsg.getUnmatchedGlobalSuppressions(enableUnusedFunctionCheck)); + if (err && returnValue == 0) + returnValue = settings.exitCode; } if (!settings.checkConfiguration) { diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index f1ed62047..8699bcb0d 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -536,7 +536,7 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string return result; } -void ErrorLogger::reportUnmatchedSuppressions(const std::list &unmatched) +bool ErrorLogger::reportUnmatchedSuppressions(const std::list &unmatched) { // Report unmatched suppressions for (const Suppressions::Suppression &s : unmatched) { diff --git a/lib/errorlogger.h b/lib/errorlogger.h index cedda5ad7..f678bb89e 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -368,10 +368,11 @@ public: } /** - * Report list of unmatched suppressions + * Report unmatched suppressions * @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions) + * @return true is returned if errors are reported */ - void reportUnmatchedSuppressions(const std::list &unmatched); + bool reportUnmatchedSuppressions(const std::list &unmatched); static std::string callStackToString(const std::list &callStack);