removed unused `ErrorLogger::reportInfo()` / small `*Executor` cleanup (#4852)
This commit is contained in:
parent
340baf10cd
commit
ad6c5d80ff
|
@ -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)
|
void CppCheckExecutor::reportStatus(std::size_t fileindex, std::size_t filecount, std::size_t sizedone, std::size_t sizetotal)
|
||||||
{
|
{
|
||||||
if (filecount > 1) {
|
if (filecount > 1) {
|
||||||
|
|
|
@ -81,11 +81,6 @@ public:
|
||||||
|
|
||||||
void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override;
|
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
|
* Information about how many files have been checked
|
||||||
*
|
*
|
||||||
|
|
|
@ -68,7 +68,7 @@ ProcessExecutor::~ProcessExecutor()
|
||||||
|
|
||||||
class PipeWriter : public ErrorLogger {
|
class PipeWriter : public ErrorLogger {
|
||||||
public:
|
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) {}
|
explicit PipeWriter(int pipe) : mWpipe(pipe) {}
|
||||||
|
|
||||||
|
@ -77,11 +77,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void reportErr(const ErrorMessage &msg) override {
|
void reportErr(const ErrorMessage &msg) override {
|
||||||
report(msg, MessageType::REPORT_ERROR);
|
writeToPipe(REPORT_ERROR, msg.serialize());
|
||||||
}
|
|
||||||
|
|
||||||
void reportInfo(const ErrorMessage &msg) override {
|
|
||||||
report(msg, MessageType::REPORT_INFO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeEnd(const std::string& str) const {
|
void writeEnd(const std::string& str) const {
|
||||||
|
@ -89,22 +85,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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
|
void writeToPipe(PipeSignal type, const std::string &data) const
|
||||||
{
|
{
|
||||||
unsigned int len = static_cast<unsigned int>(data.length() + 1);
|
unsigned int len = static_cast<unsigned int>(data.length() + 1);
|
||||||
|
@ -137,7 +117,7 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result)
|
||||||
return -1;
|
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::cerr << "#### ThreadExecutor::handleRead error, type was:" << type << std::endl;
|
||||||
std::exit(EXIT_FAILURE);
|
std::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -160,7 +140,7 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result)
|
||||||
|
|
||||||
if (type == PipeWriter::REPORT_OUT) {
|
if (type == PipeWriter::REPORT_OUT) {
|
||||||
mErrorLogger.reportOut(buf);
|
mErrorLogger.reportOut(buf);
|
||||||
} else if (type == PipeWriter::REPORT_ERROR || type == PipeWriter::REPORT_INFO) {
|
} else if (type == PipeWriter::REPORT_ERROR) {
|
||||||
ErrorMessage msg;
|
ErrorMessage msg;
|
||||||
try {
|
try {
|
||||||
msg.deserialize(buf);
|
msg.deserialize(buf);
|
||||||
|
@ -169,12 +149,8 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result)
|
||||||
std::exit(EXIT_FAILURE);
|
std::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasToLog(msg)) {
|
if (hasToLog(msg))
|
||||||
if (type == PipeWriter::REPORT_ERROR)
|
mErrorLogger.reportErr(msg);
|
||||||
mErrorLogger.reportErr(msg);
|
|
||||||
else
|
|
||||||
mErrorLogger.reportInfo(msg);
|
|
||||||
}
|
|
||||||
} else if (type == PipeWriter::CHILD_END) {
|
} else if (type == PipeWriter::CHILD_END) {
|
||||||
std::istringstream iss(buf);
|
std::istringstream iss(buf);
|
||||||
unsigned int fileResult = 0;
|
unsigned int fileResult = 0;
|
||||||
|
|
|
@ -113,35 +113,16 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void reportErr(const ErrorMessage &msg) override {
|
void reportErr(const ErrorMessage &msg) override {
|
||||||
report(msg, MessageType::REPORT_ERROR);
|
if (!mThreadExecutor.hasToLog(msg))
|
||||||
}
|
return;
|
||||||
|
|
||||||
void reportInfo(const ErrorMessage &msg) override {
|
std::lock_guard<std::mutex> lg(mReportSync);
|
||||||
report(msg, MessageType::REPORT_INFO);
|
mErrorLogger.reportErr(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::mutex mReportSync;
|
std::mutex mReportSync;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class MessageType {REPORT_ERROR, REPORT_INFO};
|
|
||||||
|
|
||||||
void report(const ErrorMessage &msg, MessageType msgType)
|
|
||||||
{
|
|
||||||
if (!mThreadExecutor.hasToLog(msg))
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lg(mReportSync);
|
|
||||||
|
|
||||||
switch (msgType) {
|
|
||||||
case MessageType::REPORT_ERROR:
|
|
||||||
mErrorLogger.reportErr(msg);
|
|
||||||
break;
|
|
||||||
case MessageType::REPORT_INFO:
|
|
||||||
mErrorLogger.reportInfo(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadExecutor &mThreadExecutor;
|
ThreadExecutor &mThreadExecutor;
|
||||||
ErrorLogger &mErrorLogger;
|
ErrorLogger &mErrorLogger;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1652,12 +1652,6 @@ void CppCheck::reportProgress(const std::string &filename, const char stage[], c
|
||||||
mErrorLogger.reportProgress(filename, stage, value);
|
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*/)
|
void CppCheck::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, std::size_t /*sizedone*/, std::size_t /*sizetotal*/)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -214,11 +214,6 @@ private:
|
||||||
|
|
||||||
void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override;
|
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;
|
ErrorLogger &mErrorLogger;
|
||||||
|
|
||||||
/** @brief Current preprocessor configuration */
|
/** @brief Current preprocessor configuration */
|
||||||
|
|
|
@ -250,14 +250,6 @@ public:
|
||||||
(void)value;
|
(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
|
* Report unmatched suppressions
|
||||||
* @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions)
|
* @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions)
|
||||||
|
|
Loading…
Reference in New Issue