Skip to content

Commit 214cc15

Browse files
committed
Cosmetics: Reduce the coding style warnings
1 parent c433910 commit 214cc15

File tree

7 files changed

+22
-25
lines changed

7 files changed

+22
-25
lines changed

headers/modsecurity/rule.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <stack>
1818
#include <vector>
1919
#include <string>
20+
#include <list>
2021
#endif
2122

2223
#ifndef HEADERS_MODSECURITY_RULE_H_
@@ -90,7 +91,7 @@ class Rule {
9091

9192
class RuleMessage {
9293
public:
93-
RuleMessage(Rule *rule) :
94+
explicit RuleMessage(Rule *rule) :
9495
m_ruleFile(rule->m_fileName),
9596
m_ruleLine(rule->m_lineNumber),
9697
m_ruleId(rule->rule_id),

headers/modsecurity/transaction/variables.h

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,21 @@ namespace transaction {
4747
* We have to have a better hash function, maybe based on the std::hash.
4848
*
4949
*/
50-
struct MyEqual
51-
{
52-
bool operator()(const std::string& Left, const std::string& Right) const
53-
{
50+
struct MyEqual {
51+
bool operator()(const std::string& Left, const std::string& Right) const {
5452
return Left.size() == Right.size()
55-
&& std::equal ( Left.begin() , Left.end() , Right.begin(),
56-
[]( char a , char b )
57-
{
53+
&& std::equal(Left.begin(), Left.end(), Right.begin(),
54+
[](char a, char b) {
5855
return tolower(a) == tolower(b);
59-
}
60-
);
56+
});
6157
}
6258
};
6359

64-
struct MyHash
65-
{
66-
size_t operator()(const std::string& Keyval) const
67-
{
68-
//You might need a better hash function than this
60+
struct MyHash{
61+
size_t operator()(const std::string& Keyval) const {
62+
// You might need a better hash function than this
6963
size_t h = 0;
70-
std::for_each( Keyval.begin() , Keyval.end() , [&](char c )
71-
{
64+
std::for_each(Keyval.begin(), Keyval.end(), [&](char c) {
7265
h += tolower(c);
7366
});
7467
return h;
@@ -92,14 +85,12 @@ class Variables :
9285

9386
std::string* resolveFirst(const std::string& var);
9487

95-
9688
void resolveSingleMatch(const std::string& var,
9789
std::vector<const transaction::Variable *> *l);
9890
void resolveMultiMatches(const std::string& var,
9991
std::vector<const transaction::Variable *> *l);
10092
void resolveRegularExpression(const std::string& var,
10193
std::vector<const transaction::Variable *> *l);
102-
10394
};
10495

10596
} // namespace transaction

src/actions/log_data.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class LogData : public Action {
3131
public:
3232
explicit LogData(std::string action);
3333

34-
bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) override;
34+
bool evaluate(Rule *rule, Transaction *transaction,
35+
RuleMessage *rm) override;
3536

3637
private:
3738
std::string m_data;

src/actions/tag.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class Tag : public Action {
3131
public:
3232
explicit Tag(std::string action);
3333

34-
bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) override;
34+
bool evaluate(Rule *rule, Transaction *transaction,
35+
RuleMessage *rm) override;
3536

3637
private:
3738
std::string m_tag;

src/actions/transformations/html_entity_decode.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ std::string HtmlEntityDecode::evaluate(std::string value,
4545

4646
// FIXME: html_entities_decode_inplace is not working as expected
4747
// temporary disabled to perform the audit_log tests.
48-
//html_entities_decode_inplace((unsigned char *)tmp, value.size());
48+
// html_entities_decode_inplace((unsigned char *)tmp, value.size());
4949
std::string ret("");
5050
ret.assign(tmp);
5151
free(tmp);

src/rule.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ bool Rule::evaluate(Transaction *trasn) {
515515
}
516516
}
517517

518-
if ((!m_log_message.empty() || !m_log_data.empty()) && !ruleMessage->m_match.empty()) {
518+
if ((!m_log_message.empty() || !m_log_data.empty())
519+
&& !ruleMessage->m_match.empty()) {
519520
ruleMessage->m_data = m_log_data;
520521
trasn->m_rulesMessages.push_back(ruleMessage);
521522
} else {

src/transaction.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,8 @@ int Transaction::processLogging(int returned_code) {
11951195
#endif
11961196
std::list<std::pair<int, std::string>>::iterator it;
11971197
parts = this->m_rules->audit_log->m_parts;
1198-
debug(7, "AuditLog parts before modification(s): " + std::to_string(parts) + ".");
1198+
debug(7, "AuditLog parts before modification(s): " +
1199+
std::to_string(parts) + ".");
11991200
for (it = m_auditLogModifier.begin();
12001201
it != m_auditLogModifier.end(); ++it) {
12011202
std::pair <int, std::string> p = *it;
@@ -1219,7 +1220,8 @@ int Transaction::processLogging(int returned_code) {
12191220
bool saved = this->m_rules->audit_log->saveIfRelevant(this, parts);
12201221
if (saved) {
12211222
#ifndef NO_LOGS
1222-
debug(8, "Request was relevant to be saved. Parts: " + std::to_string(parts));
1223+
debug(8, "Request was relevant to be saved. Parts: " +
1224+
std::to_string(parts));
12231225
#endif
12241226
}
12251227
}

0 commit comments

Comments
 (0)