Skip to content

Commit fbe0d1a

Browse files
committed
Added const reported by cppcheck 2.14
1 parent 1ec4c20 commit fbe0d1a

Some content is hidden

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

44 files changed

+96
-95
lines changed

headers/modsecurity/anchored_set_variable_translation_proxy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AnchoredSetVariableTranslationProxy {
4242
: m_name(name),
4343
m_fount(fount)
4444
{
45-
m_translate = [](std::string *name, std::vector<const VariableValue *> *l) {
45+
m_translate = [](const std::string *name, std::vector<const VariableValue *> *l) {
4646
for (int i = 0; i < l->size(); ++i) {
4747
VariableValue *newVariableValue = new VariableValue(name, &l->at(i)->getKey(), &l->at(i)->getKey());
4848
const VariableValue *oldVariableValue = l->at(i);

headers/modsecurity/rule_message.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class RuleMessage {
4848
* unnecessary data duplication. Needs to be shrink down.
4949
*
5050
*/
51-
RuleMessage(RuleWithActions *rule, Transaction *trans) :
51+
RuleMessage(RuleWithActions *rule, const Transaction *trans) :
5252
m_accuracy(rule->m_accuracy),
5353
m_clientIpAddress(trans->m_clientIpAddress),
5454
m_data(""),
@@ -73,7 +73,7 @@ class RuleMessage {
7373
m_tags()
7474
{ }
7575

76-
explicit RuleMessage(RuleMessage *rule) :
76+
explicit RuleMessage(const RuleMessage *rule) :
7777
m_accuracy(rule->m_accuracy),
7878
m_clientIpAddress(rule->m_clientIpAddress),
7979
m_data(rule->m_data),
@@ -158,16 +158,16 @@ class RuleMessage {
158158
m_ver = "";
159159
}
160160

161-
std::string log() {
161+
std::string log() const {
162162
return log(this, 0);
163163
}
164-
std::string log(int props) {
164+
std::string log(int props) const {
165165
return log(this, props);
166166
}
167-
std::string log(int props, int responseCode) {
167+
std::string log(int props, int responseCode) const {
168168
return log(this, props, responseCode);
169169
}
170-
std::string errorLog() {
170+
std::string errorLog() const {
171171
return log(this,
172172
ClientLogMessageInfo | ErrorLogTailLogMessageInfo);
173173
}

headers/modsecurity/rule_with_actions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class RuleWithActions : public Rule {
136136
bool chainedParentNull = false);
137137

138138
std::vector<actions::Action *> getActionsByName(const std::string& name,
139-
Transaction *t);
139+
const Transaction *t);
140140
bool containsTag(const std::string& name, Transaction *t);
141141
bool containsMsg(const std::string& name, Transaction *t);
142142

headers/modsecurity/rules.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Rules {
5050
int append(Rules *from, const std::vector<int64_t> &ids, std::ostringstream *err) {
5151
size_t j = 0;
5252
for (; j < from->size(); j++) {
53-
RuleWithOperator *rule = dynamic_cast<RuleWithOperator *>(from->at(j).get());
53+
const RuleWithOperator *rule = dynamic_cast<RuleWithOperator *>(from->at(j).get());
5454
if (rule && std::binary_search(ids.begin(), ids.end(), rule->m_ruleId)) {
5555
if (err != NULL) {
5656
*err << "Rule id: " << std::to_string(rule->m_ruleId) \
@@ -68,7 +68,7 @@ class Rules {
6868
}
6969

7070
bool insert(std::shared_ptr<Rule> rule, const std::vector<int64_t> *ids, std::ostringstream *err) {
71-
RuleWithOperator *r = dynamic_cast<RuleWithOperator *>(rule.get());
71+
const RuleWithOperator *r = dynamic_cast<RuleWithOperator *>(rule.get());
7272
if (r && ids != nullptr && std::binary_search(ids->begin(), ids->end(), r->m_ruleId)) {
7373
if (err != nullptr) {
7474
*err << "Rule id: " << std::to_string(r->m_ruleId) \

headers/modsecurity/rules_set.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ extern "C" {
9393
#endif
9494

9595
RulesSet *msc_create_rules_set(void);
96-
void msc_rules_dump(RulesSet *rules);
96+
void msc_rules_dump(const RulesSet *rules);
9797
int msc_rules_merge(RulesSet *rules_dst, RulesSet *rules_from, const char **error);
9898
int msc_rules_add_remote(RulesSet *rules, const char *key, const char *uri,
9999
const char **error);

headers/modsecurity/rules_set_properties.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ConfigInt {
7070
bool m_set;
7171
int m_value;
7272

73-
void merge(ConfigInt *from) {
73+
void merge(const ConfigInt *from) {
7474
if (m_set == true || from->m_set == false) {
7575
return;
7676
}
@@ -87,7 +87,7 @@ class ConfigDouble {
8787
bool m_set;
8888
double m_value;
8989

90-
void merge(ConfigDouble *from) {
90+
void merge(const ConfigDouble *from) {
9191
if (m_set == true || from->m_set == false) {
9292
return;
9393
}
@@ -104,7 +104,7 @@ class ConfigString {
104104
bool m_set;
105105
std::string m_value;
106106

107-
void merge(ConfigString *from) {
107+
void merge(const ConfigString *from) {
108108
if (m_set == true || from->m_set == false) {
109109
return;
110110
}
@@ -150,7 +150,7 @@ class ConfigUnicodeMap {
150150
static void loadConfig(std::string f, double codePage,
151151
RulesSetProperties *driver, std::string *errg);
152152

153-
void merge(ConfigUnicodeMap *from) {
153+
void merge(const ConfigUnicodeMap *from) {
154154
if (from->m_set == false) {
155155
return;
156156
}

headers/modsecurity/transaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ int msc_process_uri(Transaction *transaction, const char *uri,
704704
const char *protocol, const char *http_version);
705705

706706
/** @ingroup ModSecurity_C_API */
707-
const char *msc_get_response_body(Transaction *transaction);
707+
const char *msc_get_response_body(const Transaction *transaction);
708708

709709
/** @ingroup ModSecurity_C_API */
710710
size_t msc_get_response_body_length(Transaction *transaction);

src/actions/transformations/normalise_path.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int NormalisePath::normalize_path_inplace(unsigned char *input, int input_len,
6565
int win, int *changed) {
6666
unsigned char *src;
6767
unsigned char *dst;
68-
unsigned char *end;
68+
const unsigned char *end;
6969
int ldst = 0;
7070
int hitroot = 0;
7171
int done = 0;
@@ -185,7 +185,7 @@ int NormalisePath::normalize_path_inplace(unsigned char *input, int input_len,
185185

186186
/* Skip to the last forward slash when multiple are used. */
187187
if (*src == '/') {
188-
unsigned char *oldsrc = src;
188+
const unsigned char *oldsrc = src;
189189

190190
while ((src < end)
191191
&& ((*(src + 1) == '/') || (win && (*(src + 1) == '\\'))) ) {

src/actions/transformations/sql_hex_decode.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ std::string SqlHexDecode::evaluate(const std::string &value,
6666

6767

6868
int SqlHexDecode::inplace(unsigned char *data, int len) {
69-
unsigned char *d, *begin = data;
69+
unsigned char *d;
70+
const unsigned char *begin = data;
7071
int count = 0;
7172

7273
if ((data == NULL) || (len == 0)) {
@@ -103,7 +104,7 @@ int SqlHexDecode::inplace(unsigned char *data, int len) {
103104
}
104105

105106
*d = '\0';
106-
return strlen(reinterpret_cast<char *>(begin));
107+
return strlen(reinterpret_cast<const char *>(begin));
107108
}
108109

109110

src/collection/backend/lmdb.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ void LMDB::resolveMultiMatches(const std::string& var,
557557
continue;
558558
}
559559

560-
char *a = reinterpret_cast<char *>(key.mv_data);
560+
const char *a = reinterpret_cast<char *>(key.mv_data);
561561
if (strncmp(var.c_str(), a, keySize) == 0) {
562562
std::string key_to_insert(reinterpret_cast<char *>(key.mv_data), key.mv_size);
563563
l->insert(l->begin(), new VariableValue(&m_name, &key_to_insert, &collectionData.getValue()));

0 commit comments

Comments
 (0)