Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package cppcheck for openSUSE:Factory checked in at 2024-02-05 22:01:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/cppcheck (Old) and /work/SRC/openSUSE:Factory/.cppcheck.new.1815 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "cppcheck" Mon Feb 5 22:01:45 2024 rev:40 rq:1144161 version:2.13.3 Changes: -------- --- /work/SRC/openSUSE:Factory/cppcheck/cppcheck.changes 2024-01-26 22:48:00.837811475 +0100 +++ /work/SRC/openSUSE:Factory/.cppcheck.new.1815/cppcheck.changes 2024-02-05 22:01:55.776595165 +0100 @@ -1,0 +2,7 @@ +Mon Feb 5 09:43:34 UTC 2024 - Dirk Müller <dmuel...@suse.com> + +- update to 2.13.3: + * settings.cpp: Update autosar+cert+misra checkers mappings + * Fix #12389 (GUI: premiumaddon is not executed properly anymore) + +------------------------------------------------------------------- Old: ---- cppcheck-2.13.2.tar.gz New: ---- cppcheck-2.13.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ cppcheck.spec ++++++ --- /var/tmp/diff_new_pack.LRp4nq/_old 2024-02-05 22:01:56.348615860 +0100 +++ /var/tmp/diff_new_pack.LRp4nq/_new 2024-02-05 22:01:56.352616004 +0100 @@ -17,7 +17,7 @@ Name: cppcheck -Version: 2.13.2 +Version: 2.13.3 Release: 0 Summary: A tool for static C/C++ code analysis License: GPL-3.0-or-later ++++++ cppcheck-2.13.2.tar.gz -> cppcheck-2.13.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/.github/workflows/CI-unixish-docker.yml new/cppcheck-2.13.3/.github/workflows/CI-unixish-docker.yml --- old/cppcheck-2.13.2/.github/workflows/CI-unixish-docker.yml 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/.github/workflows/CI-unixish-docker.yml 2024-02-03 21:57:54.000000000 +0100 @@ -60,8 +60,10 @@ # needs to be called after the package installation since # - it doesn't call "apt-get update" # - it doesn't support centos + # + # needs to be to fixated on 1.2.11 so it works with older images - see https://github.com/hendrikmuhs/ccache-action/issues/178 - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 + uses: hendrikmuhs/ccache-action@v1.2.11 if: matrix.image != 'ubuntu:14.04' # no support for --set-config with: key: ${{ github.workflow }}-${{ matrix.image }} @@ -134,8 +136,10 @@ # needs to be called after the package installation since # - it doesn't call "apt-get update" # - it doesn't support centos + # + # needs to be to fixated on 1.2.11 so it works with older images - see https://github.com/hendrikmuhs/ccache-action/issues/178 - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 + uses: hendrikmuhs/ccache-action@v1.2.11 if: matrix.image != 'ubuntu:14.04' # no support for --set-config with: key: ${{ github.workflow }}-${{ matrix.image }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/cli/cmdlineparser.cpp new/cppcheck-2.13.3/cli/cmdlineparser.cpp --- old/cppcheck-2.13.2/cli/cmdlineparser.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/cli/cmdlineparser.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -893,10 +893,13 @@ "autosar", "cert-c-2016", "cert-c++-2016", + "cert-cpp-2016", "misra-c-2012", "misra-c-2023", "misra-c++-2008", + "misra-cpp-2008", "misra-c++-2023", + "misra-cpp-2023", "bughunting", "safety"}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/cmake/versions.cmake new/cppcheck-2.13.3/cmake/versions.cmake --- old/cppcheck-2.13.2/cmake/versions.cmake 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/cmake/versions.cmake 2024-02-03 21:57:54.000000000 +0100 @@ -1,6 +1,6 @@ # Version for libraries CPP # Version string must have 3 "parts". https://sourceforge.net/p/cppcheck/discussion/development/thread/e57efb2b62/ -SET(VERSION "2.13.2") +SET(VERSION "2.13.3") STRING(REGEX MATCHALL "[0-9]+" VERSION_PARTS "${VERSION}") LIST(GET VERSION_PARTS 0 VERSION_MAJOR) LIST(GET VERSION_PARTS 1 VERSION_MINOR) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/cppcheckpremium-suppressions new/cppcheck-2.13.3/cppcheckpremium-suppressions --- old/cppcheck-2.13.2/cppcheckpremium-suppressions 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/cppcheckpremium-suppressions 2024-02-03 21:57:54.000000000 +0100 @@ -42,6 +42,9 @@ # we sometimes don't care about return value from functions premium-misra-cpp-2008-0-1-7 +# we allow C++11 +premium-misra-cpp-2008-1-0-1 + # TODO: can we prevent commented out code? premium-misra-cpp-2008-2-7-2 premium-misra-cpp-2008-2-7-3 @@ -52,6 +55,9 @@ # objects of a class often has the lowercase name of the class. premium-misra-cpp-2008-2-10-4 +# we have constants that don't have U suffix +premium-misra-cpp-2008-2-13-3 + # flag |= .. premium-misra-cpp-2008-4-5-1 @@ -76,6 +82,9 @@ # conversion of char-to-int is intentional sometimes premium-misra-cpp-2008-5-0-12 +# pointer to bool conversion in condition +premium-misra-cpp-2008-5-0-13 + # pointer-to-bool conversion is common premium-misra-cpp-2008-5-0-14 @@ -106,9 +115,30 @@ # we write !pointer by intention premium-misra-cpp-2008-5-3-1 +# we have side effects in && || RHS by intention +premium-misra-cpp-2008-5-14-1 + +# comma operator: we often declare many variables in the same line +premium-misra-cpp-2008-5-18-1 + +# we have quite many assignments in subexpressions. for instance in expression `tok2 = tok2->next()` it's clear a equality is not intended. +premium-misra-cpp-2008-6-2-1 + # for (;;) premium-misra-cpp-2008-6-2-3 +# we don't enforce {} below for/while +premium-misra-cpp-2008-6-3-1 + +# we don't enforce {} below if/else +premium-misra-cpp-2008-6-4-1 + +# we do not enforce final "else" +premium-misra-cpp-2008-6-4-2 + +# we have switch with return +premium-misra-cpp-2008-6-4-5 + # it's not a bug to not put default at the end of a switch body premium-misra-cpp-2008-6-4-6 @@ -131,6 +161,9 @@ # intentional: return reference from method to non-const reference parameter premium-misra-cpp-2008-7-5-3 +# we have recursion by intention +premium-misra-cpp-2008-7-5-4 + # intentional declaration of multiple variables premium-misra-cpp-2008-8-0-1 @@ -143,15 +176,24 @@ # TODO Fix these premium-misra-cpp-2008-9-3-1 +# methods that return non-const handles to members +premium-misra-cpp-2008-9-3-2 + # we use unions by intention sometimes premium-misra-cpp-2008-9-5-1 # overridden methods is safe premium-misra-cpp-2008-10-3-1 +# in modern c++ it's prefered to use override/final +premium-misra-cpp-2008-10-3-2 + # some classes have public members by intention premium-misra-cpp-2008-11-0-1 +# clang-tidy warns if there are redundant base class initialization [readability-redundant-member-init] +premium-misra-cpp-2008-12-1-2 + # rule should not apply to deleted copy assignment operator premium-misra-cpp-2008-12-8-2 @@ -161,8 +203,13 @@ # function specializations: TODO check if we should refactor premium-misra-cpp-2008-14-8-2 +# we throw/catch token pointer in one case by intention +premium-misra-cpp-2008-15-0-2 +premium-misra-cpp-2008-15-3-5 + # we use preprocessor when it makes sense premium-misra-cpp-2008-16-0-1 +premium-misra-cpp-2008-16-0-7 premium-misra-cpp-2008-16-2-1 premium-misra-cpp-2008-16-2-2 premium-misra-cpp-2008-16-3-2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/externals/simplecpp/simplecpp.cpp new/cppcheck-2.13.3/externals/simplecpp/simplecpp.cpp --- old/cppcheck-2.13.2/externals/simplecpp/simplecpp.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/externals/simplecpp/simplecpp.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -393,12 +393,15 @@ class FileStream : public simplecpp::TokenList::Stream { public: // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members - EXPLICIT FileStream(const std::string &filename) + EXPLICIT FileStream(const std::string &filename, std::vector<std::string> &files) : file(fopen(filename.c_str(), "rb")) , lastCh(0) , lastStatus(0) { - assert(file != nullptr); + if (!file) { + files.push_back(filename); + throw simplecpp::Output(files, simplecpp::Output::FILE_NOT_FOUND, "File is missing: " + filename); + } init(); } @@ -455,8 +458,15 @@ simplecpp::TokenList::TokenList(const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList) : frontToken(nullptr), backToken(nullptr), files(filenames) { - FileStream stream(filename); - readfile(stream,filename,outputList); + try + { + FileStream stream(filename, filenames); + readfile(stream,filename,outputList); + } + catch(const simplecpp::Output & e) // TODO handle extra type of errors + { + outputList->push_back(e); + } } simplecpp::TokenList::TokenList(const TokenList &other) : frontToken(nullptr), backToken(nullptr), files(other.files) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/externals/simplecpp/simplecpp.h new/cppcheck-2.13.3/externals/simplecpp/simplecpp.h --- old/cppcheck-2.13.2/externals/simplecpp/simplecpp.h 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/externals/simplecpp/simplecpp.h 2024-02-03 21:57:54.000000000 +0100 @@ -193,8 +193,10 @@ SYNTAX_ERROR, PORTABILITY_BACKSLASH, UNHANDLED_CHAR_ERROR, - EXPLICIT_INCLUDE_NOT_FOUND + EXPLICIT_INCLUDE_NOT_FOUND, + FILE_NOT_FOUND } type; + explicit Output(const std::vector<std::string>& files, Type type, const std::string& msg) : type(type), location(files), msg(msg) {} Location location; std::string msg; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/gui/mainwindow.cpp new/cppcheck-2.13.3/gui/mainwindow.cpp --- old/cppcheck-2.13.2/gui/mainwindow.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/gui/mainwindow.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -486,6 +486,11 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, const bool checkConfiguration) { + QPair<bool,Settings> checkSettingsPair = getCppcheckSettings(); + if (!checkSettingsPair.first) + return; + Settings& checkSettings = checkSettingsPair.second; + clearResults(); mIsLogfileLoaded = false; @@ -522,7 +527,6 @@ checkLockDownUI(); // lock UI while checking mUI->mResults->setCheckDirectory(checkPath); - Settings checkSettings = getCppcheckSettings(); checkSettings.force = false; checkSettings.checkLibrary = checkLibrary; checkSettings.checkConfiguration = checkConfiguration; @@ -550,9 +554,14 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrary, const bool checkConfiguration) { - if (files.isEmpty()) { + if (files.isEmpty()) return; - } + + QPair<bool, Settings> checkSettingsPair = getCppcheckSettings(); + if (!checkSettingsPair.first) + return; + Settings& checkSettings = checkSettingsPair.second; + clearResults(); mIsLogfileLoaded = false; @@ -591,7 +600,6 @@ checkLockDownUI(); // lock UI while checking mUI->mResults->setCheckDirectory(checkPath); - Settings checkSettings = getCppcheckSettings(); checkSettings.checkLibrary = checkLibrary; checkSettings.checkConfiguration = checkConfiguration; @@ -614,6 +622,11 @@ void MainWindow::analyzeCode(const QString& code, const QString& filename) { + const QPair<bool, Settings>& checkSettingsPair = getCppcheckSettings(); + if (!checkSettingsPair.first) + return; + const Settings& checkSettings = checkSettingsPair.second; + // Initialize dummy ThreadResult as ErrorLogger ThreadResult result; result.setFiles(QStringList(filename)); @@ -628,7 +641,7 @@ // Create CppCheck instance CppCheck cppcheck(result, true, nullptr); - cppcheck.settings() = getCppcheckSettings(); + cppcheck.settings() = checkSettings; // Check checkLockDownUI(); @@ -905,13 +918,12 @@ return true; } -void MainWindow::loadAddon(Settings &settings, const QString &filesDir, const QString &pythonCmd, const QString& addon) +QString MainWindow::loadAddon(Settings &settings, const QString &filesDir, const QString &pythonCmd, const QString& addon) { - QString addonFilePath = ProjectFile::getAddonFilePath(filesDir, addon); - if (addonFilePath.isEmpty()) - return; // TODO: report an error + const QString addonFilePath = fromNativePath(ProjectFile::getAddonFilePath(filesDir, addon)); - addonFilePath.replace(QChar('\\'), QChar('/')); + if (addonFilePath.isEmpty()) + return tr("File not found: '%1'").arg(addon); picojson::object obj; obj["script"] = picojson::value(addonFilePath.toStdString()); @@ -929,42 +941,54 @@ obj["args"] = picojson::value(arg.toStdString()); } } - picojson::value json; - json.set(std::move(obj)); - std::string json_str = json.serialize(); + + const std::string& json_str = picojson::value(obj).serialize(); AddonInfo addonInfo; - addonInfo.getAddonInfo(json_str, settings.exename); // TODO: handle error + const std::string errmsg = addonInfo.getAddonInfo(json_str, settings.exename); + if (!errmsg.empty()) + return tr("Failed to load/setup addon %1: %2").arg(addon, QString::fromStdString(errmsg)); settings.addonInfos.emplace_back(std::move(addonInfo)); - settings.addons.emplace(std::move(json_str)); + settings.addons.emplace(json_str); + + return ""; } -Settings MainWindow::getCppcheckSettings() +QPair<bool,Settings> MainWindow::getCppcheckSettings() { saveSettings(); // Save settings + Settings::terminate(true); Settings result; result.exename = QCoreApplication::applicationFilePath().toStdString(); const bool std = tryLoadLibrary(&result.library, "std.cfg"); - if (!std) - QMessageBox::critical(this, tr("Error"), tr("Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured.").arg("std.cfg")); + if (!std) { + QMessageBox::critical(this, tr("Error"), tr("Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured.\n\nAnalysis is aborted.").arg("std.cfg")); + return {false, {}}; + } const QString filesDir(getDataDir()); const QString pythonCmd = fromNativePath(mSettings->value(SETTINGS_PYTHON_PATH).toString()); { const QString cfgErr = QString::fromStdString(result.loadCppcheckCfg()); - if (!cfgErr.isEmpty()) - QMessageBox::critical(this, tr("Error"), tr("Failed to load %1 - %2").arg("cppcheck.cfg").arg(cfgErr)); + if (!cfgErr.isEmpty()) { + QMessageBox::critical(this, tr("Error"), tr("Failed to load %1 - %2\n\nAnalysis is aborted.").arg("cppcheck.cfg").arg(cfgErr)); + return {false, {}}; + } const auto cfgAddons = result.addons; result.addons.clear(); for (const std::string& addon : cfgAddons) { // TODO: support addons which are a script and not a file - loadAddon(result, filesDir, pythonCmd, QString::fromStdString(addon)); + const QString addonError = loadAddon(result, filesDir, pythonCmd, QString::fromStdString(addon)); + if (!addonError.isEmpty()) { + QMessageBox::critical(this, tr("Error"), tr("%1\n\nAnalysis is aborted.").arg(addonError)); + return {false, {}}; + } } } @@ -1045,7 +1069,11 @@ result.checkUnknownFunctionReturn.insert(s.toStdString()); for (const QString& addon : mProjectFile->getAddons()) { - loadAddon(result, filesDir, pythonCmd, addon); + const QString addonError = loadAddon(result, filesDir, pythonCmd, addon); + if (!addonError.isEmpty()) { + QMessageBox::critical(this, tr("Error"), tr("%1\n\nAnalysis is aborted.").arg(addonError)); + return {false, {}}; + } } if (isCppcheckPremium()) { @@ -1099,7 +1127,7 @@ Settings::terminate(false); - return result; + return {true, std::move(result)}; } void MainWindow::analysisDone() @@ -1223,6 +1251,11 @@ if (mThread->isChecking()) return; + const QPair<bool, Settings> checkSettingsPair = getCppcheckSettings(); + if (!checkSettingsPair.first) + return; + const Settings& checkSettings = checkSettingsPair.second; + // Clear details, statistics and progress mUI->mResults->clear(false); for (int i = 0; i < files.size(); ++i) @@ -1242,7 +1275,6 @@ // considered in "Modified Files Check" performed after "Selected Files Check" // TODO: Should we store per file CheckStartTime? QDateTime saveCheckStartTime = mThread->getCheckStartTime(); - const Settings& checkSettings = getCppcheckSettings(); mThread->check(checkSettings); mUI->mResults->setCheckSettings(checkSettings); mThread->setCheckStartTime(saveCheckStartTime); @@ -1254,6 +1286,11 @@ if (files.empty()) return; + const QPair<bool, Settings>& checkSettingsPair = getCppcheckSettings(); + if (!checkSettingsPair.first) + return; + const Settings& checkSettings = checkSettingsPair.second; + // Clear details, statistics and progress mUI->mResults->clear(all); @@ -1268,7 +1305,6 @@ qDebug() << "Rechecking project file" << mProjectFile->getFilename(); mThread->setCheckFiles(all); - const Settings& checkSettings = getCppcheckSettings(); mThread->check(checkSettings); mUI->mResults->setCheckSettings(checkSettings); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/gui/mainwindow.h new/cppcheck-2.13.3/gui/mainwindow.h --- old/cppcheck-2.13.2/gui/mainwindow.h 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/gui/mainwindow.h 2024-02-03 21:57:54.000000000 +0100 @@ -315,7 +315,7 @@ * * @return Default cppcheck settings */ - Settings getCppcheckSettings(); + QPair<bool, Settings> getCppcheckSettings(); /** @brief Load program settings */ void loadSettings(); @@ -401,7 +401,7 @@ */ bool tryLoadLibrary(Library *library, const QString& filename); - void loadAddon(Settings &settings, const QString &filesDir, const QString &pythonCmd, const QString& addon); + QString loadAddon(Settings &settings, const QString &filesDir, const QString &pythonCmd, const QString& addon); /** * @brief Update project MRU items in File-menu. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/gui/projectfile.cpp new/cppcheck-2.13.3/gui/projectfile.cpp --- old/cppcheck-2.13.2/gui/projectfile.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/gui/projectfile.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -1115,6 +1115,9 @@ QString ProjectFile::getAddonFilePath(QString filesDir, const QString &addon) { + if (QFile(addon).exists()) + return addon; + if (!filesDir.endsWith("/")) filesDir += "/"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/gui/test/projectfile/testprojectfile.cpp new/cppcheck-2.13.3/gui/test/projectfile/testprojectfile.cpp --- old/cppcheck-2.13.2/gui/test/projectfile/testprojectfile.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/gui/test/projectfile/testprojectfile.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -28,6 +28,7 @@ #include <QList> #include <QStringList> +#include <QTemporaryDir> #include <QtTest> // Mock... @@ -116,4 +117,23 @@ QCOMPARE(defines[0], QString("FOO")); } +void TestProjectFile::getAddonFilePath() const +{ + QTemporaryDir tempdir; + QVERIFY(tempdir.isValid()); + const QString filepath(tempdir.path() + "/addon.py"); + + QFile file(filepath); + QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); + file.close(); + + // Relative path to addon + QCOMPARE(ProjectFile::getAddonFilePath(tempdir.path(), "addon"), filepath); + QCOMPARE(ProjectFile::getAddonFilePath(tempdir.path(), "not exist"), QString()); + + // Absolute path to addon + QCOMPARE(ProjectFile::getAddonFilePath("/not/exist", filepath), filepath); + QCOMPARE(ProjectFile::getAddonFilePath(tempdir.path(), filepath), filepath); +} + QTEST_MAIN(TestProjectFile) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/gui/test/projectfile/testprojectfile.h new/cppcheck-2.13.3/gui/test/projectfile/testprojectfile.h --- old/cppcheck-2.13.2/gui/test/projectfile/testprojectfile.h 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/gui/test/projectfile/testprojectfile.h 2024-02-03 21:57:54.000000000 +0100 @@ -27,4 +27,6 @@ void loadSimple() const; void loadSimpleWithIgnore() const; void loadSimpleNoroot() const; + + void getAddonFilePath() const; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/lib/addoninfo.cpp new/cppcheck-2.13.3/lib/addoninfo.cpp --- old/cppcheck-2.13.2/lib/addoninfo.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/lib/addoninfo.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -80,11 +80,18 @@ addoninfo.python = ""; } - if (obj.count("executable")) { - if (!obj["executable"].is<std::string>()) - return "Loading " + fileName + " failed. executable must be a string."; - addoninfo.executable = getFullPath(obj["executable"].get<std::string>(), fileName); - return ""; + { + const auto it = obj.find("executable"); + if (it != obj.cend()) { + const auto& val = it->second; + if (!val.is<std::string>()) + return "Loading " + fileName + " failed. 'executable' must be a string."; + const std::string e = val.get<std::string>(); + addoninfo.executable = getFullPath(e, fileName); + if (addoninfo.executable.empty()) + addoninfo.executable = e; + return ""; // <- do not load both "executable" and "script". + } } return addoninfo.getAddonInfo(obj["script"].get<std::string>(), exename); @@ -126,6 +133,11 @@ std::ifstream fin(fileName); if (!fin.is_open()) return "Failed to open " + fileName; + if (name.empty()) { + name = Path::fromNativeSeparators(fileName); + if (name.find('/') != std::string::npos) + name = name.substr(name.rfind('/') + 1); + } picojson::value json; fin >> json; return parseAddonInfo(*this, json, fileName, exename); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/lib/checkers.cpp new/cppcheck-2.13.3/lib/checkers.cpp --- old/cppcheck-2.13.2/lib/checkers.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/lib/checkers.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -291,7 +291,7 @@ {"Cert C++: ERR51-CPP","style"}, {"Cert C++: ERR52-CPP","style"}, {"Cert C++: ERR53-CPP",""}, - {"Cert C++: ERR54-CPP",""}, + {"Cert C++: ERR54-CPP","style"}, {"Cert C++: ERR55-CPP",""}, {"Cert C++: ERR56-CPP",""}, {"Cert C++: ERR58-CPP",""}, @@ -402,17 +402,23 @@ {"Cert C: STR32-C","warning"}, {"Cert C: STR34-C","warning"}, {"Cert C: STR38-C","style"}, + {"Misra C++ 2023: 21.20.1",""}, + {"Misra C++ 2023: 21.20.2",""}, + {"Misra C++ 2023: 6.7.1",""}, {"Misra C++: M0-1-11","style"}, {"Misra C++: M0-1-12","style"}, {"Misra C++: M0-1-4","style"}, {"Misra C++: M0-1-5","style"}, {"Misra C++: M0-1-7","style"}, {"Misra C++: M0-1-8","style"}, + {"Misra C++: M0-3-2","style"}, + {"Misra C++: M1-0-1","portability"}, {"Misra C++: M10-1-1","style"}, {"Misra C++: M10-1-2","style"}, {"Misra C++: M10-1-3","style"}, {"Misra C++: M10-2-1","style"}, {"Misra C++: M10-3-1","style"}, + {"Misra C++: M10-3-2","style"}, {"Misra C++: M10-3-3","style"}, {"Misra C++: M11-0-1","style"}, {"Misra C++: M12-1-2","style"}, @@ -435,13 +441,19 @@ {"Misra C++: M15-3-2","warning"}, {"Misra C++: M15-3-3",""}, {"Misra C++: M15-3-4",""}, + {"Misra C++: M15-3-6","style"}, + {"Misra C++: M15-3-7","style"}, {"Misra C++: M15-4-1","style"}, {"Misra C++: M15-5-2",""}, {"Misra C++: M16-0-1","style"}, {"Misra C++: M16-0-2","style"}, {"Misra C++: M16-0-3","style"}, {"Misra C++: M16-0-4","style"}, + {"Misra C++: M16-0-6","style"}, + {"Misra C++: M16-0-7","style"}, + {"Misra C++: M16-0-8","style"}, {"Misra C++: M16-1-1","style"}, + {"Misra C++: M16-1-2","style"}, {"Misra C++: M16-2-1","style"}, {"Misra C++: M16-2-2","style"}, {"Misra C++: M16-2-3","style"}, @@ -468,8 +480,11 @@ {"Misra C++: M2-10-4","style"}, {"Misra C++: M2-10-5","style"}, {"Misra C++: M2-10-6","style"}, + {"Misra C++: M2-13-2","style"}, + {"Misra C++: M2-13-3","style"}, {"Misra C++: M2-13-4","style"}, {"Misra C++: M2-13-5","style"}, + {"Misra C++: M2-3-1","style"}, {"Misra C++: M2-7-1","style"}, {"Misra C++: M2-7-2","style"}, {"Misra C++: M2-7-3","style"}, @@ -503,7 +518,10 @@ {"Misra C++: M5-0-7","style"}, {"Misra C++: M5-0-8","style"}, {"Misra C++: M5-0-9","style"}, + {"Misra C++: M5-14-1","style"}, {"Misra C++: M5-17-1","style"}, + {"Misra C++: M5-18-1","style"}, + {"Misra C++: M5-19-1","style"}, {"Misra C++: M5-2-1","style"}, {"Misra C++: M5-2-10","style"}, {"Misra C++: M5-2-11","style"}, @@ -518,8 +536,15 @@ {"Misra C++: M5-3-1","style"}, {"Misra C++: M5-3-2","style"}, {"Misra C++: M5-3-3","style"}, + {"Misra C++: M6-2-1","style"}, + {"Misra C++: M6-2-2","style"}, {"Misra C++: M6-2-3","style"}, + {"Misra C++: M6-3-1","style"}, + {"Misra C++: M6-4-1","style"}, + {"Misra C++: M6-4-2","style"}, + {"Misra C++: M6-4-3","style"}, {"Misra C++: M6-4-4","style"}, + {"Misra C++: M6-4-5","style"}, {"Misra C++: M6-4-6","style"}, {"Misra C++: M6-4-7","style"}, {"Misra C++: M6-4-8","style"}, @@ -530,6 +555,7 @@ {"Misra C++: M6-5-5","style"}, {"Misra C++: M6-5-6","style"}, {"Misra C++: M6-6-1","style"}, + {"Misra C++: M6-6-2","style"}, {"Misra C++: M6-6-3","style"}, {"Misra C++: M6-6-4","style"}, {"Misra C++: M6-6-5","style"}, @@ -563,14 +589,30 @@ {"Misra C: 10.7","style"}, {"Misra C: 10.8","style"}, {"Misra C: 11.10","style"}, + {"Misra C: 12.3","style"}, {"Misra C: 12.6",""}, + {"Misra C: 13.1","style"}, + {"Misra C: 13.2","style"}, + {"Misra C: 13.3","style"}, + {"Misra C: 13.4","style"}, + {"Misra C: 13.5","style"}, + {"Misra C: 13.6","style"}, + {"Misra C: 15.5",""}, + {"Misra C: 16.3","style"}, {"Misra C: 17.10","style"}, {"Misra C: 17.11","style"}, {"Misra C: 17.12","style"}, + {"Misra C: 17.13",""}, + {"Misra C: 17.3",""}, {"Misra C: 17.9","style"}, {"Misra C: 18.10","style"}, + {"Misra C: 18.5","style"}, + {"Misra C: 18.8","style"}, {"Misra C: 18.9","style"}, + {"Misra C: 20.3","style"}, + {"Misra C: 21.1","style"}, {"Misra C: 21.12","style"}, + {"Misra C: 21.16","style"}, {"Misra C: 21.22","style"}, {"Misra C: 21.23","style"}, {"Misra C: 21.24","style"}, @@ -601,6 +643,7 @@ {"Misra C: 8.15","style"}, {"Misra C: 8.16","style"}, {"Misra C: 8.17","style"}, + {"Misra C: 8.3","style"}, {"Misra C: 9.6","style"}, {"Misra C: 9.7",""}, {"PremiumCheckBufferOverrun::addressOfPointerArithmetic","warning"}, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/lib/preprocessor.cpp new/cppcheck-2.13.3/lib/preprocessor.cpp --- old/cppcheck-2.13.2/lib/preprocessor.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/lib/preprocessor.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -750,6 +750,7 @@ case simplecpp::Output::SYNTAX_ERROR: case simplecpp::Output::UNHANDLED_CHAR_ERROR: case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND: + case simplecpp::Output::FILE_NOT_FOUND: return true; case simplecpp::Output::WARNING: case simplecpp::Output::MISSING_HEADER: @@ -889,6 +890,7 @@ error(out.location.file(), out.location.line, out.msg); break; case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND: + case simplecpp::Output::FILE_NOT_FOUND: error(emptyString, 0, out.msg); break; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/lib/settings.cpp new/cppcheck-2.13.3/lib/settings.cpp --- old/cppcheck-2.13.2/lib/settings.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/lib/settings.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -256,14 +256,19 @@ // TODO: auto generate these tables -static const std::set<std::string> autosar_checkers{ +static const std::set<std::string> autosarCheckers{ "accessMoved", + "argumentSize", "arrayIndexOutOfBounds", + "arrayIndexOutOfBoundsCond", + "arrayIndexThenCheck", + "bufferAccessOutOfBounds", "comparePointers", "constParameter", "cstyleCast", "ctuOneDefinitionViolation", "doubleFree", + "duplInheritedMember", "duplicateBreak", "funcArgNamesDifferent", "functionConst", @@ -272,122 +277,247 @@ "memleak", "mismatchAllocDealloc", "missingReturn", + "negativeIndex", "noExplicitConstructor", "nullPointer", + "nullPointerArithmetic", + "nullPointerArithmeticRedundantCheck", + "nullPointerDefaultArg", + "nullPointerRedundantCheck", + "objectIndex", + "overlappingWriteFunction", + "overlappingWriteUnion", "pointerOutOfBounds", - "unreadVariable", - "unusedValue", + "pointerOutOfBoundsCond", + "preprocessorErrorDirective", "redundantAssignment", "redundantInitialization", "returnDanglingLifetime", - "shadowVariable", "shiftTooManyBits", "sizeofSideEffects", "throwInDestructor", "throwInNoexceptFunction", - "unreachableCode", "uninitData", "uninitMember", + "unreachableCode", + "unreadVariable", + "unsignedLessThanZero", + "unusedFunction", + "unusedStructMember", + "unusedValue", "unusedVariable", "useInitializerList", "variableScope", "virtualCallInConstructor", - "zeroDiv" + "zerodiv", + "zerodivcond" }; -static const std::set<std::string> cert_c_checkers{ - "danglingLifetime", "autoVariables", "invalidLifetime", - "unknownEvaluationOrder", - "uninitvar", "uninitdata", "uninitStructMember", - "nullPointer", - "sizeofCalculation", +static const std::set<std::string> certCCheckers{ + "IOWithoutPositioning", + "autoVariables", + "autovarInvalidDeallocation", "bitwiseOnBoolean", - "invalidFunctionArg", - "floatConversionOverflow", "comparePointers", - "stringLiteralWrite", - "doubleFree", + "danglingLifetime", "deallocret", "deallocuse", + "doubleFree", + "floatConversionOverflow", + "invalidFunctionArg", + "invalidLengthModifierError", + "invalidLifetime", + "invalidScanfFormatWidth", + "invalidscanf", + "leakReturnValNotUsed", + "leakUnsafeArgAlloc", "memleak", - "autovarInvalidDeallocation", + "memleakOnRealloc", "mismatchAllocDealloc", - "IOWithoutPositioning", + "missingReturn", + "nullPointer", + "nullPointerArithmetic", + "nullPointerArithmeticRedundantCheck", + "nullPointerDefaultArg", + "nullPointerRedundantCheck", + "preprocessorErrorDirective", "resourceLeak", + "sizeofCalculation", + "stringLiteralWrite", + "uninitStructMember", + "uninitdata", + "uninitvar", + "unknownEvaluationOrder", "useClosedFile", - "invalidscanf", "wrongPrintfScanfArgNum", - "invalidLengthModifierError", - "invalidScanfFormatWidth", - "wrongPrintfScanfParameterPositionError", - "missingReturn" + "wrongPrintfScanfParameterPositionError" }; -static const std::set<std::string> cert_cpp_checkers{ - "deallocThrow", "exceptThrowInDestructor", - "ctuOneDefinitionViolation", - "sizeofCalculation", - "comparePointers", +static const std::set<std::string> certCppCheckers{ "IOWithoutPositioning", - "virtualCallInConstructor", - "virtualDestructor", + "accessMoved", + "comparePointers", + "containerOutOfBounds", + "ctuOneDefinitionViolation", + "deallocMismatch", + "deallocThrow", + "deallocuse", + "doubleFree", + "eraseDereference", + "exceptThrowInDestructor", "initializerList", - "operatorEqToSelf", + "invalidContainer", + "lifetime", + "memleak", "missingReturn", + "nullPointer", + "operatorEqToSelf", + "sizeofCalculation", + "uninitvar", + "virtualCallInConstructor", + "virtualDestructor" }; -static const std::set<std::string> misra_c_checkers{ - "alwaysFalse", "duplicateBreak", - "alwaysTrue", "redundantCondition", "redundantAssignment", "redundantAssignInSwitch", "unreadVariable", - "unusedVariable", - "unusedLabel", - "shadowVariable", - "funcArgNamesDifferent", +static const std::set<std::string> misrac2012Checkers{ + "alwaysFalse", + "alwaysTrue", + "argumentSize", + "autovarInvalidDeallocation", + "bufferAccessOutOfBounds", + "comparePointers", + "compareValueOutOfTypeRangeError", "constPointer", + "danglingLifetime", + "duplicateBreak", + "error", + "funcArgNamesDifferent", + "incompatibleFileOpen", + "invalidFunctionArg", + "knownConditionTrueFalse", + "leakNoVarFunctionCall", + "leakReturnValNotUsed", + "memleak", + "memleakOnRealloc", + "missingReturn", + "overlappingWriteFunction", + "overlappingWriteUnion", + "pointerOutOfBounds", + "preprocessorErrorDirective", + "redundantAssignInSwitch", + "redundantAssignment", + "redundantCondition", + "resourceLeak", + "shadowVariable", + "sizeofCalculation", + "syntaxError", "uninitvar", - "alwaysTrue", "alwaysFalse", "compareValueOutOfTypeRangeError", "knownConditionTrueFalse", "unknownEvaluationOrder", - "sizeofCalculation", - "missingReturn", + "unreadVariable", + "unusedLabel", + "unusedVariable", + "useClosedFile", + "writeReadOnlyFile" +}; + +static const std::set<std::string> misrac2023Checkers{ + "alwaysFalse", + "alwaysTrue", "argumentSize", - "pointerOutOfBounds", + "autovarInvalidDeallocation", + "bufferAccessOutOfBounds", "comparePointers", + "compareValueOutOfTypeRangeError", + "constPointer", "danglingLifetime", - "overlappingWriteUnion", "overlappingWriteFunction", - "invalidFunctionArg", - "bufferAccessOutOfBounds", - "memleak", "resourceLeak", "memleakOnRealloc", "leakReturnValNotUsed", "leakNoVarFunctionCall", - "autovarInvalidDeallocation", + "duplicateBreak", + "error", + "funcArgNamesDifferent", "incompatibleFileOpen", - "writeReadOnlyFile", - "useClosedFile" -}; - -static const std::set<std::string> misra_cpp_checkers{ - "redundantAssignment", "unreadVariable", "varScope", + "invalidFunctionArg", + "knownConditionTrueFalse", + "leakNoVarFunctionCall", + "leakReturnValNotUsed", + "memleak", + "memleakOnRealloc", + "missingReturn", + "overlappingWriteFunction", + "overlappingWriteUnion", + "pointerOutOfBounds", + "preprocessorErrorDirective", + "redundantAssignInSwitch", + "redundantAssignment", + "redundantCondition", + "resourceLeak", "shadowVariable", + "sizeofCalculation", + "syntaxError", + "uninitvar", "unknownEvaluationOrder", + "unreadVariable", + "unusedLabel", + "unusedVariable", + "useClosedFile", + "writeReadOnlyFile" +}; + +static const std::set<std::string> misracpp2008Checkers{ + "autoVariables", + "comparePointers", + "constParameter", + "constVariable", "cstyleCast", - "constVariable", "constParameter", + "ctuOneDefinitionViolation", "danglingLifetime", + "duplInheritedMember", + "duplicateBreak", + "exceptThrowInDestructor", + "funcArgNamesDifferent", + "functionConst", + "functionStatic", "missingReturn", - "uninitMember", "noExplicit", - "exceptThrowInDestructor", - "throwInDestructor" + "overlappingWriteFunction", + "overlappingWriteUnion", + "pointerOutOfBounds", + "preprocessorErrorDirective", + "redundantAssignment", + "redundantInitialization", + "returnReference", + "returnTempReference", + "shadowVariable", + "shiftTooManyBits", + "sizeofSideEffects", + "throwInDestructor", + "uninitDerivedMemberVar", + "uninitDerivedMemberVarPrivate", + "uninitMemberVar", + "uninitMemberVarPrivate", + "uninitStructMember", + "uninitdata", + "uninitvar", + "unknownEvaluationOrder", + "unreachableCode", + "unreadVariable", + "unsignedLessThanZero", + "unusedFunction", + "unusedStructMember", + "unusedVariable", + "varScope", + "variableScope", + "virtualCallInConstructor" }; bool Settings::isPremiumEnabled(const char id[]) const { - if (premiumArgs.find("autosar") != std::string::npos && autosar_checkers.count(id)) + if (premiumArgs.find("autosar") != std::string::npos && autosarCheckers.count(id)) return true; - if (premiumArgs.find("cert-c-") != std::string::npos && cert_c_checkers.count(id)) + if (premiumArgs.find("cert-c-") != std::string::npos && certCCheckers.count(id)) return true; - if (premiumArgs.find("cert-c++") != std::string::npos && cert_cpp_checkers.count(id)) + if (premiumArgs.find("cert-c++") != std::string::npos && certCppCheckers.count(id)) return true; - if (premiumArgs.find("misra-c-") != std::string::npos && misra_c_checkers.count(id)) + if (premiumArgs.find("misra-c-") != std::string::npos && (misrac2012Checkers.count(id) || misrac2023Checkers.count(id))) return true; - if (premiumArgs.find("misra-c++") != std::string::npos && misra_cpp_checkers.count(id)) + if (premiumArgs.find("misra-c++") != std::string::npos && misracpp2008Checkers.count(id)) return true; return false; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/lib/valueflow.cpp new/cppcheck-2.13.3/lib/valueflow.cpp --- old/cppcheck-2.13.2/lib/valueflow.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/lib/valueflow.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -138,11 +138,11 @@ errorLogger->reportErr(errmsg); } -#define bailout2(type, tokenlist, errorLogger, tok, what) bailoutInternal(type, tokenlist, errorLogger, tok, what, __FILE__, __LINE__, __func__) +#define bailout2(type, tokenlist, errorLogger, tok, what) bailoutInternal((type), (tokenlist), (errorLogger), (tok), (what), __FILE__, __LINE__, __func__) -#define bailout(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailout", tokenlist, errorLogger, tok, what) +#define bailout(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailout", (tokenlist), (errorLogger), (tok), (what)) -#define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) bailoutInternal("valueFlowBailoutIncompleteVar", tokenlist, errorLogger, tok, what, "", 0, __func__) +#define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) bailoutInternal("valueFlowBailoutIncompleteVar", (tokenlist), (errorLogger), (tok), (what), "", 0, __func__) static std::string debugString(const ValueFlow::Value& v) { @@ -9415,7 +9415,7 @@ #define VALUEFLOW_ADAPTOR(cpp, ...) \ makeValueFlowPassAdaptor(#__VA_ARGS__, \ - cpp, \ + (cpp), \ [](TokenList& tokenlist, \ SymbolDatabase& symboldatabase, \ ErrorLogger* errorLogger, \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/lib/version.h new/cppcheck-2.13.3/lib/version.h --- old/cppcheck-2.13.2/lib/version.h 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/lib/version.h 2024-02-03 21:57:54.000000000 +0100 @@ -7,7 +7,7 @@ #define CPPCHECK_MAJOR_VERSION 2 #define CPPCHECK_MINOR_VERSION 13 #define CPPCHECK_DEVMINOR_VERSION 13 -#define CPPCHECK_FIX_VERSION 2 +#define CPPCHECK_FIX_VERSION 3 #define STRINGIFY(x) STRING(x) #define STRING(VER) #VER diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/lib/vfvalue.cpp new/cppcheck-2.13.3/lib/vfvalue.cpp --- old/cppcheck-2.13.2/lib/vfvalue.cpp 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/lib/vfvalue.cpp 2024-02-03 21:57:54.000000000 +0100 @@ -115,6 +115,7 @@ case ValueType::LIFETIME: return "lifetime=" + tokvalue->str(); case ValueType::SYMBOLIC: + { std::string result = "symbolic=" + tokvalue->expressionString(); if (intvalue > 0) result += "+" + std::to_string(intvalue); @@ -122,6 +123,7 @@ result += "-" + std::to_string(-intvalue); return result; } + } throw InternalError(nullptr, "Invalid ValueFlow Value type"); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cppcheck-2.13.2/win_installer/productInfo.wxi new/cppcheck-2.13.3/win_installer/productInfo.wxi --- old/cppcheck-2.13.2/win_installer/productInfo.wxi 2024-01-23 13:30:57.000000000 +0100 +++ new/cppcheck-2.13.3/win_installer/productInfo.wxi 2024-02-03 21:57:54.000000000 +0100 @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <Include> - <?define ProductName = "Cppcheck $(var.Platform) 2.13.2" ?> + <?define ProductName = "Cppcheck $(var.Platform) 2.13.3" ?> <?define ProductNameShort = "Cppcheck" ?> - <?define ProductVersion = "2.13.2" ?> + <?define ProductVersion = "2.13.3" ?> <?define ProductManufacturer = "The Cppcheck team" ?> <?define ProductDescription = "Cppcheck is a tool for static analysis of C/C++ code" ?>