From 1be43ace642eca902954b24a782fe91281fed781 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 6 May 2026 12:31:35 +0200 Subject: [PATCH 1/2] only issue `logChecker` messages when necessary --- cli/cppcheckexecutor.cpp | 7 +++---- lib/check.cpp | 4 ++-- lib/settings.h | 14 ++++++++++++++ test/cli/other_test.py | 3 +-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 5fb4d89855d..19f1f26bcda 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -501,6 +501,7 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup void StdLogger::writeCheckersReport(const Suppressions& supprs) { + // TODO: only necessary when we actually issue a checkers report? if (!mCheckersFile.empty()) { std::ofstream fout(mCheckersFile); @@ -510,11 +511,9 @@ void StdLogger::writeCheckersReport(const Suppressions& supprs) } } - const bool summary = mSettings.safety || mSettings.severity.isEnabled(Severity::information); - const bool xmlReport = mSettings.outputFormat == Settings::OutputFormat::xml && mSettings.xml_version == 3; - const bool textReport = !mSettings.checkersReportFilename.empty(); + bool summary, xmlReport, textReport; - if (!summary && !xmlReport && !textReport) + if (!mSettings.collectLogCheckers(&summary, &xmlReport, &textReport)) return; CheckersReport checkersReport(mSettings, mActiveCheckers); diff --git a/lib/check.cpp b/lib/check.cpp index 1d0cfe61792..812c8b02fcd 100644 --- a/lib/check.cpp +++ b/lib/check.cpp @@ -130,7 +130,7 @@ ErrorPath Check::getErrorPath(const Token* errtok, const ValueFlow::Value* value void Check::logChecker(const char id[]) { - // TODO: only issue when we would actually use it later on - reportError(nullptr, Severity::internal, "logChecker", id); + if (!mSettings->buildDir.empty() || mSettings->collectLogCheckers()) + reportError(nullptr, Severity::internal, "logChecker", id); } diff --git a/lib/settings.h b/lib/settings.h index 8e0881562ed..37f9be4dfdf 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -596,6 +596,20 @@ class CPPCHECKLIB WARN_UNUSED Settings { static bool unusedFunctionOnly(); + bool collectLogCheckers(bool* summary = nullptr, bool* xmlReport = nullptr, bool* textReport = nullptr) const { + const bool s = safety || severity.isEnabled(Severity::information); + if (summary) + *summary = s; + const bool x = outputFormat == Settings::OutputFormat::xml && xml_version == 3; + if (xmlReport) + *xmlReport = x; + const bool t = !checkersReportFilename.empty(); + if (textReport) + *textReport = t; + + return s || x || t; + } + private: static std::string parseEnabled(const std::string &str, std::tuple, SimpleEnableGroup> &groups); std::string applyEnabled(const std::string &str, bool enable); diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 72f0a7a00bd..b4bfe34a53b 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -4636,9 +4636,8 @@ def test_dui_include_absolute_missing(tmp_path): # #14675 ] -@pytest.mark.xfail(strict=True) # TODO: should not report logChecker when not required @pytest.mark.skipif(sys.platform == 'win32', reason="requires ProcessExecutor") -def test_ipc_log_checker(tmp_path): +def test_ipc(tmp_path): test_file = tmp_path / 'test.c' with open(test_file, "w") as f: f.write('void f() {}') From 43a95b57dbca342136dfc2d8e4798bfaa5f00cac Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 7 May 2026 00:55:23 +0200 Subject: [PATCH 2/2] processexecutor.cpp: fixed cast in IPC debug message --- cli/processexecutor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/processexecutor.cpp b/cli/processexecutor.cpp index f7c04301ac5..e430f6ccbf2 100644 --- a/cli/processexecutor.cpp +++ b/cli/processexecutor.cpp @@ -154,7 +154,7 @@ namespace { void writeToPipe(PipeSignal type, const std::string &data) const { if (mDebug) - std::cout << "writeToPipe - " << static_cast(type) << " - " << data << std::endl; + std::cout << "writeToPipe - " << static_cast(type) << " - " << data << std::endl; { const auto t = static_cast(type);