Skip to content

Commit c805648

Browse files
authored
Merge pull request #3134 from eduar-hte/inline-cppcheck-suppressions
Remove cppcheck suppressions with line numbers in test/cppcheck_suppressions.txt
2 parents 07e5a70 + 1f419bb commit c805648

21 files changed

+41
-87
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ cppcheck:
5959
@cppcheck -U YYSTYPE -U MBEDTLS_MD5_ALT -U MBEDTLS_SHA1_ALT \
6060
-D MS_CPPCHECK_DISABLED_FOR_PARSER -U YY_USER_INIT \
6161
--suppressions-list=./test/cppcheck_suppressions.txt \
62+
--inline-suppr \
6263
--enable=warning,style,performance,portability,unusedFunction,missingInclude \
6364
--inconclusive \
6465
--template="warning: {file},{line},{severity},{id},{message}" \

examples/reading_logs_via_rule_message/reading_logs_via_rule_message.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,35 +124,31 @@ class ReadingLogsViaRuleMessage {
124124
m_rules(rules)
125125
{ }
126126

127-
int process() {
127+
int process() const {
128128
pthread_t threads[NUM_THREADS];
129129
int i;
130130
struct data_ms dms;
131131
void *status;
132132

133-
modsecurity::ModSecurity *modsec;
134-
modsecurity::RulesSet *rules;
135-
136-
modsec = new modsecurity::ModSecurity();
133+
auto modsec = std::make_unique<modsecurity::ModSecurity>();
137134
modsec->setConnectorInformation("ModSecurity-test v0.0.1-alpha" \
138135
" (ModSecurity test)");
139136
modsec->setServerLogCb(logCb, modsecurity::RuleMessageLogProperty
140137
| modsecurity::IncludeFullHighlightLogProperty);
141138

142-
rules = new modsecurity::RulesSet();
139+
auto rules = std::make_unique<modsecurity::RulesSet>();
143140
if (rules->loadFromUri(m_rules.c_str()) < 0) {
144141
std::cout << "Problems loading the rules..." << std::endl;
145142
std::cout << rules->m_parserError.str() << std::endl;
146143
return -1;
147144
}
148145

149-
dms.modsec = modsec;
150-
dms.rules = rules;
146+
dms.modsec = modsec.get();
147+
dms.rules = rules.get();
151148

152149
for (i = 0; i < NUM_THREADS; i++) {
153150
pthread_create(&threads[i], NULL, process_request,
154151
reinterpret_cast<void *>(&dms));
155-
// process_request((void *)&dms);
156152
}
157153

158154
usleep(10000);
@@ -162,8 +158,6 @@ class ReadingLogsViaRuleMessage {
162158
std::cout << "Main: completed thread id :" << i << std::endl;
163159
}
164160

165-
delete rules;
166-
delete modsec;
167161
return 0;
168162
}
169163

headers/modsecurity/transaction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class TransactionSecMarkerManagement {
310310
if (m_marker) {
311311
return m_marker;
312312
} else {
313-
throw;
313+
throw; // cppcheck-suppress rethrowNoCurrentException
314314
}
315315
}
316316

@@ -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, const std::string &) const; // cppcheck-suppress functionStatic
409409
#endif
410410
void serverLog(std::shared_ptr<RuleMessage> rm);
411411

src/audit_log/writer/parallel.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ bool Parallel::write(Transaction *transaction, int parts, std::string *error) {
118118
log = transaction->toOldAuditLogFormat(parts, "-" + boundary + "--");
119119
}
120120

121-
std::string logPath = m_audit->m_storage_dir;
121+
const auto &logPath = m_audit->m_storage_dir;
122122
fileName = logPath + fileName + "-" + *transaction->m_id.get();
123123

124124
if (logPath.empty()) {

src/collection/backend/lmdb.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ MDB_dbi* MDBEnvProvider::GetDBI() {
659659
return &m_dbi;
660660
}
661661

662-
bool MDBEnvProvider::isValid() {
662+
bool MDBEnvProvider::isValid() const {
663663
return valid;
664664
}
665665

src/collection/backend/lmdb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class MDBEnvProvider {
8383
}
8484
MDB_env* GetEnv();
8585
MDB_dbi* GetDBI();
86-
bool isValid();
86+
bool isValid() const;
8787

8888
~MDBEnvProvider();
8989
private:

src/engine/lua.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class Lua {
6767
public:
6868
Lua() { }
6969

70-
bool load(const std::string &script, std::string *err);
71-
int run(Transaction *t, const std::string &str="");
70+
bool load(const std::string &script, std::string *err); // cppcheck-suppress functionStatic ; triggered when compiling without LUA
71+
int run(Transaction *t, const std::string &str = ""); // cppcheck-suppress functionStatic ; triggered when compiling without LUA
7272
static bool isCompatible(const std::string &script, Lua *l, std::string *error);
7373

7474
#ifdef WITH_LUA

src/modsecurity.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void ModSecurity::serverLog(void *data, std::shared_ptr<RuleMessage> rm) {
202202
}
203203

204204
if (m_logProperties & TextLogProperty) {
205-
std::string &&d = rm->log();
205+
auto d = rm->log();
206206
const void *a = static_cast<const void *>(d.c_str());
207207
m_logCb(data, a);
208208
return;

src/operators/geo_lookup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class GeoLookup : public Operator {
3232
bool evaluate(Transaction *transaction, const std::string &exp) override;
3333

3434
protected:
35+
// cppcheck-suppress functionStatic
3536
bool debug(Transaction *transaction, int x, const std::string &a) {
3637
ms_dbg_a(transaction, x, a);
3738
return true;

src/operators/rbl.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ class Rbl : public Operator {
6666
m_demandsPassword(false),
6767
m_provider(RblProvider::UnknownProvider),
6868
Operator("Rbl", std::move(param)) {
69-
m_service = m_string->evaluate();
70-
if (m_service.find("httpbl.org") != std::string::npos) {
71-
m_demandsPassword = true;
72-
m_provider = RblProvider::httpbl;
69+
m_service = m_string->evaluate(); // cppcheck-suppress useInitializationList
70+
if (m_service.find("httpbl.org") != std::string::npos)
71+
{
72+
m_demandsPassword = true;
73+
m_provider = RblProvider::httpbl;
7374
} else if (m_service.find("uribl.com") != std::string::npos) {
7475
m_provider = RblProvider::uribl;
7576
} else if (m_service.find("spamhaus.org") != std::string::npos) {

0 commit comments

Comments
 (0)