Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CppCheckExecutor: do not modify settings after they were passed to CppCheck #5697

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,13 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
return EXIT_SUCCESS;
}

settings.loadSummaries();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to check settings.buildDir before calling this since it will do that by itself.


mFiles = parser.getFiles();
mFileSettings = parser.getFileSettings();

mStdLogger = new StdLogger(settings);

CppCheck cppCheck(*mStdLogger, true, executeCommand);
cppCheck.settings() = settings;

Expand Down Expand Up @@ -230,9 +233,10 @@ bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedF
/*
* That is a method which gets called from check_wrapper
* */
int CppCheckExecutor::check_internal(CppCheck& cppcheck)
int CppCheckExecutor::check_internal(CppCheck& cppcheck) const
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did not detect this since the function body contains preprocessor usage.

{
Settings& settings = cppcheck.settings();
const auto& settings = cppcheck.settings();
auto& suppressions = cppcheck.settings().nomsg;

if (settings.reportProgress >= 0)
mStdLogger->resetLatestProgressOutputTime();
Expand All @@ -242,8 +246,6 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
}

if (!settings.buildDir.empty()) {
settings.loadSummaries();

std::list<std::string> fileNames;
for (std::list<std::pair<std::string, std::size_t>>::const_iterator i = mFiles.cbegin(); i != mFiles.cend(); ++i)
fileNames.emplace_back(i->first);
Expand All @@ -256,13 +258,13 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
unsigned int returnValue;
if (settings.useSingleJob()) {
// Single process
SingleExecutor executor(cppcheck, mFiles, mFileSettings, settings, settings.nomsg, *mStdLogger);
SingleExecutor executor(cppcheck, mFiles, mFileSettings, settings, suppressions, *mStdLogger);
returnValue = executor.check();
} else {
#if defined(THREADING_MODEL_THREAD)
ThreadExecutor executor(mFiles, mFileSettings, settings, settings.nomsg, *mStdLogger, CppCheckExecutor::executeCommand);
ThreadExecutor executor(mFiles, mFileSettings, settings, suppressions, *mStdLogger, CppCheckExecutor::executeCommand);
#elif defined(THREADING_MODEL_FORK)
ProcessExecutor executor(mFiles, mFileSettings, settings, settings.nomsg, *mStdLogger, CppCheckExecutor::executeCommand);
ProcessExecutor executor(mFiles, mFileSettings, settings, suppressions, *mStdLogger, CppCheckExecutor::executeCommand);
#endif
returnValue = executor.check();
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cppcheckexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class CppCheckExecutor {
* given value is returned instead of default 0.
* If no errors are found, 0 is returned.
*/
int check_internal(CppCheck& cppcheck);
int check_internal(CppCheck& cppcheck) const;

/**
* Filename associated with size of file
Expand Down
2 changes: 1 addition & 1 deletion cli/cppcheckexecutorseh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ namespace {
* TODO Check for multi-threading issues!
*
*/
int check_wrapper_seh(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&), CppCheck& cppcheck)
int check_wrapper_seh(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&) const, CppCheck& cppcheck)
{
FILE *outputFile = CppCheckExecutor::getExceptionOutput();
__try {
Expand Down
2 changes: 1 addition & 1 deletion cli/cppcheckexecutorseh.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class CppCheckExecutor;
class CppCheck;

int check_wrapper_seh(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&), CppCheck& cppcheck);
int check_wrapper_seh(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&) const, CppCheck& cppcheck);

#endif

Expand Down
2 changes: 1 addition & 1 deletion cli/cppcheckexecutorsig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
}
}

int check_wrapper_sig(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&), CppCheck& cppcheck)
int check_wrapper_sig(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&) const, CppCheck& cppcheck)
{
// determine stack vs. heap
char stackVariable;
Expand Down
2 changes: 1 addition & 1 deletion cli/cppcheckexecutorsig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class CppCheckExecutor;
class CppCheck;

int check_wrapper_sig(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&), CppCheck& cppcheck);
int check_wrapper_sig(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&) const, CppCheck& cppcheck);

#endif // CPPCHECKEXECUTORSIG_H

Expand Down
Loading