Skip to content

Commit 94b68b2

Browse files
committed
Minor updates to simplify code and remove cppcheck suppressions
1 parent fde9d27 commit 94b68b2

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

test/common/modsecurity_test.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ std::string ModSecurityTest<T>::header() {
4646
}
4747

4848
template <class T>
49-
bool ModSecurityTest<T>::load_test_json(std::string file) {
49+
bool ModSecurityTest<T>::load_test_json(const std::string &file) {
5050
char errbuf[1024];
5151
yajl_val node;
5252

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

7878
if (this->count(u->filename + ":" + u->name) == 0) {
79-
std::vector<T *> *vector = new std::vector<T *>;
80-
vector->push_back(u);
79+
auto vec = new std::vector<T *>;
80+
vec->push_back(u);
8181
std::string filename(u->filename + ":" + u->name);
82-
std::pair<std::string, std::vector<T*>*> a(filename, vector);
83-
this->insert(a);
82+
this->insert({filename, vec});
8483
} else {
85-
std::vector<T *> *vec = this->at(u->filename + ":" + u->name);
84+
auto vec = this->at(u->filename + ":" + u->name);
8685
vec->push_back(u);
8786
}
8887
}
@@ -95,7 +94,7 @@ bool ModSecurityTest<T>::load_test_json(std::string file) {
9594

9695
template <class T>
9796
std::pair<std::string, std::vector<T *>>*
98-
ModSecurityTest<T>::load_tests(std::string path) {
97+
ModSecurityTest<T>::load_tests(const std::string &path) {
9998
DIR *dir;
10099
struct dirent *ent;
101100
struct stat buffer;

test/common/modsecurity_test.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ template <class T> class ModSecurityTest :
3939
std::string header();
4040
void cmd_options(int, char **);
4141
std::pair<std::string, std::vector<T *>>* load_tests();
42-
std::pair<std::string, std::vector<T *>>* load_tests(std::string path);
43-
bool load_test_json(std::string);
42+
std::pair<std::string, std::vector<T *>>* load_tests(const std::string &path);
43+
bool load_test_json(const std::string &file);
4444

4545
std::string target;
4646
bool verbose = false;

test/cppcheck_suppressions.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ functionStatic:src/engine/lua.h:70
4343
functionStatic:src/engine/lua.h:71
4444
functionConst:src/utils/geo_lookup.h:49
4545
useInitializationList:src/operators/rbl.h:69
46-
constStatement:test/common/modsecurity_test.cc:82
4746
functionStatic:src/operators/geo_lookup.h:35
4847
duplicateBreak:src/operators/validate_utf8_encoding.cc
4948
syntaxError:src/transaction.cc:62
@@ -55,8 +54,6 @@ rethrowNoCurrentException:src/rule_with_actions.cc:127
5554
ctunullpointer:src/rule_with_actions.cc:244
5655
ctunullpointer:src/rule_with_operator.cc:135
5756
ctunullpointer:src/rule_with_operator.cc:95
58-
passedByValue:test/common/modsecurity_test.cc:49
59-
passedByValue:test/common/modsecurity_test.cc:98
6057
unreadVariable:src/rule_with_operator.cc:219
6158

6259
uninitvar:src/operators/verify_cpf.cc:77

0 commit comments

Comments
 (0)