Skip to content

Commit bbef22b

Browse files
eduar-hteEduardo Arias
authored andcommitted
Added const reported by cppcheck 2.14
1 parent d053ec6 commit bbef22b

Some content is hidden

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

46 files changed

+110
-112
lines changed

examples/multithread/multithread.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int main (int argc, char *argv[]) {
4040
modsec->setConnectorInformation("ModSecurity-test v0.0.1-alpha (Simple " \
4141
"example on how to use ModSecurity API");
4242

43-
char main_rule_uri[] = "basic_rules.conf";
43+
const char main_rule_uri[] = "basic_rules.conf";
4444
auto rules = std::make_unique<modsecurity::RulesSet>();
4545
if (rules->loadFromUri(main_rule_uri) < 0) {
4646
std::cerr << "Problems loading the rules..." << std::endl;

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_with_actions.h

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

8181
std::vector<actions::Action *> getActionsByName(const std::string& name,
82-
Transaction *t);
82+
const Transaction *t);
8383
bool containsTag(const std::string& name, Transaction *t);
8484
bool containsMsg(const std::string& name, Transaction *t);
8585

headers/modsecurity/rule_with_operator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class RuleWithOperator : public RuleWithActions {
6262
static void cleanMatchedVars(Transaction *trasn);
6363

6464

65-
std::string getOperatorName() const;
65+
const std::string& getOperatorName() const;
6666

6767
virtual std::string getReference() override {
6868
return std::to_string(m_ruleId);

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
@@ -713,7 +713,7 @@ int msc_process_uri(Transaction *transaction, const char *uri,
713713
const char *protocol, const char *http_version);
714714

715715
/** @ingroup ModSecurity_C_API */
716-
const char *msc_get_response_body(Transaction *transaction);
716+
const char *msc_get_response_body(const Transaction *transaction);
717717

718718
/** @ingroup ModSecurity_C_API */
719719
size_t msc_get_response_body_length(Transaction *transaction);

src/actions/ctl/rule_remove_by_id.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ bool RuleRemoveById::init(std::string *error) {
8484
}
8585

8686
bool RuleRemoveById::evaluate(RuleWithActions *rule, Transaction *transaction) {
87-
for (auto &i : m_ids) {
87+
for (const auto &i : m_ids) {
8888
transaction->m_ruleRemoveById.push_back(i);
8989
}
90-
for (auto &i : m_ranges) {
90+
for (const auto &i : m_ranges) {
9191
transaction->m_ruleRemoveByIdRange.push_back(i);
9292
}
9393

src/actions/transformations/hex_decode.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static inline int inplace(std::string &value) {
2626

2727
const auto len = value.length();
2828
auto d = reinterpret_cast<unsigned char *>(value.data());
29-
const auto data = d;
29+
const auto *data = d;
3030

3131
for (int i = 0; i <= len - 2; i += 2) {
3232
*d++ = utils::string::x2c(&data[i]);

0 commit comments

Comments
 (0)