From 606f5721c2b52e030f1028ae4e62f359a86443ce Mon Sep 17 00:00:00 2001 From: Martin Vierula Date: Wed, 27 Apr 2022 08:57:09 -0700 Subject: [PATCH] Change some parms to const reference (satisfies cppcheck) --- headers/modsecurity/transaction.h | 2 +- src/operators/operator.cc | 2 +- src/operators/operator.h | 3 ++- src/transaction.cc | 2 +- src/variables/tx.h | 2 +- test/cppcheck_suppressions.txt | 3 --- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/headers/modsecurity/transaction.h b/headers/modsecurity/transaction.h index bd3426cb..194b544c 100644 --- a/headers/modsecurity/transaction.h +++ b/headers/modsecurity/transaction.h @@ -399,7 +399,7 @@ class Transaction : public TransactionAnchoredVariables, public TransactionSecMa size_t getRequestBodyLength(); #ifndef NO_LOGS - void debug(int, std::string) const; + void debug(int, const std::string&) const; #endif void serverLog(std::shared_ptr rm); diff --git a/src/operators/operator.cc b/src/operators/operator.cc index b74b0729..57974bac 100644 --- a/src/operators/operator.cc +++ b/src/operators/operator.cc @@ -138,7 +138,7 @@ bool Operator::evaluate(Transaction *transaction, const std::string& a) { return true; } -Operator *Operator::instantiate(std::string op, std::string param_str) { +Operator *Operator::instantiate(const std::string& op, const std::string& param_str) { std::string op_ = utils::string::tolower(op); std::unique_ptr param(new RunTimeString()); param->appendText(param_str); diff --git a/src/operators/operator.h b/src/operators/operator.h index 4a21e595..bcf14e9d 100644 --- a/src/operators/operator.h +++ b/src/operators/operator.h @@ -101,7 +101,8 @@ class Operator { } virtual ~Operator() { } - static Operator *instantiate(std::string opName, std::string param); + static Operator *instantiate(const std::string& opName, + const std::string& param); virtual bool init(const std::string &arg, std::string *error) { return true; diff --git a/src/transaction.cc b/src/transaction.cc index 96f9c21b..ea7321d9 100644 --- a/src/transaction.cc +++ b/src/transaction.cc @@ -278,7 +278,7 @@ Transaction::~Transaction() { * */ #ifndef NO_LOGS -void Transaction::debug(int level, std::string message) const { +void Transaction::debug(int level, const std::string& message) const { if (m_rules == NULL) { return; } diff --git a/src/variables/tx.h b/src/variables/tx.h index cc344a7a..1fae827f 100644 --- a/src/variables/tx.h +++ b/src/variables/tx.h @@ -99,7 +99,7 @@ class Tx_DynamicElement : public Variable { } static void storeOrUpdateFirst(Transaction *t, const std::string &var, - std::string value) { + const std::string &value) { t->m_collections.m_tx_collection->storeOrUpdateFirst(var, value); } diff --git a/test/cppcheck_suppressions.txt b/test/cppcheck_suppressions.txt index 64d0d2b6..5a8eb58a 100644 --- a/test/cppcheck_suppressions.txt +++ b/test/cppcheck_suppressions.txt @@ -61,10 +61,7 @@ ctunullpointer:src/rule_with_operator.cc:135 ctunullpointer:src/rule_with_operator.cc:95 passedByValue:src/variables/global.h:109 passedByValue:src/variables/global.h:110 -passedByValue:src/variables/tx.h:102 -passedByValue:src/operators/operator.cc:141 passedByValue:src/parser/driver.cc:45 -passedByValue:src/transaction.cc:281 passedByValue:src/utils/system.cc:154 passedByValue:src/utils/system.cc:166 passedByValue:test/common/modsecurity_test.cc:49