Skip to content

Commit

Permalink
Minor updates to simplify code and remove cppcheck suppressions
Browse files Browse the repository at this point in the history
  • Loading branch information
eduar-hte committed Apr 28, 2024
1 parent 14c68c3 commit 17cbe16
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
13 changes: 6 additions & 7 deletions test/common/modsecurity_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ std::string ModSecurityTest<T>::header() {
}

template <class T>
bool ModSecurityTest<T>::load_test_json(std::string file) {
bool ModSecurityTest<T>::load_test_json(const std::string &file) {
char errbuf[1024];
yajl_val node;

Expand Down Expand Up @@ -76,13 +76,12 @@ bool ModSecurityTest<T>::load_test_json(std::string file) {
u->filename = file;

if (this->count(u->filename + ":" + u->name) == 0) {
std::vector<T *> *vector = new std::vector<T *>;
vector->push_back(u);
auto vec = new std::vector<T *>;
vec->push_back(u);
std::string filename(u->filename + ":" + u->name);
std::pair<std::string, std::vector<T*>*> a(filename, vector);
this->insert(a);
this->insert({filename, vec});
} else {
std::vector<T *> *vec = this->at(u->filename + ":" + u->name);
auto vec = this->at(u->filename + ":" + u->name);
vec->push_back(u);
}
}
Expand All @@ -95,7 +94,7 @@ bool ModSecurityTest<T>::load_test_json(std::string file) {

template <class T>
std::pair<std::string, std::vector<T *>>*
ModSecurityTest<T>::load_tests(std::string path) {
ModSecurityTest<T>::load_tests(const std::string &path) {
DIR *dir;
struct dirent *ent;
struct stat buffer;
Expand Down
4 changes: 2 additions & 2 deletions test/common/modsecurity_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ template <class T> class ModSecurityTest :
std::string header();
void cmd_options(int, char **);
std::pair<std::string, std::vector<T *>>* load_tests();
std::pair<std::string, std::vector<T *>>* load_tests(std::string path);
bool load_test_json(std::string);
std::pair<std::string, std::vector<T *>>* load_tests(const std::string &path);
bool load_test_json(const std::string &file);

std::string target;
bool verbose = false;
Expand Down
3 changes: 0 additions & 3 deletions test/cppcheck_suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ functionStatic:src/engine/lua.h:70
functionStatic:src/engine/lua.h:71
functionConst:src/utils/geo_lookup.h:49
useInitializationList:src/operators/rbl.h:73
constStatement:test/common/modsecurity_test.cc:82
functionStatic:src/operators/geo_lookup.h:35
duplicateBreak:src/operators/validate_utf8_encoding.cc
syntaxError:src/transaction.cc:65
Expand All @@ -52,8 +51,6 @@ rethrowNoCurrentException:src/rule_with_actions.cc:127
ctunullpointer:src/rule_with_actions.cc:242
ctunullpointer:src/rule_with_operator.cc:135
ctunullpointer:src/rule_with_operator.cc:95
passedByValue:test/common/modsecurity_test.cc:49
passedByValue:test/common/modsecurity_test.cc:98
unreadVariable:src/rule_with_operator.cc:219

uninitvar:src/operators/verify_cpf.cc:77
Expand Down

0 comments on commit 17cbe16

Please sign in to comment.