diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index a5c6345175f8..bccadf988792 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1126,9 +1126,7 @@ QPair MainWindow::getCppcheckSettings() result.standards.setC(mSettings->value(SETTINGS_STD_C, QString()).toString().toStdString()); result.enforcedLang = (Standards::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt(); - if (result.jobs <= 1) { - result.jobs = 1; - } + result.jobs = std::max(result.jobs, 1); Settings::terminate(false); diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index cfefd73ceb33..7994bf23840b 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -32,6 +32,8 @@ #include "threadhandler.h" #include "xmlreportv2.h" +#include + #include #include #include @@ -616,8 +618,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) if (mContextItem && mApplications->getApplicationCount() > 0 && mContextItem->parent()) { //Create an action for the application int defaultApplicationIndex = mApplications->getDefaultApplication(); - if (defaultApplicationIndex < 0) - defaultApplicationIndex = 0; + defaultApplicationIndex = std::max(defaultApplicationIndex, 0); const Application& app = mApplications->getApplication(defaultApplicationIndex); auto *start = new QAction(app.getName(), &menu); if (multipleSelection) diff --git a/gui/statsdialog.cpp b/gui/statsdialog.cpp index 8790a179d8e0..66a57b2315c2 100644 --- a/gui/statsdialog.cpp +++ b/gui/statsdialog.cpp @@ -22,6 +22,8 @@ #include "projectfile.h" #include "showtypes.h" +#include + #include "ui_statsdialog.h" #include @@ -409,8 +411,7 @@ QChartView *createChart(const QString &statsFile, const QString &tool) s->attachAxis(axisY); if (const auto *ls = dynamic_cast(s)) { for (QPointF p : ls->points()) { - if (p.y() > maxY) - maxY = p.y(); + maxY = std::max(p.y(), maxY); } } } diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index b6fd53d251f0..d69f2db0fedd 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -23,6 +23,7 @@ #include "resultsview.h" #include "settings.h" +#include #include #include #include @@ -92,10 +93,7 @@ void ThreadHandler::check(const Settings &settings) setThreadCount(settings.jobs); mRunningThreadCount = mThreads.size(); - - if (mResults.getFileCount() < mRunningThreadCount) { - mRunningThreadCount = mResults.getFileCount(); - } + mRunningThreadCount = std::min(mResults.getFileCount(), mRunningThreadCount); QStringList addonsAndTools = mAddonsAndTools; for (const std::string& addon: settings.addons) { diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index d510678ed2ed..e272452d588a 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -157,13 +157,11 @@ static int getMinFormatStringOutputLength(const std::vector ¶m if (formatString[i] == 's') { // For strings, the length after the dot "%.2s" will limit // the length of the string. - if (parameterLength > maxLen) - parameterLength = maxLen; + parameterLength = std::min(parameterLength, maxLen); } else { // For integers, the length after the dot "%.2d" can // increase required length - if (tempDigits < maxLen) - tempDigits = maxLen; + tempDigits = std::max(tempDigits, maxLen); } } diff --git a/lib/checkersreport.cpp b/lib/checkersreport.cpp index bff22361d5fa..57da92f99f33 100644 --- a/lib/checkersreport.cpp +++ b/lib/checkersreport.cpp @@ -22,6 +22,7 @@ #include "errortypes.h" #include "settings.h" +#include #include #include #include @@ -122,8 +123,7 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const int maxCheckerSize = 0; for (const auto& checkReq: checkers::allCheckers) { const std::string& checker = checkReq.first; - if (checker.size() > maxCheckerSize) - maxCheckerSize = checker.size(); + maxCheckerSize = std::max::size_type>(checker.size(), maxCheckerSize); } for (const auto& checkReq: checkers::allCheckers) { const std::string& checker = checkReq.first; diff --git a/lib/library.cpp b/lib/library.cpp index b89dcff958b3..d7aee780bb88 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -1284,8 +1284,7 @@ bool Library::matchArguments(const Token *ftok, const std::string &functionName) int args = 0; int firstOptionalArg = -1; for (const std::pair & argCheck : it->second.argumentChecks) { - if (argCheck.first > args) - args = argCheck.first; + args = std::max(argCheck.first, args); if (argCheck.second.optional && (firstOptionalArg == -1 || firstOptionalArg > argCheck.first)) firstOptionalArg = argCheck.first; diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 6e3eda8fb5fd..0036495e5928 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1665,8 +1665,7 @@ void SymbolDatabase::createSymbolDatabaseExprIds() // Find highest varId nonneg int maximumVarId = 0; for (const Token* tok = mTokenizer.list.front(); tok; tok = tok->next()) { - if (tok->varId() > maximumVarId) - maximumVarId = tok->varId(); + maximumVarId = std::max(tok->varId(), maximumVarId); } nonneg int id = maximumVarId + 1; // Find incomplete vars that are used in constant context