diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index dab78d27c..58abeca23 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -450,11 +450,6 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st } } -void CppCheckExecutor::reportInfo(const ErrorMessage &msg) -{ - reportErr(msg); -} - void CppCheckExecutor::reportStatus(std::size_t fileindex, std::size_t filecount, std::size_t sizedone, std::size_t sizetotal) { if (filecount > 1) { diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index 3218b3d5d..4576d8d4f 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -81,11 +81,6 @@ public: void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override; - /** - * Output information messages. - */ - void reportInfo(const ErrorMessage &msg) override; - /** * Information about how many files have been checked * diff --git a/cli/processexecutor.cpp b/cli/processexecutor.cpp index a07f81b8d..ee3815bb6 100644 --- a/cli/processexecutor.cpp +++ b/cli/processexecutor.cpp @@ -68,7 +68,7 @@ ProcessExecutor::~ProcessExecutor() class PipeWriter : public ErrorLogger { public: - enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', REPORT_INFO='3', REPORT_VERIFICATION='4', CHILD_END='5'}; + enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', REPORT_VERIFICATION='4', CHILD_END='5'}; explicit PipeWriter(int pipe) : mWpipe(pipe) {} @@ -77,11 +77,7 @@ public: } void reportErr(const ErrorMessage &msg) override { - report(msg, MessageType::REPORT_ERROR); - } - - void reportInfo(const ErrorMessage &msg) override { - report(msg, MessageType::REPORT_INFO); + writeToPipe(REPORT_ERROR, msg.serialize()); } void writeEnd(const std::string& str) const { @@ -89,22 +85,6 @@ public: } private: - enum class MessageType {REPORT_ERROR, REPORT_INFO}; - - void report(const ErrorMessage &msg, MessageType msgType) const { - PipeSignal pipeSignal; - switch (msgType) { - case MessageType::REPORT_ERROR: - pipeSignal = REPORT_ERROR; - break; - case MessageType::REPORT_INFO: - pipeSignal = REPORT_INFO; - break; - } - - writeToPipe(pipeSignal, msg.serialize()); - } - void writeToPipe(PipeSignal type, const std::string &data) const { unsigned int len = static_cast(data.length() + 1); @@ -137,7 +117,7 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result) return -1; } - if (type != PipeWriter::REPORT_OUT && type != PipeWriter::REPORT_ERROR && type != PipeWriter::REPORT_INFO && type != PipeWriter::CHILD_END) { + if (type != PipeWriter::REPORT_OUT && type != PipeWriter::REPORT_ERROR && type != PipeWriter::CHILD_END) { std::cerr << "#### ThreadExecutor::handleRead error, type was:" << type << std::endl; std::exit(EXIT_FAILURE); } @@ -160,7 +140,7 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result) if (type == PipeWriter::REPORT_OUT) { mErrorLogger.reportOut(buf); - } else if (type == PipeWriter::REPORT_ERROR || type == PipeWriter::REPORT_INFO) { + } else if (type == PipeWriter::REPORT_ERROR) { ErrorMessage msg; try { msg.deserialize(buf); @@ -169,12 +149,8 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result) std::exit(EXIT_FAILURE); } - if (hasToLog(msg)) { - if (type == PipeWriter::REPORT_ERROR) - mErrorLogger.reportErr(msg); - else - mErrorLogger.reportInfo(msg); - } + if (hasToLog(msg)) + mErrorLogger.reportErr(msg); } else if (type == PipeWriter::CHILD_END) { std::istringstream iss(buf); unsigned int fileResult = 0; diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index aa9f10826..911a895eb 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -113,35 +113,16 @@ public: } void reportErr(const ErrorMessage &msg) override { - report(msg, MessageType::REPORT_ERROR); - } + if (!mThreadExecutor.hasToLog(msg)) + return; - void reportInfo(const ErrorMessage &msg) override { - report(msg, MessageType::REPORT_INFO); + std::lock_guard lg(mReportSync); + mErrorLogger.reportErr(msg); } std::mutex mReportSync; private: - enum class MessageType {REPORT_ERROR, REPORT_INFO}; - - void report(const ErrorMessage &msg, MessageType msgType) - { - if (!mThreadExecutor.hasToLog(msg)) - return; - - std::lock_guard lg(mReportSync); - - switch (msgType) { - case MessageType::REPORT_ERROR: - mErrorLogger.reportErr(msg); - break; - case MessageType::REPORT_INFO: - mErrorLogger.reportInfo(msg); - break; - } - } - ThreadExecutor &mThreadExecutor; ErrorLogger &mErrorLogger; }; diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 71991879a..fea3e2d0f 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1652,12 +1652,6 @@ void CppCheck::reportProgress(const std::string &filename, const char stage[], c mErrorLogger.reportProgress(filename, stage, value); } -void CppCheck::reportInfo(const ErrorMessage &msg) -{ - if (!mSettings.nomsg.isSuppressed(msg)) - mErrorLogger.reportInfo(msg); -} - void CppCheck::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, std::size_t /*sizedone*/, std::size_t /*sizetotal*/) {} diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 1d7411a47..e161f94ae 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -214,11 +214,6 @@ private: void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override; - /** - * Output information messages. - */ - void reportInfo(const ErrorMessage &msg) override; - ErrorLogger &mErrorLogger; /** @brief Current preprocessor configuration */ diff --git a/lib/errorlogger.h b/lib/errorlogger.h index 1b1e08187..6fff2b7e6 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -250,14 +250,6 @@ public: (void)value; } - /** - * Output information messages. - * @param msg Location and other information about the found error. - */ - virtual void reportInfo(const ErrorMessage &msg) { - reportErr(msg); - } - /** * Report unmatched suppressions * @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions)