Skip to content

Commit fe98ce4

Browse files
committed
Cosmetics: address cppcheck warnings
1 parent 68ef2de commit fe98ce4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+354
-275
lines changed

Makefile.am

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,17 @@ parser:
5656

5757

5858
cppcheck:
59-
@cppcheck -U YYSTYPE \
60-
--suppressions-list=./test/cppcheck_suppressions.txt \
61-
--enable=all \
62-
--inconclusive \
63-
--template="warning: {file},{line},{severity},{id},{message}" \
64-
-I headers -I . -I others -I src -I others/mbedtls -I src/parser \
65-
--error-exitcode=0 \
66-
-i "src/parser/seclang-parser.cc" -i "src/parser/seclang-scanner.cc" \
67-
.
59+
@cppcheck -U YYSTYPE -U MBEDTLS_MD5_ALT -U MBEDTLS_SHA1_ALT \
60+
-D MS_CPPCHECK_DISABLED_FOR_PARSER \
61+
--suppressions-list=./test/cppcheck_suppressions.txt \
62+
--enable=all \
63+
--inconclusive \
64+
--template="warning: {file},{line},{severity},{id},{message}" \
65+
-I headers -I . -I others -I src -I others/mbedtls -I src/parser \
66+
--error-exitcode=1 \
67+
-i "src/parser/seclang-parser.cc" -i "src/parser/seclang-scanner.cc" \
68+
--force --verbose .
69+
6870

6971
check-static: cppcheck
7072

build/lua.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AC_DEFUN([CHECK_LUA],
66
[dnl
77
88
# Possible names for the lua library/package (pkg-config)
9-
LUA_POSSIBLE_LIB_NAMES="luajit luajit-5.1 lua53 lua5.3 lua-5.3 lua52 lua5.2 lua-5.2 lua51 lua5.1 lua-5.1 lua"
9+
LUA_POSSIBLE_LIB_NAMES="lua53 lua5.3 lua-5.3 lua52 lua5.2 lua-5.2 lua51 lua5.1 lua-5.1 lua"
1010
1111
# Possible extensions for the library
1212
LUA_POSSIBLE_EXTENSIONS="so so0 la sl dll dylib so.0.0.0"

examples/reading_logs_via_rule_message/reading_logs_via_rule_message.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class ReadingLogsViaRuleMessage {
115115
char *response_headers,
116116
char *response_body,
117117
char *ip,
118-
std::string rules) :
118+
const std::string &rules) :
119119
m_request_header(request_header),
120120
m_request_uri(request_uri),
121121
m_request_body(request_body),
@@ -133,7 +133,6 @@ class ReadingLogsViaRuleMessage {
133133

134134
modsecurity::ModSecurity *modsec;
135135
modsecurity::Rules *rules;
136-
modsecurity::ModSecurityIntervention it;
137136

138137
modsec = new modsecurity::ModSecurity();
139138
modsec->setConnectorInformation("ModSecurity-test v0.0.1-alpha" \
@@ -168,8 +167,6 @@ class ReadingLogsViaRuleMessage {
168167
delete modsec;
169168
pthread_exit(NULL);
170169
return 0;
171-
end:
172-
return -1;
173170
}
174171

175172
static void logCb(void *data, const void *ruleMessagev) {

examples/using_bodies_in_chunks/simple_request.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ int process_intervention(modsecurity::Transaction *transaction) {
126126
int main(int argc, char **argv) {
127127
modsecurity::ModSecurity *modsec;
128128
modsecurity::Rules *rules;
129-
modsecurity::ModSecurityIntervention it;
130129

131130
if (argc < 2) {
132131
std::cout << "Use " << *argv << " test-case-file.conf";

headers/modsecurity/anchored_set_variable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct MyHash{
7171
class AnchoredSetVariable : public std::unordered_multimap<std::string,
7272
VariableValue *, MyHash, MyEqual> {
7373
public:
74-
AnchoredSetVariable(Transaction *t, std::string name);
74+
AnchoredSetVariable(Transaction *t, const std::string &name);
7575
~AnchoredSetVariable();
7676

7777
void unset();

headers/modsecurity/anchored_variable.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@ class Transaction;
4242

4343
class AnchoredVariable {
4444
public:
45-
AnchoredVariable(Transaction* t, std::string name);
46-
47-
AnchoredVariable(const AnchoredVariable &a) {
48-
m_transaction = a.m_transaction;
49-
m_offset = a.m_offset;
50-
m_name = a.m_name;
51-
m_value = a.m_value;
52-
m_var = a.m_var;
53-
}
45+
AnchoredVariable(Transaction* t, const std::string &name);
46+
47+
AnchoredVariable(const AnchoredVariable &a) = delete;
48+
AnchoredVariable &operator= (const AnchoredVariable &a) = delete;
49+
50+
/*
51+
: m_transaction(a.m_transaction),
52+
m_offset(a.m_offset),
53+
m_name(a.m_name),
54+
m_value(a.m_value),
55+
m_var(a.m_var) { }
56+
*/
5457

5558
~AnchoredVariable();
5659

headers/modsecurity/audit_log.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class Writer;
3737
class AuditLog {
3838
public:
3939
AuditLog();
40-
~AuditLog();
40+
virtual ~AuditLog();
41+
42+
AuditLog(const AuditLog &a) = delete;
4143

4244
enum AuditLogType {
4345
NotSetAuditLogType,
@@ -158,22 +160,22 @@ class AuditLog {
158160
bool setStorageDir(const std::basic_string<char>& path);
159161
bool setFormat(AuditLogFormat fmt);
160162

161-
int getDirectoryPermission();
162-
int getFilePermission();
163-
int getParts();
163+
int getDirectoryPermission() const;
164+
int getFilePermission() const;
165+
int getParts() const;
164166

165167
bool setParts(const std::basic_string<char>& new_parts);
166168
bool setType(AuditLogType audit_type);
167169

168170
bool init(std::string *error);
169-
bool close();
171+
virtual bool close();
170172

171173
bool saveIfRelevant(Transaction *transaction);
172174
bool saveIfRelevant(Transaction *transaction, int parts);
173175
bool isRelevant(int status);
174176

175-
int addParts(int parts, const std::string& new_parts);
176-
int removeParts(int parts, const std::string& new_parts);
177+
static int addParts(int parts, const std::string& new_parts);
178+
static int removeParts(int parts, const std::string& new_parts);
177179

178180
bool merge(AuditLog *from, std::string *error);
179181

headers/modsecurity/collection/collection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace collection {
4444

4545
class Collection {
4646
public:
47-
explicit Collection(std::string a) : m_name(a) { }
47+
explicit Collection(const std::string &a) : m_name(a) { }
4848
virtual ~Collection() { }
4949
virtual void store(std::string key, std::string value) = 0;
5050

headers/modsecurity/collection/collections.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class Collections {
4949
Collection *user, Collection *resource);
5050
~Collections();
5151

52+
Collections(const Collections &c) = delete;
53+
Collections& operator =(const Collections &c) = delete;
54+
5255
std::string m_global_collection_key;
5356
std::string m_ip_collection_key;
5457
std::string m_session_collection_key;

headers/modsecurity/debug_log.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ class DebugLog {
4343
virtual void write(int level, const std::string &msg);
4444
virtual void write(int level, const std::string &id,
4545
const std::string &uri, const std::string &msg);
46-
bool isLogFileSet();
47-
bool isLogLevelSet();
48-
void setDebugLogLevel(int level);
49-
void setDebugLogFile(const std::string &fileName, std::string *error);
50-
const std::string& getDebugLogFile();
46+
virtual bool isLogFileSet();
47+
virtual bool isLogLevelSet();
48+
virtual void setDebugLogLevel(int level);
49+
virtual void setDebugLogFile(const std::string &fileName, std::string *error);
50+
virtual const std::string& getDebugLogFile();
5151
virtual int getDebugLogLevel();
5252

5353
int m_debugLevel;

0 commit comments

Comments
 (0)