Skip to content

Commit f5a6fcd

Browse files
authored
Merge pull request #3577 from airween/v3/cppcheck221
fix: cppcheck warnings with version 2.21.0
2 parents 2fd4929 + cce33c6 commit f5a6fcd

9 files changed

Lines changed: 35 additions & 35 deletions

File tree

examples/reading_logs_via_rule_message/reading_logs_via_rule_message.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,20 @@ static void process_request(modsecurity::ModSecurity *modsec, modsecurity::Rules
9696

9797
class ReadingLogsViaRuleMessage {
9898
public:
99-
ReadingLogsViaRuleMessage(char *request_header,
100-
char *request_uri,
101-
char *request_body,
102-
char *response_headers,
103-
char *response_body,
104-
char *ip,
105-
const std::string &rules) :
106-
m_request_header(request_header),
107-
m_request_uri(request_uri),
108-
m_request_body(request_body),
109-
m_response_headers(response_headers),
110-
m_response_body(response_body),
111-
m_ip(ip),
112-
m_rules(rules)
99+
ReadingLogsViaRuleMessage(char *arg_request_header,
100+
char *arg_request_uri,
101+
char *arg_request_body,
102+
char *arg_response_headers,
103+
char *arg_response_body,
104+
char *arg_ip,
105+
const std::string &arg_rules) :
106+
m_request_header(arg_request_header),
107+
m_request_uri(arg_request_uri),
108+
m_request_body(arg_request_body),
109+
m_response_headers(arg_response_headers),
110+
m_response_body(arg_response_body),
111+
m_ip(arg_ip),
112+
m_rules(arg_rules)
113113
{ }
114114

115115
int process() const {

headers/modsecurity/transaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class Transaction : public TransactionAnchoredVariables, public TransactionSecMa
405405
size_t getRequestBodyLength();
406406

407407
#ifndef NO_LOGS
408-
void debug(int, const std::string &) const;
408+
void debug(int level, const std::string& message) const;
409409
#endif
410410
void serverLog(const RuleMessage &rm);
411411

src/modsecurity.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void ModSecurity::setServerLogCb(ModSecLogCb cb) {
391391
}
392392

393393

394-
void ModSecurity::setServerLogCb(ModSecLogCb cb, int properties) {
394+
void ModSecurity::setServerLogCb(ModSecLogCb cb, int properties) { // cppcheck-suppress funcArgNamesDifferentUnnamed - this is a false positive
395395
m_logCb = (ModSecLogCb) cb;
396396
m_logProperties = properties;
397397
}

src/request_body_processor/xml.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class XMLNodes {
6060
// need to stop parsing if the number of arguments reached the limit
6161
xmlParserCtxtPtr parsing_ctx_arg;
6262

63-
explicit XMLNodes (Transaction *);
63+
explicit XMLNodes(Transaction *transaction);
6464
~XMLNodes();
6565
};
6666

@@ -69,7 +69,7 @@ struct xml_data {
6969
xmlParserCtxtPtr parsing_ctx;
7070
xmlDocPtr doc;
7171

72-
unsigned int well_formed;
72+
unsigned int well_formed = 0;
7373

7474
/* error reporting and XML array flag */
7575
std::string xml_error;

src/utils/shared_files.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ class SharedFiles {
5555
void operator=(SharedFiles const&) = delete;
5656

5757
struct handler_info {
58-
FILE* fp;
58+
FILE* fp = nullptr;
5959
#ifdef WIN32
60-
HANDLE hMutex;
60+
HANDLE hMutex = nullptr;
6161
#endif
62-
unsigned int cnt;
62+
unsigned int cnt = 0;
6363
};
6464

6565
using handlers_map = std::unordered_map<std::string, handler_info>;

test/common/modsecurity_test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ template <class T> class ModSecurityTest :
3434
ModSecurityTest() = default;
3535

3636
std::string header();
37-
void cmd_options(int, char **);
37+
void cmd_options(int argc, char** argv);
3838
void load_tests();
3939
void load_tests(const std::string &path);
4040
bool load_test_json(const std::string &file);

test/common/modsecurity_test_results.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace modsecurity_test {
2525
template <class T> class ModSecurityTestResults : public std::vector<T *> {
2626
public:
2727
std::string log_raw_debug_log;
28-
int status;
28+
int status = 0;
2929
std::string location;
3030
};
3131

test/regression/regression_test.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace modsecurity_test {
3232

3333
class RegressionTest {
3434
public:
35-
static std::unique_ptr<RegressionTest> from_yajl_node(const yajl_val &);
35+
static std::unique_ptr<RegressionTest> from_yajl_node(const yajl_val &node);
3636

3737
static std::string print();
3838
std::string filename;
@@ -42,8 +42,8 @@ class RegressionTest {
4242
std::string rules;
4343

4444
std::string url;
45-
int enabled;
46-
int version_min;
45+
int enabled = 0;
46+
int version_min = 0;
4747
std::optional<int> version_max;
4848
std::optional<int> github_issue;
4949

@@ -60,8 +60,8 @@ class RegressionTest {
6060

6161
std::string clientIp;
6262
std::string serverIp;
63-
int clientPort;
64-
int serverPort;
63+
int clientPort = 0;
64+
int serverPort = 0;
6565
std::string hostname;
6666

6767
std::string method;
@@ -75,7 +75,7 @@ class RegressionTest {
7575
static inline std::vector<std::pair<std::string, std::string>>
7676
yajl_array_to_map(const yajl_val &node);
7777

78-
int http_code;
78+
int http_code = 0;
7979
std::string redirect_url;
8080

8181
// fields for formatting JSON
@@ -96,7 +96,7 @@ class RegressionTest {
9696

9797
class RegressionTests {
9898
public:
99-
static std::unique_ptr<RegressionTests> from_yajl_node(const yajl_val &);
99+
static std::unique_ptr<RegressionTests> from_yajl_node(const yajl_val &node);
100100
void update_content_lengths();
101101
std::string toJSON() const;
102102

test/unit/unit_test.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ namespace modsecurity_test {
2727

2828
class UnitTestResult {
2929
public:
30-
int ret;
30+
int ret = 0;
3131
std::string output;
3232
};
3333

3434
class UnitTest {
3535
public:
36-
static std::unique_ptr<UnitTest> from_yajl_node(const yajl_val &);
36+
static std::unique_ptr<UnitTest> from_yajl_node(const yajl_val &node);
3737

3838
std::string print() const;
3939

@@ -45,9 +45,9 @@ class UnitTest {
4545
std::string filename;
4646
std::string output;
4747
std::string libinjection_override;
48-
int ret;
49-
int capture;
50-
int skipped;
48+
int ret = 0;
49+
int capture = 0;
50+
int skipped = 0;
5151
UnitTestResult result;
5252
};
5353

0 commit comments

Comments
 (0)