Change some args from pass-by-value (satisfies cppcheck)

This commit is contained in:
Martin Vierula 2022-06-15 07:20:28 -07:00
parent d2a1080db2
commit c3b7a7f4f0
No known key found for this signature in database
GPG Key ID: F2FC4E45883BCBA4
3 changed files with 4 additions and 6 deletions

View File

@ -151,7 +151,7 @@ std::list<std::string> expandEnv(const std::string& var, int flags) {
return vars;
}
bool createDir(std::string dir, int mode, std::string *error) {
bool createDir(const std::string& dir, int mode, std::string *error) {
int ret = mkdir(dir.data(), mode);
if (ret != 0 && errno != EEXIST) {
error->assign("Not able to create directory: " + dir + ": " \
@ -163,7 +163,7 @@ bool createDir(std::string dir, int mode, std::string *error) {
}
bool isFile(std::string f) {
bool isFile(const std::string& f) {
struct stat fileInfo;
FILE *fp = fopen(f.c_str(), "r");
if (fp == NULL) {

View File

@ -33,8 +33,8 @@ std::string find_resource(const std::string& file, const std::string& config,
std::string *err);
std::string get_path(const std::string& file);
std::list<std::string> expandEnv(const std::string& var, int flags);
bool createDir(std::string dir, int mode, std::string *error);
bool isFile(std::string f);
bool createDir(const std::string& dir, int mode, std::string *error);
bool isFile(const std::string& f);
} // namespace utils
} // namespace modsecurity

View File

@ -62,8 +62,6 @@ ctunullpointer:src/rule_with_operator.cc:95
passedByValue:src/variables/global.h:109
passedByValue:src/variables/global.h:110
passedByValue:src/parser/driver.cc:45
passedByValue:src/utils/system.cc:154
passedByValue:src/utils/system.cc:166
passedByValue:test/common/modsecurity_test.cc:49
passedByValue:test/common/modsecurity_test.cc:98