Correct exit code when there are no unmatched suppressions

This commit is contained in:
Daniel Marjamäki 2019-01-21 20:33:22 +01:00
parent 4b37f276c2
commit 4119cfd3d1
3 changed files with 9 additions and 6 deletions

View File

@ -914,13 +914,15 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
if (settings.jointSuppressionReport && !settings.checkLibrary) { if (settings.jointSuppressionReport && !settings.checkLibrary) {
for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) { for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) {
reportUnmatchedSuppressions(settings.nomsg.getUnmatchedLocalSuppressions(i->first, enableUnusedFunctionCheck)); const bool err = reportUnmatchedSuppressions(settings.nomsg.getUnmatchedLocalSuppressions(i->first, enableUnusedFunctionCheck));
if (returnValue == 0) if (err && returnValue == 0)
returnValue = settings.exitCode; 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) { if (!settings.checkConfiguration) {

View File

@ -536,7 +536,7 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string
return result; return result;
} }
void ErrorLogger::reportUnmatchedSuppressions(const std::list<Suppressions::Suppression> &unmatched) bool ErrorLogger::reportUnmatchedSuppressions(const std::list<Suppressions::Suppression> &unmatched)
{ {
// Report unmatched suppressions // Report unmatched suppressions
for (const Suppressions::Suppression &s : unmatched) { for (const Suppressions::Suppression &s : unmatched) {

View File

@ -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) * @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<Suppressions::Suppression> &unmatched); bool reportUnmatchedSuppressions(const std::list<Suppressions::Suppression> &unmatched);
static std::string callStackToString(const std::list<ErrorLogger::ErrorMessage::FileLocation> &callStack); static std::string callStackToString(const std::list<ErrorLogger::ErrorMessage::FileLocation> &callStack);