From 0cb15ddcc20ffff8e223bbbf6dc3e608d1daf4ea Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 2 Nov 2023 20:39:39 +0100 Subject: [PATCH 1/2] CppCheckExecutor: made more member functions private --- cli/cppcheckexecutor.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index 55d70e3d799..f88d893c010 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -71,6 +71,8 @@ class CppCheckExecutor : public ErrorLogger { */ int check(int argc, const char* const argv[]); +private: + /** * Information about progress is directed here. This should be * called by the CppCheck class only. @@ -84,6 +86,8 @@ class CppCheckExecutor : public ErrorLogger { void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override; +public: + /** * @param exceptionOutput Output file */ @@ -99,13 +103,13 @@ class CppCheckExecutor : public ErrorLogger { */ static bool tryLoadLibrary(Library& destination, const std::string& basepath, const char* filename); +private: + /** * Execute a shell command and read the output from it. Returns exitcode of the executed command,. */ static int executeCommand(std::string exe, std::vector args, std::string redirect, std::string &output_); -protected: - /** * Helper function to print out errors. Appends a line change. * @param errmsg String printed to error stream @@ -123,8 +127,6 @@ class CppCheckExecutor : public ErrorLogger { */ bool parseFromArgs(Settings &settings, int argc, const char* const argv[]); -private: - static bool reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map &files, ErrorLogger& errorLogger); /** From 79ed58cdaa547dbb41dcbe525f08463011ef9a6c Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 2 Nov 2023 20:40:27 +0100 Subject: [PATCH 2/2] do not explicitly load `windows.cfg` during command-line parsing --- cli/cmdlineparser.cpp | 6 +----- cli/cppcheckexecutor.h | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 3e8ea4cf5e5..50b43a2e538 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -713,11 +713,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) { if (project.guiProject.analyzeAllVsConfigs == "false") project.selectOneVsConfig(mSettings.platform.type); - if (!CppCheckExecutor::tryLoadLibrary(mSettings.library, argv[0], "windows.cfg")) { - // This shouldn't happen normally. - mLogger.printError("failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install."); - return false; - } + mSettings.libraries.emplace_back("windows"); } if (projType == ImportProject::Type::MISSING) { mLogger.printError("failed to open project '" + projectFile + "'. The file does not exist."); diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index f88d893c010..b1662ea3e17 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -97,14 +97,14 @@ class CppCheckExecutor : public ErrorLogger { */ static FILE* getExceptionOutput(); +private: + /** * Tries to load a library and prints warning/error messages * @return false, if an error occurred (except unknown XML elements) */ static bool tryLoadLibrary(Library& destination, const std::string& basepath, const char* filename); -private: - /** * Execute a shell command and read the output from it. Returns exitcode of the executed command,. */